Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
3348266
First commit
Nov 9, 2022
9bc664a
Add pixelation shader
Nov 9, 2022
e8506f3
update workflow
Nov 9, 2022
d7d43ca
++
Nov 9, 2022
70ad41b
++
Nov 9, 2022
3389e7e
Merge pull request #1 from jonahwilliams/add_filters
Nov 9, 2022
8ce26fb
switch to flutter runtime effect
Nov 16, 2022
17fda50
Merge pull request #2 from jonahwilliams/add_ffg
Nov 16, 2022
8e4c71d
Fix docs for fragment shader breaking changes
Dec 5, 2022
defb8b8
Merge pull request #3 from jonahwilliams/fix_image_sampler_docs
Dec 5, 2022
4bb1124
Add support for configuring inkwell shader
Dec 10, 2022
9a3c1df
update workflows
Dec 10, 2022
317e61d
format
Dec 10, 2022
680f6d6
Update inkwell_test.dart
Dec 11, 2022
d2fff45
Add support for configuring inkwell shader
Dec 11, 2022
2b7646d
Call `AnimatedSampler.builder` from `Layer.addToScene` to update ever…
blaugold Dec 15, 2022
1974183
Address review
blaugold Dec 20, 2022
6c364e7
Fixup test
blaugold Dec 20, 2022
85db96e
Add license header
blaugold Dec 20, 2022
e398c37
Use single layer
blaugold Dec 20, 2022
f079183
Call `AnimatedSampler.builder` from `Layer.addToScene` to update ever…
Dec 20, 2022
f8ccdfb
update changelog and version
Dec 20, 2022
1a63e41
Merge pull request #6 from jonahwilliams/ready_for_release
Dec 20, 2022
79e4d56
fix offset transforming animated sampler children off the screen
Jan 4, 2023
248ca93
Update sampler.frag
Jan 4, 2023
3e5dbf0
Merge pull request #7 from jonahwilliams/make_rpb
Jan 4, 2023
2266910
++
Jan 4, 2023
e712652
Merge pull request #8 from jonahwilliams/p123
Jan 4, 2023
a859335
example with adjustable sampler
Jan 12, 2023
2f0e219
++
Jan 12, 2023
ca2f5f1
Merge pull request #9 from jonahwilliams/more_sample_code
Jan 12, 2023
3918321
Update URLs
goderbauer Feb 21, 2023
4fe348d
Update CHANGELOG.md
goderbauer Feb 21, 2023
cf3ea19
Merge pull request #10 from goderbauer/patch-1
Mar 2, 2023
f80f1ea
Bump versions for publishing
Mar 2, 2023
c414314
Merge pull request #11 from jonahwilliams/bump_to_zero_dot_1
Mar 2, 2023
8d11634
Resolved issues errors when enabled=false
gskinner Mar 23, 2023
db5c6fa
Resolves errors when the target widget is empty
gskinner Mar 23, 2023
d915278
Adjust enabled check per feedback
gskinner Mar 25, 2023
777206b
Merge pull request #15 from gskinner/main
Mar 25, 2023
c0cedd7
update for release
Mar 25, 2023
3264bf2
Merge pull request #16 from jonahwilliams/release
Mar 25, 2023
f413185
feat: add uniform setter
renancaraujo Jun 19, 2023
c87c907
docs
renancaraujo Jun 19, 2023
defa646
dart format
renancaraujo Jun 21, 2023
92c6ba0
add premultiply option
renancaraujo Jun 21, 2023
d971cd9
update example
renancaraujo Jun 21, 2023
118c496
uh
renancaraujo Jun 21, 2023
dfc1a12
Merge pull request #23 from renancaraujo/main
Jun 21, 2023
c0b4aa2
Publish prep.
Jun 25, 2023
97eaf0d
Merge pull request #24 from jonahwilliams/fix_leak_2
Jun 25, 2023
baa6a07
Fix pixelation shader not compiling
Spooky12 Jun 18, 2024
84d0a90
Merge pull request #36 from Spooky12/main
Jun 20, 2024
080f77e
update version.
Jun 20, 2024
0463e09
Merge pull request #37 from jonahwilliams/roll_version
Jun 20, 2024
2802b9e
Initial import of flutter_shaders
tarrinneal Aug 24, 2026
6eb14ba
import initial flutter shaders directory
tarrinneal Aug 24, 2026
80c73e4
add headers, change dart and flutter constraints
tarrinneal Aug 24, 2026
3103657
dart fix
tarrinneal Aug 24, 2026
8e3615f
format and add comments
tarrinneal Aug 24, 2026
239bef6
for -> forEach
tarrinneal Aug 24, 2026
5d4bb92
update Uniform Setter to work with new dart base class rules and fix …
tarrinneal Aug 25, 2026
793f2d2
run validation, format example
tarrinneal Aug 25, 2026
41d170a
version bump
tarrinneal Aug 25, 2026
2b07642
more changelog
tarrinneal Aug 25, 2026
88b222a
skip test on web
tarrinneal Aug 25, 2026
bd531bb
skip example tests on web
tarrinneal Aug 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
- any-glob-to-any-file:
- packages/flutter_plugin_android_lifecycle/**/*

