From 94452b78fcfcb89925c359746a7c19fcd15d3eb3 Mon Sep 17 00:00:00 2001 From: WieFel <felix.wielander@gmail.com> Date: Thu, 4 Mar 2021 18:42:03 +0100 Subject: [PATCH 01/12] Upgraded dependency --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 299a91b..1541385 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -22,7 +22,7 @@ dev_dependencies: flutter_test: sdk: flutter test: any - pedantic: ^1.8.0 + pedantic: ^1.11.0 # For information on the generic Dart part of this file, see the From d2ecce87e827372398d3bd29a191fd4b992a8eba Mon Sep 17 00:00:00 2001 From: WieFel <felix.wielander@gmail.com> Date: Thu, 4 Mar 2021 19:11:12 +0100 Subject: [PATCH 02/12] Migrated package to null safety --- lib/app_bar.dart | 26 ++++----- lib/button.dart | 2 +- lib/navigation.dart | 16 +++--- lib/scaffold.dart | 129 +++++++++++++++++++++++--------------------- lib/sub_header.dart | 12 ++--- pubspec.yaml | 2 +- 6 files changed, 97 insertions(+), 90 deletions(-) diff --git a/lib/app_bar.dart b/lib/app_bar.dart index c7f071c..6597647 100644 --- a/lib/app_bar.dart +++ b/lib/app_bar.dart @@ -55,7 +55,7 @@ class BackdropAppBar extends StatelessWidget implements PreferredSizeWidget { /// If this is `null` and if [BackdropAppBar.automaticallyImplyLeading] is /// set to `true`, [BackdropAppBar] sets the underlying [AppBar.leading] to /// [BackdropToggleButton]. - final Widget leading; + final Widget? leading; /// See [AppBar.automaticallyImplyLeading]. /// @@ -67,16 +67,16 @@ class BackdropAppBar extends StatelessWidget implements PreferredSizeWidget { final bool automaticallyImplyLeading; /// The widget that should be displayed as the [AppBar] title. - final Widget title; + final Widget? title; /// See [AppBar.actions]. - final List<Widget> actions; + final List<Widget>? actions; /// See [AppBar.flexibleSpace]. - final Widget flexibleSpace; + final Widget? flexibleSpace; /// See [AppBar.bottom]. - final PreferredSizeWidget bottom; + final PreferredSizeWidget? bottom; /// See [AppBar.elevation]. /// @@ -84,28 +84,28 @@ class BackdropAppBar extends StatelessWidget implements PreferredSizeWidget { final double elevation; /// See [AppBar.shape] - final ShapeBorder shape; + final ShapeBorder? shape; /// See [AppBar.backgroundColor]. - final Color backgroundColor; + final Color? backgroundColor; /// See [AppBar.brightness]. - final Brightness brightness; + final Brightness? brightness; /// See [AppBar.iconTheme]. - final IconThemeData iconTheme; + final IconThemeData? iconTheme; /// See [AppBar.actionsIconTheme]. - final IconThemeData actionsIconTheme; + final IconThemeData? actionsIconTheme; /// See [AppBar.textTheme]. - final TextTheme textTheme; + final TextTheme? textTheme; /// See [AppBar.primary]. final bool primary; /// See [AppBar.centerTitle]. - final bool centerTitle; + final bool? centerTitle; /// See [AppBar.excludeHeaderSemantics]. final bool excludeHeaderSemantics; @@ -127,7 +127,7 @@ class BackdropAppBar extends StatelessWidget implements PreferredSizeWidget { /// /// For more information see [AppBar]. BackdropAppBar({ - Key key, + Key? key, this.leading, this.automaticallyImplyLeading = true, this.title, diff --git a/lib/button.dart b/lib/button.dart index d6718f6..f2fdce8 100644 --- a/lib/button.dart +++ b/lib/button.dart @@ -49,7 +49,7 @@ class BackdropToggleButton extends StatelessWidget { icon: AnimatedIcon( icon: icon, color: color, - progress: Backdrop.of(context).animationController.view, + progress: Backdrop.of(context).animationController!.view, ), onPressed: () => Backdrop.of(context).fling(), ); diff --git a/lib/navigation.dart b/lib/navigation.dart index 1ed18dc..60cdebf 100644 --- a/lib/navigation.dart +++ b/lib/navigation.dart @@ -43,33 +43,33 @@ class BackdropNavigationBackLayer extends StatelessWidget { final List<Widget> items; /// Callback that is called whenever a list item is tapped by the user. - final ValueChanged<int> onTap; + final ValueChanged<int>? onTap; /// Customizable separator used with [ListView.separated]. @Deprecated("Replace by use of `separatorBuilder`." "This feature was deprecated after v0.4.2.") - final Widget separator; + final Widget? separator; /// Customizable separatorBuilder used with [ListView.separated]. - final IndexedWidgetBuilder separatorBuilder; + final IndexedWidgetBuilder? separatorBuilder; /// Allows to set a [Padding] for each item of the list. - final EdgeInsetsGeometry itemPadding; + final EdgeInsetsGeometry? itemPadding; /// Sets a custom border on the list items' [InkWell]. /// See [InkResponse.customBorder]. - final ShapeBorder itemSplashBorder; + final ShapeBorder? itemSplashBorder; /// Sets a custom splash color on the list items. See [InkResponse.splashColor]. - final Color itemSplashColor; + final Color? itemSplashColor; /// Creates an instance of [BackdropNavigationBackLayer] to be used with /// [BackdropScaffold]. /// /// The argument [items] is required and must not be `null` and not empty. BackdropNavigationBackLayer({ - Key key, - @required this.items, + Key? key, + required this.items, this.onTap, this.separator, this.separatorBuilder, diff --git a/lib/scaffold.dart b/lib/scaffold.dart index d131c87..3298dcc 100644 --- a/lib/scaffold.dart +++ b/lib/scaffold.dart @@ -19,12 +19,12 @@ class Backdrop extends InheritedWidget { final BackdropScaffoldState data; /// Creates a [Backdrop] instance. - Backdrop({Key key, @required this.data, @required Widget child}) + Backdrop({Key? key, required this.data, required Widget child}) : super(key: key, child: child); /// Provides access to the state from everywhere in the widget tree. static BackdropScaffoldState of(BuildContext context) => - context.dependOnInheritedWidgetOfExactType<Backdrop>().data; + context.dependOnInheritedWidgetOfExactType<Backdrop>()!.data; @override bool updateShouldNotify(Backdrop old) => true; @@ -69,15 +69,15 @@ class BackdropScaffold extends StatefulWidget { /// /// Can be used to customize the behaviour of the backdrop animation. @Deprecated("See animationController. This was deprecated after v0.5.1") - final AnimationController controller; + final AnimationController? controller; /// Can be used to customize the behaviour of the backdrop animation. - final AnimationController animationController; + final AnimationController? animationController; /// Deprecated. Use [BackdropAppBar.title]. /// /// The widget assigned to the [Scaffold]'s [AppBar.title]. - final Widget title; + final Widget? title; /// Content that should be displayed on the back layer. final Widget backLayer; @@ -89,7 +89,7 @@ class BackdropScaffold extends StatefulWidget { /// /// When the front layer is minimized (back layer revealed), the entire [subHeader] will be visible unless /// [headerHeight] is specified. - final Widget subHeader; + final Widget? subHeader; /// If true, the scrim applied to the front layer while minimized (back layer revealed) will not /// cover the [subHeader]. See [frontLayerScrim]. @@ -111,7 +111,7 @@ class BackdropScaffold extends StatefulWidget { /// /// To vary the front layer's height when active (back layer concealed), /// see [frontLayerActiveFactor]. - final double headerHeight; + final double? headerHeight; /// Defines the [BorderRadius] applied to the front layer. /// @@ -157,17 +157,17 @@ class BackdropScaffold extends StatefulWidget { /// The reverse animation curve passed to [Tween.animate]. /// /// If not set, [animationCurve.flipped] is used. - final Curve reverseAnimationCurve; + final Curve? reverseAnimationCurve; /// Background [Color] for the back layer. /// /// Defaults to `Theme.of(context).primaryColor`. - final Color backLayerBackgroundColor; + final Color? backLayerBackgroundColor; /// Background [Color] for the front layer. /// /// If null, the color is handled automatically according to the theme. - final Color frontLayerBackgroundColor; + final Color? frontLayerBackgroundColor; /// Fraction of the available height the front layer will occupy, /// when active (back layer concealed). Clamped to (0, 1). @@ -201,18 +201,18 @@ class BackdropScaffold extends StatefulWidget { final Color backLayerScrim; /// Will be called when [backLayer] has been concealed. - final VoidCallback onBackLayerConcealed; + final VoidCallback? onBackLayerConcealed; /// Will be called when [backLayer] has been revealed. - final VoidCallback onBackLayerRevealed; + final VoidCallback? onBackLayerRevealed; // ------------- PROPERTIES TAKEN OVER FROM SCAFFOLD ------------- // /// A key to use when building the [Scaffold]. - final GlobalKey<ScaffoldState> scaffoldKey; + final GlobalKey<ScaffoldState>? scaffoldKey; /// See [Scaffold.appBar]. - final PreferredSizeWidget appBar; + final PreferredSizeWidget? appBar; /// See [Scaffold.extendBody]. /// @@ -225,39 +225,39 @@ class BackdropScaffold extends StatefulWidget { final bool extendBodyBehindAppBar; /// See [Scaffold.floatingActionButton]. - final Widget floatingActionButton; + final Widget? floatingActionButton; /// See [Scaffold.floatingActionButtonLocation]. - final FloatingActionButtonLocation floatingActionButtonLocation; + final FloatingActionButtonLocation? floatingActionButtonLocation; /// See [Scaffold.floatingActionButtonAnimator]. - final FloatingActionButtonAnimator floatingActionButtonAnimator; + final FloatingActionButtonAnimator? floatingActionButtonAnimator; /// See [Scaffold.persistentFooterButtons]. - final List<Widget> persistentFooterButtons; + final List<Widget>? persistentFooterButtons; /// See [Scaffold.drawer]. - final Widget drawer; + final Widget? drawer; /// See [Scaffold.endDrawer]. - final Widget endDrawer; + final Widget? endDrawer; /// See [Scaffold.drawerScrimColor]. - final Color drawerScrimColor; + final Color? drawerScrimColor; /// See [Scaffold.backgroundColor]. - final Color backgroundColor; + final Color? backgroundColor; /// See [Scaffold.bottomNavigationBar]. - final Widget bottomNavigationBar; + final Widget? bottomNavigationBar; /// See [Scaffold.bottomSheet]. - final Widget bottomSheet; + final Widget? bottomSheet; /// See [Scaffold.resizeToAvoidBottomInset]. /// /// Defaults to `true`. - final bool resizeToAvoidBottomInset; + final bool? resizeToAvoidBottomInset; /// See [Scaffold.primary]. /// @@ -270,7 +270,7 @@ class BackdropScaffold extends StatefulWidget { final DragStartBehavior drawerDragStartBehavior; /// See [Scaffold.drawerEdgeDragWidth]. - final double drawerEdgeDragWidth; + final double? drawerEdgeDragWidth; /// See [Scaffold.drawerEnableOpenDragGesture]. /// @@ -284,15 +284,15 @@ class BackdropScaffold extends StatefulWidget { /// Creates a backdrop scaffold to be used as a material widget. BackdropScaffold({ - Key key, + Key? key, @Deprecated("See animationController. This was deprecated after v0.5.1") this.controller, this.animationController, @Deprecated("Replace by use of BackdropAppBar. See BackdropAppBar.title." "This feature was deprecated after v0.2.17.") this.title, - this.backLayer, - this.frontLayer, + required this.backLayer, + required this.frontLayer, this.subHeader, this.subHeaderAlwaysActive = true, @Deprecated("Replace by use of BackdropAppBar. See BackdropAppBar.actions." @@ -361,12 +361,12 @@ class BackdropScaffold extends StatefulWidget { class BackdropScaffoldState extends State<BackdropScaffold> with SingleTickerProviderStateMixin { bool _shouldDisposeAnimationController = false; - AnimationController _animationController; - ColorTween _backLayerScrimColorTween; + AnimationController? _animationController; + late ColorTween _backLayerScrimColorTween; /// Key for accessing the [ScaffoldState] of [BackdropScaffold]'s internally /// used [Scaffold]. - GlobalKey<ScaffoldState> scaffoldKey; + GlobalKey<ScaffoldState>? scaffoldKey; double _backPanelHeight = 0; double _subHeaderHeight = 0; @@ -375,7 +375,7 @@ class BackdropScaffoldState extends State<BackdropScaffold> /// [AnimationController] used for the backdrop animation. @Deprecated("Replace by the use of `animationController`." "This feature was deprecated after v0.5.1.") - AnimationController get controller => _animationController; + AnimationController? get controller => _animationController; /// [AnimationController] used for the backdrop animation. /// @@ -384,7 +384,7 @@ class BackdropScaffoldState extends State<BackdropScaffold> /// AnimationController( /// vsync: this, duration: Duration(milliseconds: 200), value: 1) /// ``` - AnimationController get animationController => _animationController; + AnimationController? get animationController => _animationController; @override void initState() { @@ -406,7 +406,7 @@ class BackdropScaffoldState extends State<BackdropScaffold> _backLayerScrimColorTween = _buildBackLayerScrimColorTween(); - _animationController.addListener(() => setState(() { + _animationController!.addListener(() => setState(() { // This is intentionally left empty. The state change itself takes // place inside the AnimationController, so there's nothing to update. // All we want is for the widget to rebuild and read the new animation @@ -425,7 +425,7 @@ class BackdropScaffoldState extends State<BackdropScaffold> @override void dispose() { - if (_shouldDisposeAnimationController) _animationController.dispose(); + if (_shouldDisposeAnimationController) _animationController!.dispose(); super.dispose(); } @@ -438,8 +438,8 @@ class BackdropScaffoldState extends State<BackdropScaffold> /// Whether the back layer is concealed or not. bool get isBackLayerConcealed => - animationController.status == AnimationStatus.completed || - animationController.status == AnimationStatus.forward; + animationController!.status == AnimationStatus.completed || + animationController!.status == AnimationStatus.forward; /// Deprecated. Use [isBackLayerRevealed] instead. /// @@ -450,8 +450,8 @@ class BackdropScaffoldState extends State<BackdropScaffold> /// Whether the back layer is revealed or not. bool get isBackLayerRevealed => - animationController.status == AnimationStatus.dismissed || - animationController.status == AnimationStatus.reverse; + animationController!.status == AnimationStatus.dismissed || + animationController!.status == AnimationStatus.reverse; /// Toggles the backdrop functionality. /// @@ -477,7 +477,7 @@ class BackdropScaffoldState extends State<BackdropScaffold> /// Animates the back layer to the "revealed" state. void revealBackLayer() { if (isBackLayerConcealed) { - animationController.animateBack(-1); + animationController!.animateBack(-1); widget.onBackLayerRevealed?.call(); } } @@ -492,14 +492,14 @@ class BackdropScaffoldState extends State<BackdropScaffold> /// Animates the back layer to the "concealed" state. void concealBackLayer() { if (isBackLayerRevealed) { - animationController.animateTo(1); + animationController!.animateTo(1); widget.onBackLayerConcealed?.call(); } } double get _headerHeight { // if defined then use it - if (widget.headerHeight != null) return widget.headerHeight; + if (widget.headerHeight != null) return widget.headerHeight!; // if no subHeader then 32 if (widget.subHeader == null) return 32; @@ -526,7 +526,7 @@ class BackdropScaffoldState extends State<BackdropScaffold> end: RelativeRect.fromLTRB( 0, availableHeight * (1 - widget.frontLayerActiveFactor), 0, 0), ).animate(CurvedAnimation( - parent: animationController, + parent: animationController!, curve: widget.animationCurve, reverseCurve: widget.reverseAnimationCurve ?? widget.animationCurve.flipped)); @@ -534,9 +534,9 @@ class BackdropScaffoldState extends State<BackdropScaffold> Widget _buildInactiveLayer(BuildContext context) { return Offstage( - offstage: animationController.status == AnimationStatus.completed, + offstage: animationController!.status == AnimationStatus.completed, child: FadeTransition( - opacity: Tween<double>(begin: 1, end: 0).animate(animationController), + opacity: Tween<double>(begin: 1, end: 0).animate(animationController!), child: GestureDetector( onTap: () => fling(), behavior: HitTestBehavior.opaque, @@ -571,8 +571,11 @@ class BackdropScaffoldState extends State<BackdropScaffold> children: <Widget>[ Flexible( child: _MeasureSize( - onChange: (size) => - setState(() => _backPanelHeight = size.height), + onChange: (size) { + if (size != null) { + setState(() => _backPanelHeight = size.height); + } + }, child: widget.backLayer ?? Container(), ), ), @@ -600,10 +603,13 @@ class BackdropScaffoldState extends State<BackdropScaffold> children: <Widget>[ // subHeader _MeasureSize( - onChange: (size) => - setState(() => _subHeaderHeight = size.height), + onChange: (size) { + if (size != null) { + setState(() => _subHeaderHeight = size.height); + } + }, child: DefaultTextStyle( - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.subtitle1!, child: widget.subHeader ?? Container(), ), ), @@ -618,7 +624,7 @@ class BackdropScaffoldState extends State<BackdropScaffold> ); } - Future<bool> _willPopCallback(BuildContext context) async { + Future<bool?> _willPopCallback(BuildContext context) async { if (isBackLayerRevealed) { concealBackLayer(); return null; @@ -633,7 +639,8 @@ class BackdropScaffoldState extends State<BackdropScaffold> Widget _buildBody(BuildContext context) { return WillPopScope( - onWillPop: () => _willPopCallback(context), + onWillPop: (() => _willPopCallback(context) as Future<bool>) + as Future<bool> Function()?, child: Scaffold( key: scaffoldKey, appBar: widget.appBar ?? @@ -686,7 +693,7 @@ class BackdropScaffoldState extends State<BackdropScaffold> } Container _buildBackLayerScrim() => Container( - color: _backLayerScrimColorTween.evaluate(animationController), + color: _backLayerScrimColorTween.evaluate(animationController!), height: _backPanelHeight); bool get _hasBackLayerScrim => @@ -707,12 +714,12 @@ class BackdropScaffoldState extends State<BackdropScaffold> /// Credit: https://stackoverflow.com/a/60868972/2554745 class _MeasureSize extends StatefulWidget { final Widget child; - final ValueChanged<Size> onChange; + final ValueChanged<Size?> onChange; const _MeasureSize({ - Key key, - @required this.onChange, - @required this.child, + Key? key, + required this.onChange, + required this.child, }) : super(key: key); @override @@ -721,7 +728,7 @@ class _MeasureSize extends StatefulWidget { class _MeasureSizeState extends State<_MeasureSize> { final widgetKey = GlobalKey(); - Size oldSize; + Size? oldSize; void _notify() { final context = widgetKey.currentContext; @@ -736,10 +743,10 @@ class _MeasureSizeState extends State<_MeasureSize> { @override Widget build(BuildContext context) { - SchedulerBinding.instance.addPostFrameCallback((_) => _notify()); + SchedulerBinding.instance!.addPostFrameCallback((_) => _notify()); return NotificationListener<SizeChangedLayoutNotification>( onNotification: (_) { - SchedulerBinding.instance.addPostFrameCallback((_) => _notify()); + SchedulerBinding.instance!.addPostFrameCallback((_) => _notify()); return true; }, child: SizeChangedLayoutNotifier( diff --git a/lib/sub_header.dart b/lib/sub_header.dart index cb35754..d2852c2 100644 --- a/lib/sub_header.dart +++ b/lib/sub_header.dart @@ -24,7 +24,7 @@ class BackdropSubHeader extends StatelessWidget { /// The divider that should be shown at the bottom of the sub-header. /// /// Defaults to `Divider(height: 4.0, indent: 16.0, endIndent: 16.0)`. - final Widget divider; + final Widget? divider; /// Padding that will be applied to the sub-header. /// @@ -51,18 +51,18 @@ class BackdropSubHeader extends StatelessWidget { /// Widget to be shown as leading element to the sub-header. If set, the value /// of [automaticallyImplyLeading] is ignored. - final Widget leading; + final Widget? leading; /// Widget to be shown as trailing element to the sub-header. If set, the value /// of [automaticallyImplyTrailing] is ignored. - final Widget trailing; + final Widget? trailing; /// Creates a [BackdropSubHeader] instance. /// /// The [title] argument must not be `null`. const BackdropSubHeader({ - Key key, - @required this.title, + Key? key, + required this.title, this.divider, this.padding = const EdgeInsets.symmetric(vertical: 12.0, horizontal: 16.0), this.automaticallyImplyLeading = false, @@ -77,7 +77,7 @@ class BackdropSubHeader extends StatelessWidget { Widget _buildAutomaticLeadingOrTrailing(BuildContext context) => FadeTransition( opacity: Tween(begin: 1.0, end: 0.0) - .animate(Backdrop.of(context).animationController), + .animate(Backdrop.of(context).animationController!), child: Icon(Icons.keyboard_arrow_up), ); diff --git a/pubspec.yaml b/pubspec.yaml index 1541385..2b95837 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,7 +12,7 @@ authors: - Felix Wortmann <https://github.com/felixwortmann> environment: - sdk: ">=2.3.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: From bf9e446643674a08c79ea5aba976f3b1ce11f76c Mon Sep 17 00:00:00 2001 From: WieFel <felix.wielander@gmail.com> Date: Thu, 4 Mar 2021 19:11:27 +0100 Subject: [PATCH 03/12] Adapted backdrop_test.dart to comply with null safe code --- test/backdrop_test.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/backdrop_test.dart b/test/backdrop_test.dart index 59b749e..fef7cff 100644 --- a/test/backdrop_test.dart +++ b/test/backdrop_test.dart @@ -1,8 +1,12 @@ import 'package:backdrop/backdrop.dart'; +import 'package:flutter/material.dart'; import 'package:test/test.dart'; void main() { test('write tests here', () { - BackdropScaffold(); + BackdropScaffold( + frontLayer: Container(), + backLayer: Container(), + ); }); } From 94fc67751f5c0e6ca36c306dc34cee029c7beb48 Mon Sep 17 00:00:00 2001 From: proninyaroslav <proninyaroslav@gmail.com> Date: Mon, 8 Mar 2021 20:44:46 +0300 Subject: [PATCH 04/12] Make animationController non-nullable; fix warnings --- analysis_options.yaml | 2 +- lib/app_bar.dart | 2 +- lib/button.dart | 2 +- lib/scaffold.dart | 75 ++++++++++++++++++++++++++----------------- lib/sub_header.dart | 2 +- 5 files changed, 50 insertions(+), 33 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index c3d94c8..6715b49 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:pedantic/analysis_options.1.8.0.yaml +include: package:pedantic/analysis_options.yaml analyzer: exclude: [build/**] diff --git a/lib/app_bar.dart b/lib/app_bar.dart index 6597647..0a15a5f 100644 --- a/lib/app_bar.dart +++ b/lib/app_bar.dart @@ -154,7 +154,7 @@ class BackdropAppBar extends StatelessWidget implements PreferredSizeWidget { assert(toolbarOpacity != null), assert(bottomOpacity != null), preferredSize = Size.fromHeight( - kToolbarHeight + (bottom?.preferredSize?.height ?? 0.0)), + kToolbarHeight + (bottom?.preferredSize.height ?? 0.0)), super(key: key); @override diff --git a/lib/button.dart b/lib/button.dart index f2fdce8..d6718f6 100644 --- a/lib/button.dart +++ b/lib/button.dart @@ -49,7 +49,7 @@ class BackdropToggleButton extends StatelessWidget { icon: AnimatedIcon( icon: icon, color: color, - progress: Backdrop.of(context).animationController!.view, + progress: Backdrop.of(context).animationController.view, ), onPressed: () => Backdrop.of(context).fling(), ); diff --git a/lib/scaffold.dart b/lib/scaffold.dart index 3298dcc..8dcc127 100644 --- a/lib/scaffold.dart +++ b/lib/scaffold.dart @@ -4,6 +4,10 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; +@Deprecated('Replace with frontLayerScrim.') +const _kInactiveOverlayOpacity = 0.7; +const _kInactiveOverlayColor = Color(0xFFEEEEEE); + /// This class is an InheritedWidget that exposes state of [BackdropScaffold] /// [BackdropScaffoldState] to be accessed from anywhere below the widget tree. /// @@ -181,12 +185,12 @@ class BackdropScaffold extends StatefulWidget { /// Deprecated. Use [frontLayerScrim] instead. @Deprecated('Replace with frontLayerScrim.') - final Color inactiveOverlayColor; + final Color? inactiveOverlayColor; /// Deprecated. Use [frontLayerScrim] instead. @Deprecated('Replace with frontLayerScrim. Use Color#withOpacity, or pass' 'the opacity value in the Color constructor.') - final double inactiveOverlayOpacity; + final double? inactiveOverlayOpacity; /// Defines the scrim color for the front layer when minimized /// (revealing the back layer) and animating. Defaults to [Colors.white70]. @@ -315,9 +319,9 @@ class BackdropScaffold extends StatefulWidget { double frontLayerActiveFactor = 1, this.backLayerBackgroundColor, @Deprecated('See frontLayerScrim. This was deprecated after v0.4.7.') - this.inactiveOverlayColor = const Color(0xFFEEEEEE), + this.inactiveOverlayColor, @Deprecated('See frontLayerScrim. This was deprecated after v0.4.7.') - this.inactiveOverlayOpacity = 0.7, + this.inactiveOverlayOpacity, this.frontLayerScrim = Colors.white70, this.backLayerScrim = Colors.black54, this.onBackLayerConcealed, @@ -342,7 +346,8 @@ class BackdropScaffold extends StatefulWidget { this.drawerEdgeDragWidth, this.drawerEnableOpenDragGesture = true, this.endDrawerEnableOpenDragGesture = true, - }) : assert(inactiveOverlayOpacity >= 0.0 && inactiveOverlayOpacity <= 1.0), + }) : assert(inactiveOverlayOpacity == null || + inactiveOverlayOpacity >= 0.0 && inactiveOverlayOpacity <= 1.0), frontLayerActiveFactor = frontLayerActiveFactor.clamp(0, 1).toDouble(), super(key: key); @@ -361,7 +366,7 @@ class BackdropScaffold extends StatefulWidget { class BackdropScaffoldState extends State<BackdropScaffold> with SingleTickerProviderStateMixin { bool _shouldDisposeAnimationController = false; - AnimationController? _animationController; + late AnimationController _animationController; late ColorTween _backLayerScrimColorTween; /// Key for accessing the [ScaffoldState] of [BackdropScaffold]'s internally @@ -375,7 +380,7 @@ class BackdropScaffoldState extends State<BackdropScaffold> /// [AnimationController] used for the backdrop animation. @Deprecated("Replace by the use of `animationController`." "This feature was deprecated after v0.5.1.") - AnimationController? get controller => _animationController; + AnimationController get controller => _animationController; /// [AnimationController] used for the backdrop animation. /// @@ -384,7 +389,7 @@ class BackdropScaffoldState extends State<BackdropScaffold> /// AnimationController( /// vsync: this, duration: Duration(milliseconds: 200), value: 1) /// ``` - AnimationController? get animationController => _animationController; + AnimationController get animationController => _animationController; @override void initState() { @@ -406,7 +411,7 @@ class BackdropScaffoldState extends State<BackdropScaffold> _backLayerScrimColorTween = _buildBackLayerScrimColorTween(); - _animationController!.addListener(() => setState(() { + _animationController.addListener(() => setState(() { // This is intentionally left empty. The state change itself takes // place inside the AnimationController, so there's nothing to update. // All we want is for the widget to rebuild and read the new animation @@ -425,7 +430,7 @@ class BackdropScaffoldState extends State<BackdropScaffold> @override void dispose() { - if (_shouldDisposeAnimationController) _animationController!.dispose(); + if (_shouldDisposeAnimationController) _animationController.dispose(); super.dispose(); } @@ -438,8 +443,8 @@ class BackdropScaffoldState extends State<BackdropScaffold> /// Whether the back layer is concealed or not. bool get isBackLayerConcealed => - animationController!.status == AnimationStatus.completed || - animationController!.status == AnimationStatus.forward; + animationController.status == AnimationStatus.completed || + animationController.status == AnimationStatus.forward; /// Deprecated. Use [isBackLayerRevealed] instead. /// @@ -450,8 +455,8 @@ class BackdropScaffoldState extends State<BackdropScaffold> /// Whether the back layer is revealed or not. bool get isBackLayerRevealed => - animationController!.status == AnimationStatus.dismissed || - animationController!.status == AnimationStatus.reverse; + animationController.status == AnimationStatus.dismissed || + animationController.status == AnimationStatus.reverse; /// Toggles the backdrop functionality. /// @@ -459,7 +464,7 @@ class BackdropScaffoldState extends State<BackdropScaffold> /// by this function. If it was revealed, this function will animate it to /// the "concealed" state. void fling() { - FocusScope.of(context)?.unfocus(); + FocusScope.of(context).unfocus(); if (isBackLayerConcealed) { revealBackLayer(); } else { @@ -477,7 +482,7 @@ class BackdropScaffoldState extends State<BackdropScaffold> /// Animates the back layer to the "revealed" state. void revealBackLayer() { if (isBackLayerConcealed) { - animationController!.animateBack(-1); + animationController.animateBack(-1); widget.onBackLayerRevealed?.call(); } } @@ -492,7 +497,7 @@ class BackdropScaffoldState extends State<BackdropScaffold> /// Animates the back layer to the "concealed" state. void concealBackLayer() { if (isBackLayerRevealed) { - animationController!.animateTo(1); + animationController.animateTo(1); widget.onBackLayerConcealed?.call(); } } @@ -526,17 +531,31 @@ class BackdropScaffoldState extends State<BackdropScaffold> end: RelativeRect.fromLTRB( 0, availableHeight * (1 - widget.frontLayerActiveFactor), 0, 0), ).animate(CurvedAnimation( - parent: animationController!, + parent: animationController, curve: widget.animationCurve, reverseCurve: widget.reverseAnimationCurve ?? widget.animationCurve.flipped)); } Widget _buildInactiveLayer(BuildContext context) { + Color? frontLayerScrim; + if (widget.inactiveOverlayColor == null && + widget.inactiveOverlayOpacity == null) { + frontLayerScrim = widget.frontLayerScrim; + } else if (widget.inactiveOverlayOpacity == null) { + frontLayerScrim = widget.inactiveOverlayColor!.withOpacity( + _kInactiveOverlayOpacity, + ); + } else if (widget.inactiveOverlayColor == null) { + frontLayerScrim = _kInactiveOverlayColor.withOpacity( + widget.inactiveOverlayOpacity!, + ); + } + return Offstage( - offstage: animationController!.status == AnimationStatus.completed, + offstage: animationController.status == AnimationStatus.completed, child: FadeTransition( - opacity: Tween<double>(begin: 1, end: 0).animate(animationController!), + opacity: Tween<double>(begin: 1, end: 0).animate(animationController), child: GestureDetector( onTap: () => fling(), behavior: HitTestBehavior.opaque, @@ -548,9 +567,8 @@ class BackdropScaffoldState extends State<BackdropScaffold> : Container(), Expanded( child: Container( - color: widget.frontLayerScrim ?? - widget.inactiveOverlayColor - .withOpacity(widget.inactiveOverlayOpacity)), + color: frontLayerScrim, + ), ), ], ), @@ -576,7 +594,7 @@ class BackdropScaffoldState extends State<BackdropScaffold> setState(() => _backPanelHeight = size.height); } }, - child: widget.backLayer ?? Container(), + child: widget.backLayer, ), ), ], @@ -624,10 +642,10 @@ class BackdropScaffoldState extends State<BackdropScaffold> ); } - Future<bool?> _willPopCallback(BuildContext context) async { + Future<bool> _willPopCallback(BuildContext context) async { if (isBackLayerRevealed) { concealBackLayer(); - return null; + return false; } return true; } @@ -639,8 +657,7 @@ class BackdropScaffoldState extends State<BackdropScaffold> Widget _buildBody(BuildContext context) { return WillPopScope( - onWillPop: (() => _willPopCallback(context) as Future<bool>) - as Future<bool> Function()?, + onWillPop: (() => _willPopCallback(context)), child: Scaffold( key: scaffoldKey, appBar: widget.appBar ?? @@ -693,7 +710,7 @@ class BackdropScaffoldState extends State<BackdropScaffold> } Container _buildBackLayerScrim() => Container( - color: _backLayerScrimColorTween.evaluate(animationController!), + color: _backLayerScrimColorTween.evaluate(animationController), height: _backPanelHeight); bool get _hasBackLayerScrim => diff --git a/lib/sub_header.dart b/lib/sub_header.dart index d2852c2..9a521e7 100644 --- a/lib/sub_header.dart +++ b/lib/sub_header.dart @@ -77,7 +77,7 @@ class BackdropSubHeader extends StatelessWidget { Widget _buildAutomaticLeadingOrTrailing(BuildContext context) => FadeTransition( opacity: Tween(begin: 1.0, end: 0.0) - .animate(Backdrop.of(context).animationController!), + .animate(Backdrop.of(context).animationController), child: Icon(Icons.keyboard_arrow_up), ); From beb79ad1ac8fccd1f1a35806be401367603c5daf Mon Sep 17 00:00:00 2001 From: Yaroslav Pronin <proninyaroslav@gmail.com> Date: Mon, 8 Mar 2021 20:53:28 +0300 Subject: [PATCH 05/12] Add Deprecated annotation --- lib/scaffold.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/scaffold.dart b/lib/scaffold.dart index 8dcc127..008b09a 100644 --- a/lib/scaffold.dart +++ b/lib/scaffold.dart @@ -6,6 +6,7 @@ import 'package:flutter/scheduler.dart'; @Deprecated('Replace with frontLayerScrim.') const _kInactiveOverlayOpacity = 0.7; +@Deprecated('Replace with frontLayerScrim.') const _kInactiveOverlayColor = Color(0xFFEEEEEE); /// This class is an InheritedWidget that exposes state of [BackdropScaffold] From 0c43ed9e58a998b207b7e691c994ceecd144926c Mon Sep 17 00:00:00 2001 From: Felix <felix.wielander@gmail.com> Date: Mon, 8 Mar 2021 21:42:13 +0100 Subject: [PATCH 06/12] Migrated example/ --- example/pubspec.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/example/pubspec.yaml b/example/pubspec.yaml index ce84bdf..6539278 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -2,15 +2,12 @@ name: example description: A new Flutter project. environment: - sdk: '>=2.10.0 <3.0.0' + sdk: '>=2.12.0 <3.0.0' 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: ^0.1.2 # Add backdrop dependency here backdrop: path: "../" From 7b4e123e217f12c060a56a4848acdc398f5b2052 Mon Sep 17 00:00:00 2001 From: Felix <felix.wielander@gmail.com> Date: Mon, 8 Mar 2021 21:46:12 +0100 Subject: [PATCH 07/12] Refactored demo/ --- demo/lib/data/theme_data.dart | 100 ---------------------------------- demo/lib/main.dart | 4 +- demo/pubspec.yaml | 9 +-- 3 files changed, 4 insertions(+), 109 deletions(-) delete mode 100644 demo/lib/data/theme_data.dart diff --git a/demo/lib/data/theme_data.dart b/demo/lib/data/theme_data.dart deleted file mode 100644 index f76393f..0000000 --- a/demo/lib/data/theme_data.dart +++ /dev/null @@ -1,100 +0,0 @@ -// Taken from flutter gallery app -// -// Copyright 2019 The Flutter team. All rights reserved. -// 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:google_fonts/google_fonts.dart'; - -class GalleryThemeData { - static const _lightFillColor = Colors.black; - static const _darkFillColor = Colors.white; - - static final Color _lightFocusColor = Colors.black.withOpacity(0.12); - static final Color _darkFocusColor = Colors.white.withOpacity(0.12); - - static ThemeData lightThemeData = - themeData(lightColorScheme, _lightFocusColor); - static ThemeData darkThemeData = themeData(darkColorScheme, _darkFocusColor); - - static ThemeData themeData(ColorScheme colorScheme, Color focusColor) { - return ThemeData( - colorScheme: colorScheme, - textTheme: _textTheme, - // Matches manifest.json colors and background color. - primaryColor: const Color(0xFF030303), - appBarTheme: AppBarTheme( - textTheme: _textTheme.apply(bodyColor: colorScheme.onPrimary), - color: colorScheme.background, - elevation: 0, - iconTheme: IconThemeData(color: colorScheme.primary), - brightness: colorScheme.brightness, - ), - iconTheme: IconThemeData(color: colorScheme.onPrimary), - canvasColor: colorScheme.background, - scaffoldBackgroundColor: colorScheme.background, - highlightColor: Colors.transparent, - accentColor: colorScheme.primary, - focusColor: focusColor, - snackBarTheme: SnackBarThemeData( - behavior: SnackBarBehavior.floating, - backgroundColor: Color.alphaBlend( - _lightFillColor.withOpacity(0.80), - _darkFillColor, - ), - contentTextStyle: _textTheme.subtitle1.apply(color: _darkFillColor), - ), - ); - } - - static const ColorScheme lightColorScheme = ColorScheme( - primary: Color(0xFFB93C5D), - primaryVariant: Color(0xFF117378), - secondary: Color(0xFFEFF3F3), - secondaryVariant: Color(0xFFFAFBFB), - background: Color(0xFFE6EBEB), - surface: Color(0xFFFAFBFB), - onBackground: Colors.white, - error: _lightFillColor, - onError: _lightFillColor, - onPrimary: _lightFillColor, - onSecondary: Color(0xFF322942), - onSurface: Color(0xFF241E30), - brightness: Brightness.light, - ); - - static const ColorScheme darkColorScheme = ColorScheme( - primary: Color(0xFFFF8383), - primaryVariant: Color(0xFF1CDEC9), - secondary: Color(0xFF4D1F7C), - secondaryVariant: Color(0xFF451B6F), - background: Color(0xFF241E30), - surface: Color(0xFF1F1929), - onBackground: Color(0x0DFFFFFF), // White with 0.05 opacity - error: _darkFillColor, - onError: _darkFillColor, - onPrimary: _darkFillColor, - onSecondary: _darkFillColor, - onSurface: _darkFillColor, - brightness: Brightness.dark, - ); - - static const _regular = FontWeight.w400; - static const _medium = FontWeight.w500; - static const _semiBold = FontWeight.w600; - static const _bold = FontWeight.w700; - - static final TextTheme _textTheme = TextTheme( - headline4: GoogleFonts.montserrat(fontWeight: _bold, fontSize: 20.0), - caption: GoogleFonts.oswald(fontWeight: _semiBold, fontSize: 16.0), - headline5: GoogleFonts.oswald(fontWeight: _medium, fontSize: 16.0), - subtitle1: GoogleFonts.montserrat(fontWeight: _medium, fontSize: 16.0), - overline: GoogleFonts.montserrat(fontWeight: _medium, fontSize: 12.0), - bodyText1: GoogleFonts.montserrat(fontWeight: _regular, fontSize: 14.0), - subtitle2: GoogleFonts.montserrat(fontWeight: _medium, fontSize: 14.0), - bodyText2: GoogleFonts.montserrat(fontWeight: _regular, fontSize: 16.0), - headline6: GoogleFonts.montserrat(fontWeight: _bold, fontSize: 16.0), - button: GoogleFonts.montserrat(fontWeight: _semiBold, fontSize: 14.0), - ); -} diff --git a/demo/lib/main.dart b/demo/lib/main.dart index 59158dd..dee23a6 100644 --- a/demo/lib/main.dart +++ b/demo/lib/main.dart @@ -1,4 +1,3 @@ -import 'package:demo/data/theme_data.dart'; import 'package:demo/data/use_case.dart'; import 'package:demo/use_cases/contextual_controls/contextual_controls_use_case.dart'; import 'package:demo/use_cases/contextual_info/contextual_info_use_case.dart'; @@ -6,6 +5,7 @@ import 'package:demo/use_cases/filter/filter_use_case.dart'; import 'package:demo/use_cases/navigation/navigation_use_case.dart'; import 'package:flutter/material.dart'; import 'package:gallerize/gallerize.dart'; +import 'package:gallerize/themes/gallerize_theme_data.dart'; void main() => runApp(DemoApp()); @@ -15,7 +15,7 @@ class DemoApp extends StatelessWidget { Widget build(BuildContext context) { return MaterialApp( title: "Backdrop Gallery", - theme: GalleryThemeData.darkThemeData, + theme: GallerizeThemeData.darkThemeData, home: HomePage(), ); } diff --git a/demo/pubspec.yaml b/demo/pubspec.yaml index ba0b8f2..c262782 100644 --- a/demo/pubspec.yaml +++ b/demo/pubspec.yaml @@ -24,12 +24,7 @@ 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: ^0.1.3 - google_fonts: ^1.1.0 - flutter_highlight: ^0.6.0 - gallerize: ^0.0.4 + gallerize: ^0.1.0 # Add backdrop dependency here backdrop: path: "../" @@ -37,7 +32,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_launcher_icons: "^0.7.3" + flutter_launcher_icons: ^0.9.0 flutter_icons: android: false From 7aaacdfc7a1e6fb88d3b4dbfe4c49484b0fe8cee Mon Sep 17 00:00:00 2001 From: Felix <felix.wielander@gmail.com> Date: Mon, 8 Mar 2021 21:49:34 +0100 Subject: [PATCH 08/12] Migrated demo/ --- demo/lib/data/use_case.dart | 8 ++++---- .../contextual_controls/contextual_controls.dart | 12 ++++++------ .../use_cases/contextual_info/contextual_info.dart | 4 ++-- demo/lib/use_cases/filter/filter.dart | 6 +++--- demo/pubspec.yaml | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/demo/lib/data/use_case.dart b/demo/lib/data/use_case.dart index c6c60fd..a953722 100644 --- a/demo/lib/data/use_case.dart +++ b/demo/lib/data/use_case.dart @@ -3,14 +3,14 @@ import 'package:flutter/material.dart'; /// Abstract class for defining a use case that is presented within the demo app. abstract class UseCase { /// The name of the use case. - String name; + late String name; /// Description of the use case. - String description; + late String description; /// Path to the file containing the sample code of the use case. - String codeFile; + String? codeFile; /// The `Widget` representing a preview of the given use case. - Widget preview; + Widget? preview; } diff --git a/demo/lib/use_cases/contextual_controls/contextual_controls.dart b/demo/lib/use_cases/contextual_controls/contextual_controls.dart index f4bec5f..ebc2f87 100644 --- a/demo/lib/use_cases/contextual_controls/contextual_controls.dart +++ b/demo/lib/use_cases/contextual_controls/contextual_controls.dart @@ -53,12 +53,12 @@ class _ContextualControlsState extends State<ContextualControls> { items: _COLOR_MAP.keys.map<DropdownMenuItem<Color>>((Color c) { return DropdownMenuItem<Color>( value: c, - child: Text(_COLOR_MAP[c]), + child: Text(_COLOR_MAP[c]!), ); }).toList(), - onChanged: (Color newValue) { + onChanged: (Color? newValue) { setState(() { - _color = newValue; + _color = newValue!; }); }, ), @@ -99,9 +99,9 @@ class _ContextualControlsState extends State<ContextualControls> { child: Text("${r.toString()} GB"), ); }).toList(), - onChanged: (int newValue) { + onChanged: (int? newValue) { setState(() { - _ram = newValue; + _ram = newValue!; }); }, ), @@ -132,7 +132,7 @@ class _ContextualControlsState extends State<ContextualControls> { "Laptop", style: Theme.of(context) .textTheme - .headline3 + .headline3! .apply(color: Colors.black), ), ], diff --git a/demo/lib/use_cases/contextual_info/contextual_info.dart b/demo/lib/use_cases/contextual_info/contextual_info.dart index 339e391..dc48a5c 100644 --- a/demo/lib/use_cases/contextual_info/contextual_info.dart +++ b/demo/lib/use_cases/contextual_info/contextual_info.dart @@ -93,7 +93,7 @@ class ContextualInfo extends StatelessWidget { "Laptop", style: Theme.of(context) .textTheme - .headline3 + .headline3! .apply(color: Colors.black), ), ], @@ -156,7 +156,7 @@ class ContextualInfo extends StatelessWidget { title: Text("Reviews", style: Theme.of(context) .textTheme - .headline6 + .headline6! .apply(color: Colors.black)), ), ListTile( diff --git a/demo/lib/use_cases/filter/filter.dart b/demo/lib/use_cases/filter/filter.dart index 053f988..974b418 100644 --- a/demo/lib/use_cases/filter/filter.dart +++ b/demo/lib/use_cases/filter/filter.dart @@ -23,7 +23,7 @@ class _FilterState extends State<Filter> { ]; Set<ItemCategory> _filteredCategories = Set.from([ItemCategory.Electronics, ItemCategory.Transportation]); - List<Item> _shownItems; + late List<Item> _shownItems; @override void initState() { @@ -70,8 +70,8 @@ class _FilterState extends State<Filter> { ListView.builder( itemCount: _CATEGORIES.length, itemBuilder: (context, index) => CheckboxListTile( - onChanged: (bool checked) => - _addOrRemoveFilterCategory(checked, _CATEGORIES[index]), + onChanged: (bool? checked) => + _addOrRemoveFilterCategory(checked!, _CATEGORIES[index]), value: _filteredCategories.contains(_CATEGORIES[index]), title: Text(describeEnum(_CATEGORIES[index].toString())), activeColor: Colors.white, diff --git a/demo/pubspec.yaml b/demo/pubspec.yaml index c262782..5c9a8a2 100644 --- a/demo/pubspec.yaml +++ b/demo/pubspec.yaml @@ -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.7.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: From 2f4010e5619ad2089290835c3e40b7048594943f Mon Sep 17 00:00:00 2001 From: Harsh Bhikadia <harsh@bhikadia.com> Date: Tue, 9 Mar 2021 11:51:37 +0530 Subject: [PATCH 09/12] [scaffold] `_MeasureSize.onChange`: changed type `ValueChanged<Size?>` -> `ValueChanged<Size>` --- lib/scaffold.dart | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/scaffold.dart b/lib/scaffold.dart index 3298dcc..1954e2b 100644 --- a/lib/scaffold.dart +++ b/lib/scaffold.dart @@ -571,11 +571,8 @@ class BackdropScaffoldState extends State<BackdropScaffold> children: <Widget>[ Flexible( child: _MeasureSize( - onChange: (size) { - if (size != null) { - setState(() => _backPanelHeight = size.height); - } - }, + onChange: (size) => + setState(() => _backPanelHeight = size.height), child: widget.backLayer ?? Container(), ), ), @@ -603,11 +600,8 @@ class BackdropScaffoldState extends State<BackdropScaffold> children: <Widget>[ // subHeader _MeasureSize( - onChange: (size) { - if (size != null) { - setState(() => _subHeaderHeight = size.height); - } - }, + onChange: (size) => + setState(() => _subHeaderHeight = size.height), child: DefaultTextStyle( style: Theme.of(context).textTheme.subtitle1!, child: widget.subHeader ?? Container(), @@ -714,7 +708,7 @@ class BackdropScaffoldState extends State<BackdropScaffold> /// Credit: https://stackoverflow.com/a/60868972/2554745 class _MeasureSize extends StatefulWidget { final Widget child; - final ValueChanged<Size?> onChange; + final ValueChanged<Size> onChange; const _MeasureSize({ Key? key, @@ -738,7 +732,7 @@ class _MeasureSizeState extends State<_MeasureSize> { if (oldSize == newSize) return; oldSize = newSize; - widget.onChange(newSize); + if (newSize != null) widget.onChange(newSize); } @override From c77c561f2f754576242980531f8e08710632e2a0 Mon Sep 17 00:00:00 2001 From: Harsh Bhikadia <harsh@bhikadia.com> Date: Tue, 9 Mar 2021 12:00:54 +0530 Subject: [PATCH 10/12] [scaffold] `_willPopCallback`: not returning null. --- lib/scaffold.dart | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/scaffold.dart b/lib/scaffold.dart index 1954e2b..99e3682 100644 --- a/lib/scaffold.dart +++ b/lib/scaffold.dart @@ -618,10 +618,10 @@ class BackdropScaffoldState extends State<BackdropScaffold> ); } - Future<bool?> _willPopCallback(BuildContext context) async { + Future<bool> _willPopCallback(BuildContext context) async { if (isBackLayerRevealed) { concealBackLayer(); - return null; + return false; } return true; } @@ -633,8 +633,7 @@ class BackdropScaffoldState extends State<BackdropScaffold> Widget _buildBody(BuildContext context) { return WillPopScope( - onWillPop: (() => _willPopCallback(context) as Future<bool>) - as Future<bool> Function()?, + onWillPop: () => _willPopCallback(context), child: Scaffold( key: scaffoldKey, appBar: widget.appBar ?? From 9e264ee4b303e4549d50742f6031d5b8d85302c5 Mon Sep 17 00:00:00 2001 From: Yaroslav Pronin <proninyaroslav@gmail.com> Date: Wed, 10 Mar 2021 12:34:18 +0300 Subject: [PATCH 11/12] Fix warning --- lib/scaffold.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/scaffold.dart b/lib/scaffold.dart index 06d30a0..96212d7 100644 --- a/lib/scaffold.dart +++ b/lib/scaffold.dart @@ -592,7 +592,7 @@ class BackdropScaffoldState extends State<BackdropScaffold> child: _MeasureSize( onChange: (size) => setState(() => _backPanelHeight = size.height), - child: widget.backLayer ?? Container(), + child: widget.backLayer, ), ), ], From 031be1006259f282d53af2f07cbc5668f2137dc8 Mon Sep 17 00:00:00 2001 From: Harsh Bhikadia <harsh.bhikadiya@gmail.com> Date: Thu, 11 Mar 2021 11:48:20 +0530 Subject: [PATCH 12/12] [readme] added note for flutter v1 --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ae87c50..a6d6cd3 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ This widget is in active development. ___Any contribution, idea, criticism or feedback is welcomed.___ +__NOTE: If using Flutter v1.x.x, use v0.5.x pub version.__ + ## Quick links | | |