diff --git a/.idea/NewGradientAppBar.iml b/.idea/NewGradientAppBar.iml
index 08d6bda..3328d10 100644
--- a/.idea/NewGradientAppBar.iml
+++ b/.idea/NewGradientAppBar.iml
@@ -28,6 +28,5 @@
-
\ No newline at end of file
diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml
deleted file mode 100644
index a616ed9..0000000
--- a/.idea/libraries/Dart_Packages.xml
+++ /dev/null
@@ -1,188 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml
index f531cdf..32cf88a 100644
--- a/.idea/libraries/Dart_SDK.xml
+++ b/.idea/libraries/Dart_SDK.xml
@@ -1,26 +1,27 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..5c94cb2
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index eef0ee1..916c762 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,23 +1,18 @@
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
@@ -29,26 +24,32 @@
+
+
+
-
-
-
-
-
-
-
-
-
+
+
diff --git a/lib/new_gradient_app_bar.dart b/lib/new_gradient_app_bar.dart
index c6b3e4c..f9b3876 100644
--- a/lib/new_gradient_app_bar.dart
+++ b/lib/new_gradient_app_bar.dart
@@ -8,8 +8,7 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
-const double _kLeadingWidth =
- kToolbarHeight; // So the leading button is square.
+const double _kLeadingWidth = kToolbarHeight; // So the leading button is square.
// Bottom justify the kToolbarHeight child which may overflow the top.
class _ToolbarContainerLayout extends SingleChildLayoutDelegate {
@@ -183,8 +182,7 @@ class NewGradientAppBar extends StatefulWidget implements PreferredSizeWidget {
this.toolbarOpacity = 1.0,
this.bottomOpacity = 1.0,
}) : assert(elevation == null || elevation >= 0.0),
- preferredSize = Size.fromHeight(
- kToolbarHeight + (bottom?.preferredSize.height ?? 0.0)),
+ preferredSize = Size.fromHeight(kToolbarHeight + (bottom?.preferredSize.height ?? 0.0)),
super(key: key);
/// A widget to display before the [title].
@@ -410,35 +408,19 @@ class _NewGradientAppBarState extends State {
final bool hasDrawer = scaffold.hasDrawer;
final bool hasEndDrawer = scaffold.hasEndDrawer;
final bool canPop = parentRoute?.canPop ?? false;
- final bool useCloseButton =
- parentRoute is PageRoute && parentRoute.fullscreenDialog;
-
- IconThemeData overallIconTheme =
- widget.iconTheme ?? appBarTheme.iconTheme ?? themeData.primaryIconTheme;
- IconThemeData actionsIconTheme = widget.actionsIconTheme ??
- appBarTheme.actionsIconTheme ??
- overallIconTheme;
- TextStyle centerStyle = (widget.textTheme?.headline6 ??
- appBarTheme.textTheme?.headline6 ??
- themeData.primaryTextTheme.headline6)!;
- TextStyle? sideStyle = widget.textTheme?.bodyText2 ??
- appBarTheme.textTheme?.bodyText2 ??
- themeData.primaryTextTheme.bodyText2;
+ final bool useCloseButton = parentRoute is PageRoute && parentRoute.fullscreenDialog;
+
+ IconThemeData overallIconTheme = widget.iconTheme ?? appBarTheme.iconTheme ?? themeData.primaryIconTheme;
+ IconThemeData actionsIconTheme = widget.actionsIconTheme ?? appBarTheme.actionsIconTheme ?? overallIconTheme;
+ TextStyle centerStyle = (widget.textTheme?.headline6 ?? appBarTheme.titleTextStyle ?? themeData.primaryTextTheme.headline6)!;
+ TextStyle? sideStyle = widget.textTheme?.bodyText2 ?? appBarTheme.toolbarTextStyle ?? themeData.primaryTextTheme.bodyText2;
if (widget.toolbarOpacity != 1.0) {
- final double opacity =
- const Interval(0.25, 1.0, curve: Curves.fastOutSlowIn)
- .transform(widget.toolbarOpacity);
- if (centerStyle.color != null)
- centerStyle = centerStyle.copyWith(
- color: centerStyle.color!.withOpacity(opacity));
- if (sideStyle?.color != null)
- sideStyle =
- sideStyle!.copyWith(color: sideStyle.color!.withOpacity(opacity));
- overallIconTheme = overallIconTheme.copyWith(
- opacity: opacity * (overallIconTheme.opacity ?? 1.0));
- actionsIconTheme = actionsIconTheme.copyWith(
- opacity: opacity * (actionsIconTheme.opacity ?? 1.0));
+ final double opacity = const Interval(0.25, 1.0, curve: Curves.fastOutSlowIn).transform(widget.toolbarOpacity);
+ if (centerStyle.color != null) centerStyle = centerStyle.copyWith(color: centerStyle.color!.withOpacity(opacity));
+ if (sideStyle?.color != null) sideStyle = sideStyle!.copyWith(color: sideStyle.color!.withOpacity(opacity));
+ overallIconTheme = overallIconTheme.copyWith(opacity: opacity * (overallIconTheme.opacity ?? 1.0));
+ actionsIconTheme = actionsIconTheme.copyWith(opacity: opacity * (actionsIconTheme.opacity ?? 1.0));
}
Widget? leading = widget.leading;
@@ -450,8 +432,7 @@ class _NewGradientAppBarState extends State {
tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip,
);
} else {
- if (canPop)
- leading = useCloseButton ? const CloseButton() : const BackButton();
+ if (canPop) leading = useCloseButton ? const CloseButton() : const BackButton();
}
}
if (leading != null) {
@@ -545,9 +526,7 @@ class _NewGradientAppBarState extends State {
widget.bottomOpacity == 1.0
? widget.bottom!
: Opacity(
- opacity:
- const Interval(0.25, 1.0, curve: Curves.fastOutSlowIn)
- .transform(widget.bottomOpacity),
+ opacity: const Interval(0.25, 1.0, curve: Curves.fastOutSlowIn).transform(widget.bottomOpacity),
child: widget.bottom!,
),
],
@@ -576,21 +555,16 @@ class _NewGradientAppBarState extends State {
],
);
}
- final Brightness brightness = widget.brightness ??
- appBarTheme.brightness ??
- themeData.primaryColorBrightness;
- final SystemUiOverlayStyle overlayStyle = brightness == Brightness.dark
- ? SystemUiOverlayStyle.light
- : SystemUiOverlayStyle.dark;
+ final Brightness brightness = widget.brightness ?? themeData.brightness;
+ final SystemUiOverlayStyle overlayStyle = brightness == Brightness.dark ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark;
return Semantics(
container: true,
child: AnnotatedRegion(
value: overlayStyle,
child: Material(
- color: appBarTheme.color ?? themeData.primaryColor,
- elevation:
- widget.elevation ?? appBarTheme.elevation ?? _defaultElevation,
+ color: appBarTheme.backgroundColor ?? themeData.primaryColor,
+ elevation: widget.elevation ?? appBarTheme.elevation ?? _defaultElevation,
shape: widget.shape,
child: Container(
decoration: BoxDecoration(gradient: widget.gradient),
@@ -621,23 +595,19 @@ class _FloatingGradientAppBarState extends State<_FloatingGradientAppBar> {
@override
void didChangeDependencies() {
super.didChangeDependencies();
- if (_position != null)
- _position!.isScrollingNotifier.removeListener(_isScrollingListener);
+ if (_position != null) _position!.isScrollingNotifier.removeListener(_isScrollingListener);
_position = Scrollable.of(context)?.position;
- if (_position != null)
- _position!.isScrollingNotifier.addListener(_isScrollingListener);
+ if (_position != null) _position!.isScrollingNotifier.addListener(_isScrollingListener);
}
@override
void dispose() {
- if (_position != null)
- _position!.isScrollingNotifier.removeListener(_isScrollingListener);
+ if (_position != null) _position!.isScrollingNotifier.removeListener(_isScrollingListener);
super.dispose();
}
RenderSliverFloatingPersistentHeader? _headerRenderer() {
- return context
- .findAncestorRenderObjectOfType();
+ return context.findAncestorRenderObjectOfType();
}
void _isScrollingListener() {
@@ -679,7 +649,7 @@ class _SliverGradientAppBarDelegate extends SliverPersistentHeaderDelegate {
required this.pinned,
required this.snapConfiguration,
required this.shape,
- }) : assert(primary || topPadding == 0.0),
+ }) : assert(primary || topPadding == 0.0),
_bottomHeight = bottom.preferredSize.height;
final Widget leading;
@@ -717,8 +687,7 @@ class _SliverGradientAppBarDelegate extends SliverPersistentHeaderDelegate {
final FloatingHeaderSnapConfiguration snapConfiguration;
@override
- Widget build(
- BuildContext context, double shrinkOffset, bool overlapsContent) {
+ Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {
final double visibleMainHeight = maxExtent - shrinkOffset - topPadding;
// Truth table for `toolbarOpacity`:
@@ -732,9 +701,7 @@ class _SliverGradientAppBarDelegate extends SliverPersistentHeaderDelegate {
// 1 | 0 | 1 || 1.0
// 1 | 1 | 0 || 1.0
// 1 | 1 | 1 || fade
- final double toolbarOpacity = !pinned || (floating)
- ? ((visibleMainHeight - _bottomHeight) / kToolbarHeight).clamp(0.0, 1.0)
- : 1.0;
+ final double toolbarOpacity = !pinned || (floating) ? ((visibleMainHeight - _bottomHeight) / kToolbarHeight).clamp(0.0, 1.0) : 1.0;
final Widget appBar = FlexibleSpaceBar.createSettings(
minExtent: minExtent,
@@ -747,15 +714,9 @@ class _SliverGradientAppBarDelegate extends SliverPersistentHeaderDelegate {
title: title,
actions: actions,
// ignore: unnecessary_null_comparison
- flexibleSpace: (title == null && flexibleSpace != null)
- ? Semantics(child: flexibleSpace, header: true)
- : flexibleSpace,
+ flexibleSpace: (title == null && flexibleSpace != null) ? Semantics(child: flexibleSpace, header: true) : flexibleSpace,
bottom: bottom,
- elevation: forceElevated ||
- overlapsContent ||
- (pinned && shrinkOffset > maxExtent - minExtent)
- ? elevation
- : 0.0,
+ elevation: forceElevated || overlapsContent || (pinned && shrinkOffset > maxExtent - minExtent) ? elevation : 0.0,
gradient: gradient,
brightness: brightness,
iconTheme: iconTheme,
@@ -766,8 +727,7 @@ class _SliverGradientAppBarDelegate extends SliverPersistentHeaderDelegate {
titleSpacing: titleSpacing,
shape: shape,
toolbarOpacity: toolbarOpacity,
- bottomOpacity:
- pinned ? 1.0 : (visibleMainHeight / _bottomHeight).clamp(0.0, 1.0),
+ bottomOpacity: pinned ? 1.0 : (visibleMainHeight / _bottomHeight).clamp(0.0, 1.0),
),
);
return floating ? _FloatingGradientAppBar(child: appBar) : appBar;
@@ -910,8 +870,7 @@ class SliverNewGradientAppBar extends StatefulWidget {
this.pinned = false,
this.snap = false,
this.shape,
- }) : assert(floating || !snap,
- 'The "snap" argument only makes sense for floating app bars.'),
+ }) : assert(floating || !snap, 'The "snap" argument only makes sense for floating app bars.'),
super(key: key);
/// A widget to display before the [title].
@@ -1154,14 +1113,12 @@ class SliverNewGradientAppBar extends StatefulWidget {
final bool snap;
@override
- _SliverNewGradientAppBarState createState() =>
- _SliverNewGradientAppBarState();
+ _SliverNewGradientAppBarState createState() => _SliverNewGradientAppBarState();
}
// This class is only Stateful because it owns the TickerProvider used
// by the floating appbar snap animation (via FloatingHeaderSnapConfiguration).
-class _SliverNewGradientAppBarState extends State
- with TickerProviderStateMixin {
+class _SliverNewGradientAppBarState extends State with TickerProviderStateMixin {
FloatingHeaderSnapConfiguration? _snapConfiguration;
void _updateSnapConfiguration() {
@@ -1184,18 +1141,14 @@ class _SliverNewGradientAppBarState extends State
@override
void didUpdateWidget(SliverNewGradientAppBar oldWidget) {
super.didUpdateWidget(oldWidget);
- if (widget.snap != oldWidget.snap || widget.floating != oldWidget.floating)
- _updateSnapConfiguration();
+ if (widget.snap != oldWidget.snap || widget.floating != oldWidget.floating) _updateSnapConfiguration();
}
@override
Widget build(BuildContext context) {
assert(!widget.primary || debugCheckHasMediaQuery(context));
- final double topPadding =
- widget.primary ? MediaQuery.of(context).padding.top : 0.0;
- final double collapsedHeight = ((widget.pinned && widget.floating)
- ? widget.bottom!.preferredSize.height + topPadding
- : null)!;
+ final double topPadding = widget.primary ? MediaQuery.of(context).padding.top : 0.0;
+ final double collapsedHeight = ((widget.pinned && widget.floating) ? widget.bottom!.preferredSize.height + topPadding : null)!;
return MediaQuery.removePadding(
context: context,
diff --git a/pubspec.lock b/pubspec.lock
index 49a0ce6..7e0fe89 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -5,51 +5,50 @@ packages:
dependency: transitive
description:
name: async
- url: "https://pub.dartlang.org"
+ sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
+ url: "https://pub.dev"
source: hosted
- version: "2.5.0"
+ 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.1.0"
- charcode:
- dependency: transitive
- description:
- name: charcode
- url: "https://pub.dartlang.org"
- source: hosted
- version: "1.2.0"
+ 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: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
+ url: "https://pub.dev"
source: hosted
- version: "1.15.0"
+ version: "1.18.0"
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
@@ -64,23 +63,34 @@ packages:
dependency: transitive
description:
name: matcher
- url: "https://pub.dartlang.org"
+ sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
+ url: "https://pub.dev"
source: hosted
- version: "0.12.10"
+ version: "0.12.16"
+ material_color_utilities:
+ dependency: transitive
+ description:
+ name: material_color_utilities
+ sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.5.0"
meta:
dependency: transitive
description:
name: meta
- url: "https://pub.dartlang.org"
+ sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
+ url: "https://pub.dev"
source: hosted
- version: "1.3.0"
+ version: "1.10.0"
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
@@ -90,57 +100,65 @@ packages:
dependency: transitive
description:
name: source_span
- url: "https://pub.dartlang.org"
+ sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
+ url: "https://pub.dev"
source: hosted
- version: "1.8.0"
+ version: "1.10.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
- url: "https://pub.dartlang.org"
+ sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
+ url: "https://pub.dev"
source: hosted
- version: "1.10.0"
+ version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
- url: "https://pub.dartlang.org"
+ sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
+ url: "https://pub.dev"
source: hosted
- version: "2.1.0"
+ version: "2.1.2"
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: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
+ url: "https://pub.dev"
source: hosted
- version: "0.2.19"
- typed_data:
+ version: "0.6.1"
+ vector_math:
dependency: transitive
description:
- name: typed_data
- url: "https://pub.dartlang.org"
+ name: vector_math
+ sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
+ url: "https://pub.dev"
source: hosted
- version: "1.3.0"
- vector_math:
+ version: "2.1.4"
+ web:
dependency: transitive
description:
- name: vector_math
- url: "https://pub.dartlang.org"
+ name: web
+ sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
+ url: "https://pub.dev"
source: hosted
- version: "2.1.0"
+ version: "0.3.0"
sdks:
- dart: ">=2.12.0 <3.0.0"
+ dart: ">=3.2.0-194.0.dev <4.0.0"
diff --git a/pubspec.yaml b/pubspec.yaml
index 108cbda..2244c0c 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
name: new_gradient_app_bar
description: The official AppBar, with a more colorful twist. Add gradients to spice up your application and make it beautiful.
-version: 0.2.0
+version: 0.3.0
homepage: https://github.com/GUIKAR741/NewGradientAppBar
dependencies:
diff --git a/test/new_gradient_app_bar_test.dart b/test/new_gradient_app_bar_test.dart
index df73574..7ea7fbd 100644
--- a/test/new_gradient_app_bar_test.dart
+++ b/test/new_gradient_app_bar_test.dart
@@ -1489,7 +1489,7 @@ void main() {
),
));
- expect(darkTheme.primaryColorBrightness, Brightness.dark);
+ expect(darkTheme.brightness, Brightness.dark);
expect(
SystemChrome.latestStyle,
const SystemUiOverlayStyle(
@@ -1509,7 +1509,7 @@ void main() {
),
));
- expect(lightTheme.primaryColorBrightness, Brightness.light);
+ expect(lightTheme.brightness, Brightness.light);
expect(
SystemChrome.latestStyle,
const SystemUiOverlayStyle(
diff --git a/test/semantics_tester.dart b/test/semantics_tester.dart
index 9f5ff30..ce93eac 100644
--- a/test/semantics_tester.dart
+++ b/test/semantics_tester.dart
@@ -553,7 +553,7 @@ class SemanticsTester {
static String _flagsToSemanticsFlagExpression(dynamic flags) {
Iterable list;
if (flags is int) {
- list = SemanticsFlag.values.values
+ list = SemanticsFlag.values
.where((SemanticsFlag flag) => (flag.index & flags) != 0);
} else {
list = flags;
@@ -568,7 +568,7 @@ class SemanticsTester {
static String _actionsToSemanticsActionExpression(dynamic actions) {
Iterable list;
if (actions is int) {
- list = SemanticsAction.values.values
+ list = SemanticsAction.values
.where((SemanticsAction action) => (action.index & actions) != 0);
} else {
list = actions;