'p: flutter_shaders':
- changed-files:
- any-glob-to-any-file:
- packages/flutter_shaders/**/*

'p: flutter_svg':
- changed-files:
- any-glob-to-any-file:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ These are the packages hosted in this repository:
| [file\_selector](./packages/file_selector/) | [![pub package](https://img.shields.io/pub/v/file_selector.svg)](https://pub.dev/packages/file_selector) | [![pub points](https://img.shields.io/pub/points/file_selector)](https://pub.dev/packages/file_selector/score) | [![downloads](https://img.shields.io/pub/dm/file_selector)](https://pub.dev/packages/file_selector/score) | [![GitHub issues by-label](https://img.shields.io/github/issues/flutter/flutter/p%3A%20file_selector?label=)](https://github.com/flutter/flutter/labels/p%3A%20file_selector) | [![GitHub pull requests by-label](https://img.shields.io/github/issues-pr/flutter/packages/p%3A%20file_selector?label=)](https://github.com/flutter/packages/labels/p%3A%20file_selector) |
| [flutter\_lints](./packages/flutter_lints/) | [![pub package](https://img.shields.io/pub/v/flutter_lints.svg)](https://pub.dev/packages/flutter_lints) | [![pub points](https://img.shields.io/pub/points/flutter_lints)](https://pub.dev/packages/flutter_lints/score) | [![downloads](https://img.shields.io/pub/dm/flutter_lints)](https://pub.dev/packages/flutter_lints/score) | [![GitHub issues by-label](https://img.shields.io/github/issues/flutter/flutter/p%3A%20flutter_lints?label=)](https://github.com/flutter/flutter/labels/p%3A%20flutter_lints) | [![GitHub pull requests by-label](https://img.shields.io/github/issues-pr/flutter/packages/p%3A%20flutter_lints?label=)](https://github.com/flutter/packages/labels/p%3A%20flutter_lints) |
| [flutter\_plugin\_android\_lifecycle](./packages/flutter_plugin_android_lifecycle/) | [![pub package](https://img.shields.io/pub/v/flutter_plugin_android_lifecycle.svg)](https://pub.dev/packages/flutter_plugin_android_lifecycle) | [![pub points](https://img.shields.io/pub/points/flutter_plugin_android_lifecycle)](https://pub.dev/packages/flutter_plugin_android_lifecycle/score) | [![downloads](https://img.shields.io/pub/dm/flutter_plugin_android_lifecycle)](https://pub.dev/packages/flutter_plugin_android_lifecycle/score) | [![GitHub issues by-label](https://img.shields.io/github/issues/flutter/flutter/p%3A%20flutter_plugin_android_lifecycle?label=)](https://github.com/flutter/flutter/labels/p%3A%20flutter_plugin_android_lifecycle) | [![GitHub pull requests by-label](https://img.shields.io/github/issues-pr/flutter/packages/p%3A%20flutter_plugin_android_lifecycle?label=)](https://github.com/flutter/packages/labels/p%3A%20flutter_plugin_android_lifecycle) |
| [flutter\_shaders](./packages/flutter_shaders/) | [![pub package](https://img.shields.io/pub/v/flutter_shaders.svg)](https://pub.dev/packages/flutter_shaders) | [![pub points](https://img.shields.io/pub/points/flutter_shaders)](https://pub.dev/packages/flutter_shaders/score) | [![downloads](https://img.shields.io/pub/dm/flutter_shaders)](https://pub.dev/packages/flutter_shaders/score) | [![GitHub issues by-label](https://img.shields.io/github/issues/flutter/flutter/p%3A%20flutter_shaders?label=)](https://github.com/flutter/flutter/labels/p%3A%20flutter_shaders) | [![GitHub pull requests by-label](https://img.shields.io/github/issues-pr/flutter/packages/p%3A%20flutter_shaders?label=)](https://github.com/flutter/packages/labels/p%3A%20flutter_shaders) |
| [flutter\_svg](./third_party/packages/flutter_svg/) | [![pub package](https://img.shields.io/pub/v/flutter_svg.svg)](https://pub.dev/packages/flutter_svg) | [![pub points](https://img.shields.io/pub/points/flutter_svg)](https://pub.dev/packages/flutter_svg/score) | [![downloads](https://img.shields.io/pub/dm/flutter_svg)](https://pub.dev/packages/flutter_svg/score) | [![GitHub issues by-label](https://img.shields.io/github/issues/flutter/flutter/p%3A%20flutter_svg?label=)](https://github.com/flutter/flutter/labels/p%3A%20flutter_svg) | [![GitHub pull requests by-label](https://img.shields.io/github/issues-pr/flutter/packages/p%3A%20flutter_svg?label=)](https://github.com/flutter/packages/labels/p%3A%20flutter_svg) |
| [flutter\_svg\_test](./third_party/packages/flutter_svg_test/) | [![pub package](https://img.shields.io/pub/v/flutter_svg_test.svg)](https://pub.dev/packages/flutter_svg_test) | [![pub points](https://img.shields.io/pub/points/flutter_svg_test)](https://pub.dev/packages/flutter_svg_test/score) | [![downloads](https://img.shields.io/pub/dm/flutter_svg_test)](https://pub.dev/packages/flutter_svg_test/score) | [![GitHub issues by-label](https://img.shields.io/github/issues/flutter/flutter/p%3A%20flutter_svg_test?label=)](https://github.com/flutter/flutter/labels/p%3A%20flutter_svg_test) | [![GitHub pull requests by-label](https://img.shields.io/github/issues-pr/flutter/packages/p%3A%20flutter_svg_test?label=)](https://github.com/flutter/packages/labels/p%3A%20flutter_svg_test) |
| [go\_router](./packages/go_router/) | [![pub package](https://img.shields.io/pub/v/go_router.svg)](https://pub.dev/packages/go_router) | [![pub points](https://img.shields.io/pub/points/go_router)](https://pub.dev/packages/go_router/score) | [![downloads](https://img.shields.io/pub/dm/go_router)](https://pub.dev/packages/go_router/score) | [![GitHub issues by-label](https://img.shields.io/github/issues/flutter/flutter/p%3A%20go_router?label=)](https://github.com/flutter/flutter/labels/p%3A%20go_router) | [![GitHub pull requests by-label](https://img.shields.io/github/issues-pr/flutter/packages/p%3A%20go_router?label=)](https://github.com/flutter/packages/labels/p%3A%20go_router) |
Expand Down
21 changes: 21 additions & 0 deletions packages/flutter_shaders/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.packages
.pubspec.lock
.pub-cache/
.pub/
/build/
.idea/
7 changes: 7 additions & 0 deletions packages/flutter_shaders/AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Below is a list of people and organizations that have contributed
# to the Flutter project. Names should be added to the list like so:
#
# Name/Organization <email address>

Google Inc.
The Chromium Authors
58 changes: 58 additions & 0 deletions packages/flutter_shaders/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
## 0.1.4

* Transfers the package source from https://github.com/jonahwilliams/flutter_shaders
to https://github.com/flutter/packages.
* Updates metadata in `pubspec.yaml`.
* Updates minimum supported SDK version to Flutter 3.38/Dart 3.10.
* Adds [FloatUniformsSetter] interface for configuring float uniforms.
* Adds documentation comments for public APIs.
* Updates code for new analysis options.

## 0.1.3

* Remove unecessary location decorations for pixelation shader.

## 0.1.2

* Ensure constructed ui.Picture objects are disposed after usage.
* Add [SetUniforms] to help constructing FragmentShader uniform data.

## 0.1.1

* Fix `AnimatedSampler` offset assertion to no longer trigger incorrectly when shader is disabled.
* Fix runtime exception when the `AnimatedSampler` was asked to construct an image with no size.

## 0.1.0

* Update URLs in pubspec.yaml.

## 0.0.6

* Fix bug in `AnimatedSampler` that caused children with non-zero offsets to
be rendered offscreen.
* Removed `offset` parameter from `AnimatedSamplerBuilder`. The offset will
always be `Offset.zero` now and this is no longer necessary.


## 0.0.5

* Remove restriction on `AnimatedSampler` child repainting.

## 0.0.4

* Added `ShaderInkFeatureFactory` and `ShaderInkFeature` to allow configuration of a
material inkwell splash with a developer authored fragment shader and configuration
callback

## 0.0.3

* Updated documentation on `AnimatedSampler` to account for `FragmentShader` breaking
API changes.

## 0.0.2

* Add pixelation shader.

## 0.0.1

* First published version
25 changes: 25 additions & 0 deletions packages/flutter_shaders/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Copyright 2013 The Flutter Authors

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 changes: 31 additions & 0 deletions packages/flutter_shaders/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# flutter_shaders

A collection of utilities to make working with the FragmentProgram API easier.


## Available Shaders

This package includes a number of shaders that can be optionally included into your
application by declaring them in the pubspec.yaml:

### Pixelation

The pixelation shader reduces the provided sampler to MxN samples. This can be used with the [AnimatedSampler] widget. The required uniforms are:

Floats:
* The number of pixels in the X coordinate space.
* The number of pixels in the Y coordinate space.
* The width of the sampled area.
* The height of the sampled area.
Samplers:
* The child widget, captured as a texture.

To include this shader in your application, add the following line to
your pubspec.yaml

```yaml
flutter:
shaders:
- packages/flutter_shaders/shaders/pixelation.frag

```
53 changes: 53 additions & 0 deletions packages/flutter_shaders/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
pubspec.lock
.pub-cache/
.pub/
/build/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release

# Platform directories
android/
ios/
windows/
web/
macos/
linux/
3 changes: 3 additions & 0 deletions packages/flutter_shaders/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# example

A project for testing shaders with flutter_shaders
2 changes: 2 additions & 0 deletions packages/flutter_shaders/example/dart_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Fragment shaders are not supported in web unit tests.
test_on: vm
93 changes: 93 additions & 0 deletions packages/flutter_shaders/example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:ui' as ui;

import 'package:flutter/material.dart';
import 'package:flutter_shaders/flutter_shaders.dart';

void main() async {
final ui.FragmentProgram program = await ui.FragmentProgram.fromAsset('shaders/inkwell.frag');
runApp(MyApp(program: program));
}

/// The main application widget for the shader demo.
class MyApp extends StatelessWidget {
/// Creates the [MyApp] demo widget.
const MyApp({super.key, required this.program});

/// The fragment program used to power shader effects.
final ui.FragmentProgram program;

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
splashFactory: ShaderInkFeatureFactory(program, (
shader, {
required double animation,
required Color color,
required Offset position,
required Size referenceBoxSize,
required double targetRadius,
required TextDirection textDirection,
}) {
shader.setFloatUniforms(
(uniforms) => uniforms
..setFloat(animation)
..setColor(color, premultiply: true)
..setFloat(targetRadius)
..setOffset(position),
);
}),
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}

/// The home page widget displaying counter and shader effects.
class MyHomePage extends StatefulWidget {
/// Creates the home page with a given [title].
const MyHomePage({super.key, required this.title});

/// The title displayed in the AppBar.
final String title;

@override
State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;

void _incrementCounter() {
setState(() {
_counter++;
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(widget.title)),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text('You have pushed the button this many times:'),
Text('$_counter', style: Theme.of(context).textTheme.headlineMedium),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
}
77 changes: 77 additions & 0 deletions packages/flutter_shaders/example/lib/sampler_example.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';
import 'package:flutter_shaders/flutter_shaders.dart';

void main() {
runApp(const ExampleApp());
}

/// The example application widget showcasing shader sampling.
class ExampleApp extends StatefulWidget {
/// Creates the [ExampleApp] widget.
const ExampleApp({super.key});

@override
State<ExampleApp> createState() => _ExampleAppState();
}

class _ExampleAppState extends State<ExampleApp> {
double _value = 2.0;

void _onChanged(double newValue) {
setState(() {
_value = newValue;
});
}

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Shaders!')),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SampledText(text: 'This is some sampled text', value: _value),
Slider(value: _value, onChanged: _onChanged, min: 2, max: 50),
],
),
),
),
);
}
}

/// A widget that renders text sampled and pixelated through a custom fragment shader.
class SampledText extends StatelessWidget {
/// Creates a [SampledText] widget.
const SampledText({super.key, required this.text, required this.value});

/// The text content to display.
final String text;

/// The pixelation scale value applied to the shader.
final double value;

@override
Widget build(BuildContext context) {
return ShaderBuilder((context, shader, child) {
return AnimatedSampler((image, size, canvas) {
shader.setFloatUniforms((uniforms) {
uniforms
..setFloat(value)
..setFloat(value)
..setSize(size);
});

shader.setImageSampler(0, image);

canvas.drawRect(Rect.fromLTWH(0, 0, size.width, size.height), Paint()..shader = shader);
}, child: Text(text, style: const TextStyle(fontSize: 20)));
}, assetKey: 'packages/flutter_shaders/shaders/pixelation.frag');
}
}
Loading
Loading