From 5187c6e594a17e15839b444241ff383d8e9c0057 Mon Sep 17 00:00:00 2001 From: Guillaume Roux Date: Wed, 24 May 2023 01:06:22 +0200 Subject: [PATCH] prepare v2.0.0 --- .github/workflows/tests.yml | 8 +- CHANGELOG.md | 7 + analysis_options.yaml | 16 +- example/lib/main.dart | 112 ++++++++------ example/pubspec.lock | 122 ++++++++------- example/pubspec.yaml | 6 +- lib/icon_decoration.dart | 2 +- lib/src/decorated_icon.dart | 22 +-- lib/src/gradient_icon.dart | 38 ++--- lib/src/icon_border.dart | 10 +- lib/src/icon_decoration.dart | 19 +-- pubspec.lock | 137 +++++++++-------- pubspec.yaml | 11 +- test/borders_test.dart | 66 ++++---- test/flutter_test_config.dart | 3 +- test/gradient_test.dart | 132 ++++++++-------- test/shadows_test.dart | 66 ++++---- test/test_utils/base_widget.dart | 250 +++++++++++++++---------------- test/test_utils/gradients.dart | 79 +++++----- 19 files changed, 581 insertions(+), 525 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4e4e926..3f5baa3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,14 +10,12 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: subosito/flutter-action@v1.5.3 - with: - flutter-version: '2.10.2' + - uses: actions/checkout@v3 + - uses: subosito/flutter-action@v2.10.0 - run: flutter pub get - name: Test run: flutter test --coverage --dart-define=CI=true - name: Collect and report coverage - uses: coverallsapp/github-action@v1.1.2 + uses: coverallsapp/github-action@v2.1.2 with: github-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index a83cebc..ad29595 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 2.0.0 + +* Removed `IconDecoration.shadows`, use `Icon.shadows` instead +* Support for Dart 3 +* Upgraded dependencies +* Updated linting + ## 1.0.1 * Fix gradient issue [#3](https://github.com/TesteurManiak/icon_decoration/issues/3) diff --git a/analysis_options.yaml b/analysis_options.yaml index 7e778f2..ab25050 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,15 +1 @@ -include: package:flutter_lints/flutter.yaml - -linter: - rules: - - avoid_bool_literals_in_conditional_expressions - - avoid_escaping_inner_quotes - - avoid_positional_boolean_parameters - - flutter_style_todos - - one_member_abstracts - - parameter_assignments - - prefer_null_aware_method_calls - - require_trailing_commas - - use_is_even_rather_than_modulo - - use_named_constants - - use_to_and_as_if_applicable \ No newline at end of file +include: package:fd_lints/flutter.yaml diff --git a/example/lib/main.dart b/example/lib/main.dart index 6c0efaa..d855b44 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -6,7 +6,7 @@ void main() { } class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); + const MyApp({super.key}); @override Widget build(BuildContext context) { @@ -25,43 +25,39 @@ class MyApp extends StatelessWidget { child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Row( + const Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - const DecoratedIcon( + DecoratedIcon( icon: Icon( Icons.lightbulb_outline, color: Colors.lightBlueAccent, size: 36, - ), - decoration: IconDecoration( shadows: [ Shadow(blurRadius: 3, color: Colors.lightBlueAccent), ], ), ), DecoratedIcon( - icon: const Icon( - Icons.lightbulb_outline, - color: Colors.lightBlueAccent, - size: 36, - ), - decoration: IconDecoration(shadows: [ - Shadow( - blurRadius: 3, - color: Colors.lightBlueAccent.shade100, - ), - ]), + icon: Icon(Icons.lightbulb_outline, + color: Colors.lightBlueAccent, + size: 36, + shadows: [ + Shadow( + blurRadius: 3, + color: Color.fromARGB(255, 128, 216, 255), + ), + ]), ), - const DecoratedIcon( + DecoratedIcon( icon: Icon( Icons.lightbulb_outline, color: Colors.lightBlueAccent, size: 36, + shadows: [ + Shadow(blurRadius: 2, color: Colors.lightBlueAccent), + ], ), - decoration: IconDecoration(shadows: [ - Shadow(blurRadius: 2, color: Colors.lightBlueAccent), - ]), ) ], ), @@ -73,60 +69,77 @@ class MyApp extends StatelessWidget { Icons.home, color: Colors.green.shade900, size: 36, + shadows: const [ + Shadow(color: Colors.yellowAccent, blurRadius: 3), + ], ), - decoration: const IconDecoration(shadows: [ - Shadow(color: Colors.yellowAccent, blurRadius: 3), - ]), ), DecoratedIcon( icon: Icon( Icons.home, color: Colors.green.shade900, size: 36, + shadows: [ + Shadow(color: Colors.green.shade900, blurRadius: 3), + ], ), - decoration: IconDecoration(shadows: [ - Shadow(color: Colors.green.shade900, blurRadius: 3), - ]), ), DecoratedIcon( icon: Icon( Icons.home, color: Colors.green.shade900, size: 36, + shadows: [ + Shadow(color: Colors.green.shade900, blurRadius: 2), + ], ), - decoration: IconDecoration(shadows: [ - Shadow(color: Colors.green.shade900, blurRadius: 2), - ]), ) ], ), - Row( + const Row( mainAxisAlignment: MainAxisAlignment.center, children: [ DecoratedIcon( - icon: const Icon(Icons.access_alarm, size: 36), - decoration: IconDecoration(shadows: [ - Shadow( - color: Colors.yellowAccent.shade400, blurRadius: 3), - ]), + icon: Icon( + Icons.access_alarm, + size: 36, + shadows: [ + Shadow( + color: Color.fromARGB(255, 255, 234, 0), + blurRadius: 3, + ), + ], + ), ), DecoratedIcon( - icon: const Icon(Icons.access_alarm, size: 36), - decoration: IconDecoration(shadows: [ - Shadow(color: Colors.red.shade400, blurRadius: 3), - ]), + icon: Icon( + Icons.access_alarm, + size: 36, + shadows: [ + Shadow( + color: Color.fromARGB(255, 239, 83, 80), + blurRadius: 3, + ), + ], + ), ), DecoratedIcon( - icon: const Icon(Icons.access_alarm, size: 36), - decoration: IconDecoration(shadows: [ - Shadow(color: Colors.cyanAccent.shade400, blurRadius: 3), - ]), + icon: Icon( + Icons.access_alarm, + size: 36, + shadows: [ + Shadow( + color: Color.fromARGB(255, 0, 229, 255), + blurRadius: 3, + ), + ], + ), ) ], ), - Row( + const Row( mainAxisAlignment: MainAxisAlignment.center, - children: const [ + children: [ DecoratedIcon( icon: Icon(Icons.favorite, size: 36), decoration: IconDecoration( @@ -134,13 +147,16 @@ class MyApp extends StatelessWidget { ), ), DecoratedIcon( - icon: Icon(Icons.favorite, size: 36), - decoration: IconDecoration( - border: IconBorder(color: Colors.red, width: 4), + icon: Icon( + Icons.favorite, + size: 36, shadows: [ Shadow(color: Colors.red, blurRadius: 6), ], ), + decoration: IconDecoration( + border: IconBorder(color: Colors.red, width: 4), + ), ), DecoratedIcon( icon: Icon(Icons.favorite, size: 36, color: Colors.red), diff --git a/example/pubspec.lock b/example/pubspec.lock index 9de7066..8d613f4 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,58 +5,58 @@ packages: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.8.2" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.3.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.17.1" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.dartlang.org" + sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be + url: "https://pub.dev" source: hosted - version: "1.0.3" + version: "1.0.5" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.1" flutter: dependency: "direct main" description: flutter @@ -66,7 +66,8 @@ packages: dependency: "direct dev" description: name: flutter_lints - url: "https://pub.dartlang.org" + sha256: b543301ad291598523947dc534aaddc5aaad597b709d2426d3a0e0d44c5cb493 + url: "https://pub.dev" source: hosted version: "1.0.4" flutter_test: @@ -80,42 +81,55 @@ packages: path: ".." relative: true source: path - version: "1.0.1" + version: "2.0.0" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" lints: dependency: transitive description: name: lints - url: "https://pub.dartlang.org" + sha256: a2c3d198cb5ea2e179926622d433331d8b58374ab8f29cdda6e863bd62fd369c + url: "https://pub.dev" source: hosted version: "1.0.1" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" + url: "https://pub.dev" source: hosted - version: "0.12.11" + version: "0.12.15" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + url: "https://pub.dev" source: hosted - version: "0.1.3" + version: "0.2.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + url: "https://pub.dev" source: hosted - version: "1.7.0" + version: "1.9.1" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.8.3" sky_engine: dependency: transitive description: flutter @@ -125,58 +139,58 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + url: "https://pub.dev" source: hosted - version: "1.8.1" + version: "1.9.1" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb + url: "https://pub.dev" source: hosted - version: "0.4.8" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" + version: "0.5.1" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.4" sdks: - dart: ">=2.14.0 <3.0.0" + dart: ">=3.0.0-0 <4.0.0" flutter: ">=1.17.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 19da8fc..8dfbd85 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -3,7 +3,7 @@ description: A new Flutter project. # The following line prevents the package from being accidentally published to # pub.dev using `flutter pub publish`. This is preferred for private packages. -publish_to: 'none' # Remove this line if you wish to publish to pub.dev +publish_to: "none" # Remove this line if you wish to publish to pub.dev # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=2.17.0 <4.0.0" # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions @@ -30,7 +30,6 @@ dependencies: flutter: sdk: flutter - # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 @@ -53,7 +52,6 @@ dev_dependencies: # The following section is specific to Flutter. flutter: - # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. diff --git a/lib/icon_decoration.dart b/lib/icon_decoration.dart index 70dbb53..e61d687 100644 --- a/lib/icon_decoration.dart +++ b/lib/icon_decoration.dart @@ -1,5 +1,5 @@ library icon_decoration; export 'src/decorated_icon.dart'; -export 'src/icon_decoration.dart'; export 'src/icon_border.dart'; +export 'src/icon_decoration.dart'; diff --git a/lib/src/decorated_icon.dart b/lib/src/decorated_icon.dart index d73e256..35f9d70 100644 --- a/lib/src/decorated_icon.dart +++ b/lib/src/decorated_icon.dart @@ -2,15 +2,18 @@ import 'package:flutter/material.dart'; import 'package:icon_decoration/src/gradient_icon.dart'; import 'package:icon_decoration/src/icon_decoration.dart'; -/// Reimplementation of the [Icon] widget which adds support for shadows and -/// borders trough its [decoration] property. +/// Reimplementation of the [Icon] widget which adds support for borders and +/// gradients trough its [decoration] property. class DecoratedIcon extends StatelessWidget { + const DecoratedIcon({ + Key? key, + required this.icon, + this.decoration, + }) : super(key: key); + final Icon icon; final IconDecoration? decoration; - const DecoratedIcon({Key? key, required this.icon, this.decoration}) - : super(key: key); - @override Widget build(BuildContext context) { final iconData = icon.icon!; @@ -20,18 +23,20 @@ class DecoratedIcon extends StatelessWidget { final iconOpacity = iconTheme.opacity ?? 1.0; final border = decoration?.border; final gradient = decoration?.gradient; + final shadows = icon.shadows; + Color iconColor = icon.color ?? iconTheme.color!; if (iconOpacity != 1.0) { iconColor = iconColor.withOpacity(iconColor.opacity * iconOpacity); } - TextStyle iconStyle = TextStyle( + final TextStyle iconStyle = TextStyle( inherit: false, color: iconColor, fontSize: iconSize, fontFamily: iconData.fontFamily, package: iconData.fontPackage, - shadows: decoration?.shadows, + shadows: shadows, ); Widget iconWidget = RichText( @@ -67,7 +72,7 @@ class DecoratedIcon extends StatelessWidget { switch (textDirection) { case TextDirection.rtl: iconWidget = Transform( - transform: Matrix4.identity()..scale(-1.0, 1.0, 1.0), + transform: Matrix4.identity()..scale(-1.0, 1, 1), alignment: Alignment.center, transformHitTests: false, child: iconWidget, @@ -106,7 +111,6 @@ class DecoratedIcon extends StatelessWidget { ..strokeJoin = StrokeJoin.round ..strokeWidth = border.width ..color = border.color, - color: null, ), ), ), diff --git a/lib/src/gradient_icon.dart b/lib/src/gradient_icon.dart index 3d1c6fb..c6975b8 100644 --- a/lib/src/gradient_icon.dart +++ b/lib/src/gradient_icon.dart @@ -2,12 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; class GradientIcon extends StatelessWidget { - final IconData icon; - final double size; - final Gradient gradient; - final TextDirection textDirection; - final TextStyle style; - const GradientIcon({ Key? key, required this.icon, @@ -17,6 +11,12 @@ class GradientIcon extends StatelessWidget { required this.style, }) : super(key: key); + final IconData icon; + final double size; + final Gradient gradient; + final TextDirection textDirection; + final TextStyle style; + @override Widget build(BuildContext context) { final textPainter = TextPainter( @@ -44,17 +44,16 @@ class GradientIcon extends StatelessWidget { } class _GradientIconPainter extends CustomPainter { - final Gradient gradient; - final IconData icon; - final TextStyle style; - final TextPainter textPainter; - _GradientIconPainter({ required this.gradient, required this.icon, required this.style, required this.textPainter, }); + final Gradient gradient; + final IconData icon; + final TextStyle style; + final TextPainter textPainter; @override void paint(Canvas canvas, Size size) { @@ -65,14 +64,15 @@ class _GradientIconPainter extends CustomPainter { debugPaintPadding(canvas, textSpanRect, textSpanRect.deflate(2)); } - textPainter.text = TextSpan( - text: String.fromCharCode(icon.codePoint), - style: style.copyWith( - foreground: Paint()..shader = gradient.createShader(textSpanRect), - ), - ); - textPainter.layout(minWidth: size.width, maxWidth: size.width); - textPainter.paint(canvas, textSpanRect.topLeft); + textPainter + ..text = TextSpan( + text: String.fromCharCode(icon.codePoint), + style: style.copyWith( + foreground: Paint()..shader = gradient.createShader(textSpanRect), + ), + ) + ..layout(minWidth: size.width, maxWidth: size.width) + ..paint(canvas, textSpanRect.topLeft); } @override diff --git a/lib/src/icon_border.dart b/lib/src/icon_border.dart index 3f827a9..629e79e 100644 --- a/lib/src/icon_border.dart +++ b/lib/src/icon_border.dart @@ -1,14 +1,14 @@ import 'package:flutter/material.dart'; class IconBorder { + const IconBorder({ + this.width = 1.0, + this.color = Colors.black, + }) : assert(width >= 0.0); + /// Border's width final double width; /// Border's color final Color color; - - const IconBorder({ - this.width = 1.0, - this.color = Colors.black, - }) : assert(width >= 0.0); } diff --git a/lib/src/icon_decoration.dart b/lib/src/icon_decoration.dart index df8a2fe..10e4404 100644 --- a/lib/src/icon_decoration.dart +++ b/lib/src/icon_decoration.dart @@ -3,16 +3,16 @@ import 'package:icon_decoration/src/icon_border.dart'; /// The [IconDecoration] class provides a variety of ways to draw an icon. /// -/// The icon has a [border] and may cast [shadows]. +/// The icon has a [border] and may cast shadows. /// /// The [border] paints over the icon; the [boxShadow], naturally, paints /// below it. class IconDecoration { - /// A list of [Shadow]s that will be painted underneath the icon. - /// - /// Multiple shadows are supported to replicate lighting from multiple light - /// sources. - final List? shadows; + /// Creates a `DecoratedIcon` decoration. + const IconDecoration({ + this.border, + this.gradient, + }); /// A border to draw above the icon color or [gradient]. final IconBorder? border; @@ -20,11 +20,4 @@ class IconDecoration { /// Apply a gradient to the icon. If this is specified the [Icon.color] /// property has no effect. final Gradient? gradient; - - /// Creates a `DecoratedIcon` decoration. - const IconDecoration({ - this.shadows, - this.border, - this.gradient, - }); } diff --git a/pubspec.lock b/pubspec.lock index 14dce9e..fdfe25b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,117 +5,124 @@ packages: dependency: "direct dev" description: name: alchemist - url: "https://pub.dartlang.org" + sha256: "3888bf8477d560bc18055939dda28105ffdaac638efbce8f2b7975762bf986d0" + url: "https://pub.dev" source: hosted - version: "0.2.1" + version: "0.6.0" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.8.2" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.2.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" + version: "1.3.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.17.1" equatable: dependency: transitive description: name: equatable - url: "https://pub.dartlang.org" + sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2 + url: "https://pub.dev" source: hosted - version: "2.0.3" + version: "2.0.5" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.1" + fd_lints: + dependency: "direct dev" + description: + name: fd_lints + sha256: f3065474f9608dfe289164045a4d700d18994dca721aa911d3702d0f62dc6fe9 + url: "https://pub.dev" + source: hosted + version: "1.1.0" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" - flutter_lints: - dependency: "direct dev" - description: - name: flutter_lints - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.4" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" - lints: + js: dependency: transitive description: - name: lints - url: "https://pub.dartlang.org" + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" source: hosted - version: "1.0.1" + version: "0.6.7" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" + url: "https://pub.dev" source: hosted - version: "0.12.11" + version: "0.12.15" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + url: "https://pub.dev" source: hosted - version: "0.1.3" + version: "0.2.0" meta: dependency: "direct dev" description: name: meta - url: "https://pub.dartlang.org" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + url: "https://pub.dev" source: hosted - version: "1.7.0" + version: "1.9.1" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.8.3" sky_engine: dependency: transitive description: flutter @@ -125,58 +132,58 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + url: "https://pub.dev" source: hosted - version: "1.8.1" + version: "1.9.1" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.8" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" + sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb + url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "0.5.1" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.4" sdks: - dart: ">=2.15.0 <3.0.0" - flutter: ">=2.8.1" + dart: ">=3.0.0-0 <4.0.0" + flutter: ">=3.4.0-34.1.pre" diff --git a/pubspec.yaml b/pubspec.yaml index d5eb888..0917b09 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,12 +1,13 @@ name: icon_decoration description: Add decoration capabilities for the Icon widget with shadows, borders, gradients. -version: 1.0.1 +version: 2.0.0 homepage: https://github.com/TesteurManiak/icon_decoration repository: https://github.com/TesteurManiak/icon_decoration +issue_tracker: https://github.com/TesteurManiak/icon_decoration/issues environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=2.12.0 <4.0.0" flutter: ">=1.17.0" dependencies: @@ -14,11 +15,11 @@ dependencies: sdk: flutter dev_dependencies: - alchemist: ^0.2.1 - flutter_lints: ^1.0.0 + alchemist: ^0.6.0 + fd_lints: ^1.1.0 flutter_test: sdk: flutter - meta: ^1.7.0 + meta: ^1.9.1 flutter: uses-material-design: true diff --git a/test/borders_test.dart b/test/borders_test.dart index 8e8e8bb..78d667d 100644 --- a/test/borders_test.dart +++ b/test/borders_test.dart @@ -8,40 +8,46 @@ void main() { goldenTest( 'Border rendering', fileName: 'border_rendering', - widget: GoldenTestGroup( - children: [ - GoldenTestScenario( - name: 'default', - child: const DecoratedIcon( - icon: Icon(Icons.favorite, color: Colors.transparent, size: 50), - decoration: IconDecoration(border: IconBorder()), + builder: () { + return GoldenTestGroup( + children: [ + GoldenTestScenario( + name: 'default', + child: const DecoratedIcon( + icon: Icon(Icons.favorite, color: Colors.transparent, size: 50), + decoration: IconDecoration(border: IconBorder()), + ), ), - ), - GoldenTestScenario( - name: 'with colorized icon', - child: const DecoratedIcon( - icon: Icon(Icons.favorite, color: Colors.green, size: 50), - decoration: IconDecoration(border: IconBorder()), + GoldenTestScenario( + name: 'with colorized icon', + child: const DecoratedIcon( + icon: Icon(Icons.favorite, color: Colors.green, size: 50), + decoration: IconDecoration(border: IconBorder()), + ), ), - ), - GoldenTestScenario( - name: 'with shadows', - child: const DecoratedIcon( - icon: Icon(Icons.favorite, color: Colors.green, size: 50), - decoration: IconDecoration( - border: IconBorder(), - shadows: [ - Shadow( - color: Colors.red, - blurRadius: 3, - offset: Offset(0, 2), - ) - ], + GoldenTestScenario( + name: 'with shadows', + child: const DecoratedIcon( + icon: Icon( + Icons.favorite, + color: Colors.green, + size: 50, + shadows: [ + Shadow( + color: Colors.red, + blurRadius: 3, + offset: Offset(0, 2), + ) + ], + ), + decoration: IconDecoration( + border: IconBorder(), + ), ), ), - ), - ], - ), + ], + ); + }, ); }); } diff --git a/test/flutter_test_config.dart b/test/flutter_test_config.dart index 064269e..dc6404f 100644 --- a/test/flutter_test_config.dart +++ b/test/flutter_test_config.dart @@ -3,11 +3,12 @@ import 'dart:async'; import 'package:alchemist/alchemist.dart'; Future testExecutable(FutureOr Function() testMain) async { - const isRunningInCi = bool.fromEnvironment('CI', defaultValue: false); + const isRunningInCi = bool.fromEnvironment('CI'); return AlchemistConfig.runWithConfig( config: const AlchemistConfig( platformGoldensConfig: PlatformGoldensConfig( + // ignore: avoid_redundant_argument_values enabled: !isRunningInCi, ), ), diff --git a/test/gradient_test.dart b/test/gradient_test.dart index 43821c1..a820ad6 100644 --- a/test/gradient_test.dart +++ b/test/gradient_test.dart @@ -10,80 +10,88 @@ void main() { goldenTest( 'Gradient rendering', fileName: 'gradient_rendering', - widget: GoldenTestGroup( - children: [ - GoldenTestScenario( - name: 'rainbow gradient', - child: const DecoratedIcon( - icon: Icon(Icons.all_inbox, size: 50), - decoration: IconDecoration( - gradient: rainbowGradient, + builder: () { + return GoldenTestGroup( + children: [ + GoldenTestScenario( + name: 'rainbow gradient', + child: const DecoratedIcon( + icon: Icon(Icons.all_inbox, size: 50), + decoration: IconDecoration( + gradient: RainbowGradient(), + ), ), ), - ), - GoldenTestScenario( - name: 'flutter gradient', - child: DecoratedIcon( - icon: const Icon(Icons.all_inbox, size: 50), - decoration: IconDecoration( - gradient: flutterGradient, + GoldenTestScenario( + name: 'flutter gradient', + child: const DecoratedIcon( + icon: Icon(Icons.all_inbox, size: 50), + decoration: IconDecoration( + gradient: FlutterGradient(), + ), ), ), - ), - GoldenTestScenario( - name: 'fadeOut gradient', - child: DecoratedIcon( - icon: const Icon(Icons.all_inbox, size: 50), - decoration: IconDecoration( - gradient: fadeOut, + GoldenTestScenario( + name: 'fadeOut gradient', + child: const DecoratedIcon( + icon: Icon(Icons.all_inbox, size: 50), + decoration: IconDecoration( + gradient: FadeOutGradient(), + ), ), ), - ), - GoldenTestScenario( - name: 'with red shadows', - child: const DecoratedIcon( - icon: Icon(Icons.all_inbox, size: 50), - decoration: IconDecoration( - gradient: rainbowGradient, - shadows: [ - Shadow( - color: Colors.red, - blurRadius: 3, - offset: Offset(0, 2), - ) - ], + GoldenTestScenario( + name: 'with red shadows', + child: const DecoratedIcon( + icon: Icon( + Icons.all_inbox, + size: 50, + shadows: [ + Shadow( + color: Colors.red, + blurRadius: 3, + offset: Offset(0, 2), + ) + ], + ), + decoration: IconDecoration( + gradient: RainbowGradient(), + ), ), ), - ), - GoldenTestScenario( - name: 'with default border', - child: const DecoratedIcon( - icon: Icon(Icons.all_inbox, size: 50), - decoration: IconDecoration( - gradient: rainbowGradient, - border: IconBorder(), + GoldenTestScenario( + name: 'with default border', + child: const DecoratedIcon( + icon: Icon(Icons.all_inbox, size: 50), + decoration: IconDecoration( + gradient: RainbowGradient(), + border: IconBorder(), + ), ), ), - ), - GoldenTestScenario( - name: 'with border and shadows', - child: const DecoratedIcon( - icon: Icon(Icons.all_inbox, size: 50), - decoration: IconDecoration( - gradient: rainbowGradient, - border: IconBorder(), - shadows: [ - Shadow( - color: Colors.red, - blurRadius: 3, - offset: Offset(0, 2), - ) - ], + GoldenTestScenario( + name: 'with border and shadows', + child: const DecoratedIcon( + icon: Icon( + Icons.all_inbox, + size: 50, + shadows: [ + Shadow( + color: Colors.red, + blurRadius: 3, + offset: Offset(0, 2), + ) + ], + ), + decoration: IconDecoration( + gradient: RainbowGradient(), + border: IconBorder(), + ), ), ), - ), - ], - ), + ], + ); + }, ); }); } diff --git a/test/shadows_test.dart b/test/shadows_test.dart index badfc9a..c7020d2 100644 --- a/test/shadows_test.dart +++ b/test/shadows_test.dart @@ -10,39 +10,49 @@ void main() { goldenTest( 'Shadows rendering', fileName: 'shadows_rendering', - widget: GoldenTestGroup( - children: [ - GoldenTestScenario( - name: 'base', - child: SizedBox(width: 150, child: baseWidget), - ), - GoldenTestScenario( - name: 'default', - child: const DecoratedIcon( - icon: Icon(Icons.home, color: Colors.red, size: 50), - decoration: IconDecoration(shadows: [Shadow(blurRadius: 3)]), + builder: () { + return GoldenTestGroup( + children: [ + GoldenTestScenario( + name: 'base', + child: const SizedBox(width: 150, child: BaseTestWidget()), ), - ), - GoldenTestScenario( - name: 'with Offset(0, 6)', - child: const DecoratedIcon( - icon: Icon(Icons.home, color: Colors.red, size: 50), - decoration: IconDecoration( - shadows: [Shadow(blurRadius: 3, offset: Offset(0, 6))], + GoldenTestScenario( + name: 'default', + child: const DecoratedIcon( + icon: Icon( + Icons.home, + color: Colors.red, + size: 50, + shadows: [Shadow(blurRadius: 3)], + ), ), ), - ), - GoldenTestScenario( - name: 'with Offset(3, 0)', - child: const DecoratedIcon( - icon: Icon(Icons.home, color: Colors.red, size: 50), - decoration: IconDecoration( - shadows: [Shadow(blurRadius: 3, offset: Offset(3, 0))], + GoldenTestScenario( + name: 'with Offset(0, 6)', + child: const DecoratedIcon( + icon: Icon( + Icons.home, + color: Colors.red, + size: 50, + shadows: [Shadow(blurRadius: 3, offset: Offset(0, 6))], + ), ), ), - ), - ], - ), + GoldenTestScenario( + name: 'with Offset(3, 0)', + child: const DecoratedIcon( + icon: Icon( + Icons.home, + color: Colors.red, + size: 50, + shadows: [Shadow(blurRadius: 3, offset: Offset(3, 0))], + ), + ), + ), + ], + ); + }, ); }); } diff --git a/test/test_utils/base_widget.dart b/test/test_utils/base_widget.dart index 1dc2efc..76252f7 100644 --- a/test/test_utils/base_widget.dart +++ b/test/test_utils/base_widget.dart @@ -1,136 +1,134 @@ import 'package:flutter/material.dart'; import 'package:icon_decoration/icon_decoration.dart'; -final baseWidget = DecoratedBox( - decoration: const BoxDecoration(color: Colors.black), - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, +class BaseTestWidget extends StatelessWidget { + const BaseTestWidget({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return DecoratedBox( + decoration: const BoxDecoration(color: Colors.black), + child: Column( children: [ - const DecoratedIcon( - icon: Icon( - Icons.lightbulb_outline, - color: Colors.lightBlueAccent, - size: 36, - ), - decoration: IconDecoration( - shadows: [ - Shadow(blurRadius: 3, color: Colors.lightBlueAccent), - ], - ), - ), - DecoratedIcon( - icon: const Icon( - Icons.lightbulb_outline, - color: Colors.lightBlueAccent, - size: 36, - ), - decoration: IconDecoration( - shadows: [ - Shadow( - blurRadius: 3, - color: Colors.lightBlueAccent.shade100, + const Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + DecoratedIcon( + icon: Icon( + Icons.lightbulb_outline, + color: Colors.lightBlueAccent, + size: 36, + shadows: [ + Shadow(blurRadius: 3, color: Colors.lightBlueAccent), + ], ), - ], - ), - ), - const DecoratedIcon( - icon: Icon( - Icons.lightbulb_outline, - color: Colors.lightBlueAccent, - size: 36, - ), - decoration: IconDecoration( - shadows: [ - Shadow(blurRadius: 2, color: Colors.lightBlueAccent), - ], - ), - ) - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - DecoratedIcon( - icon: Icon( - Icons.home, - color: Colors.green.shade900, - size: 36, - ), - decoration: const IconDecoration( - shadows: [ - Shadow(color: Colors.yellowAccent, blurRadius: 3), - ], - ), - ), - DecoratedIcon( - icon: Icon( - Icons.home, - color: Colors.green.shade900, - size: 36, - ), - decoration: IconDecoration( - shadows: [ - Shadow(color: Colors.green.shade900, blurRadius: 3), - ], - ), + ), + DecoratedIcon( + icon: Icon( + Icons.lightbulb_outline, + color: Colors.lightBlueAccent, + size: 36, + shadows: [ + Shadow( + blurRadius: 3, + color: Color.fromARGB(255, 128, 216, 255), + ), + ], + ), + ), + DecoratedIcon( + icon: Icon( + Icons.lightbulb_outline, + color: Colors.lightBlueAccent, + size: 36, + shadows: [ + Shadow(blurRadius: 2, color: Colors.lightBlueAccent), + ], + ), + ) + ], ), - DecoratedIcon( - icon: Icon( - Icons.home, - color: Colors.green.shade900, - size: 36, - ), - decoration: IconDecoration( - shadows: [ - Shadow(color: Colors.green.shade900, blurRadius: 2), - ], - ), - ) - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - DecoratedIcon( - icon: const Icon( - Icons.access_alarm, - color: Colors.black54, - size: 36, - ), - decoration: IconDecoration( - shadows: [ - Shadow(color: Colors.yellowAccent.shade400, blurRadius: 3), - ], - ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + DecoratedIcon( + icon: Icon( + Icons.home, + color: Colors.green.shade900, + size: 36, + shadows: const [ + Shadow(color: Colors.yellowAccent, blurRadius: 3), + ], + ), + ), + DecoratedIcon( + icon: Icon( + Icons.home, + color: Colors.green.shade900, + size: 36, + shadows: [ + Shadow(color: Colors.green.shade900, blurRadius: 3), + ], + ), + ), + DecoratedIcon( + icon: Icon( + Icons.home, + color: Colors.green.shade900, + size: 36, + shadows: [ + Shadow(color: Colors.green.shade900, blurRadius: 2), + ], + ), + ) + ], ), - DecoratedIcon( - icon: const Icon( - Icons.access_alarm, - color: Colors.black54, - size: 36, - ), - decoration: IconDecoration( - shadows: [ - Shadow(color: Colors.red.shade400, blurRadius: 3), - ], - ), + const Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + DecoratedIcon( + icon: Icon( + Icons.access_alarm, + color: Colors.black54, + size: 36, + shadows: [ + Shadow( + color: Color.fromARGB(255, 255, 234, 0), + blurRadius: 3, + ), + ], + ), + ), + DecoratedIcon( + icon: Icon( + Icons.access_alarm, + color: Colors.black54, + size: 36, + shadows: [ + Shadow( + color: Color.fromARGB(255, 239, 83, 80), + blurRadius: 3, + ), + ], + ), + ), + DecoratedIcon( + icon: Icon( + Icons.access_alarm, + color: Colors.black54, + size: 36, + shadows: [ + Shadow( + color: Color.fromARGB(255, 0, 229, 255), + blurRadius: 3, + ), + ], + ), + ) + ], ), - DecoratedIcon( - icon: const Icon( - Icons.access_alarm, - color: Colors.black54, - size: 36, - ), - decoration: IconDecoration( - shadows: [ - Shadow(color: Colors.cyanAccent.shade400, blurRadius: 3), - ], - ), - ) ], ), - ], - ), -); + ); + } +} diff --git a/test/test_utils/gradients.dart b/test/test_utils/gradients.dart index d2d1fc5..79f0b14 100644 --- a/test/test_utils/gradients.dart +++ b/test/test_utils/gradients.dart @@ -1,39 +1,48 @@ import 'package:flutter/material.dart'; -const rainbowGradient = LinearGradient( - colors: [ - Colors.red, - Colors.pink, - Colors.purple, - Colors.deepPurple, - Colors.deepPurple, - Colors.indigo, - Colors.blue, - Colors.lightBlue, - Colors.cyan, - Colors.teal, - Colors.green, - Colors.lightGreen, - Colors.lime, - Colors.yellow, - Colors.amber, - Colors.orange, - Colors.deepOrange, - ], -); +class RainbowGradient extends LinearGradient { + const RainbowGradient() + : super( + colors: const [ + Colors.red, + Colors.pink, + Colors.purple, + Colors.deepPurple, + Colors.deepPurple, + Colors.indigo, + Colors.blue, + Colors.lightBlue, + Colors.cyan, + Colors.teal, + Colors.green, + Colors.lightGreen, + Colors.lime, + Colors.yellow, + Colors.amber, + Colors.orange, + Colors.deepOrange, + ], + ); +} -final flutterGradient = LinearGradient( - colors: [ - Colors.blue.shade400, - Colors.blue.shade900, - ], -); +class FlutterGradient extends LinearGradient { + const FlutterGradient() + : super( + colors: const [ + Color.fromARGB(255, 66, 165, 245), + Color.fromARGB(255, 13, 71, 161), + ], + ); +} -final fadeOut = LinearGradient( - colors: [ - Colors.white, - Colors.white.withAlpha(0), - ], - begin: Alignment.topLeft, - end: Alignment.bottomRight, -); +class FadeOutGradient extends LinearGradient { + const FadeOutGradient() + : super( + colors: const [ + Colors.white, + Color.fromRGBO(255, 255, 255, 0), + ], + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ); +}