From 29c4f23358e5ca6309f7616d33a074b5d715ff70 Mon Sep 17 00:00:00 2001 From: Scott MacDougall Date: Sat, 1 May 2021 15:20:45 -0400 Subject: [PATCH 1/2] Resolves #91 - Added maintainState property --- lib/scaffold.dart | 15 ++++++++++++++- pubspec.yaml | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/scaffold.dart b/lib/scaffold.dart index 96212d7..6616000 100644 --- a/lib/scaffold.dart +++ b/lib/scaffold.dart @@ -211,6 +211,16 @@ class BackdropScaffold extends StatefulWidget { /// Will be called when [backLayer] has been revealed. final VoidCallback? onBackLayerRevealed; + /// Specifies whether the state of the [backLayer] is maintained when it is + /// revealed and concealed. + /// + /// When true (default), the [backLayer] is kept in the tree while concealed. + /// When false, the [backLayer] is removed from the tree when concealed and + /// recreated when revealed. + /// + /// Defaults to `true`. + final bool maintainState; + // ------------- PROPERTIES TAKEN OVER FROM SCAFFOLD ------------- // /// A key to use when building the [Scaffold]. @@ -327,6 +337,7 @@ class BackdropScaffold extends StatefulWidget { this.backLayerScrim = Colors.black54, this.onBackLayerConcealed, this.onBackLayerRevealed, + this.maintainState = true, this.scaffoldKey, this.appBar, this.floatingActionButton, @@ -592,7 +603,9 @@ class BackdropScaffoldState extends State child: _MeasureSize( onChange: (size) => setState(() => _backPanelHeight = size.height), - child: widget.backLayer, + child: !widget.maintainState && isBackLayerConcealed + ? Container() + : widget.backLayer, ), ), ], diff --git a/pubspec.yaml b/pubspec.yaml index ab16cbc..3e35eec 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,6 +10,7 @@ authors: - Felix Wielander - Daniel Borges - Felix Wortmann + - Scott MacDougall environment: sdk: '>=2.12.0 <3.0.0' From 2f834e66c25fe620cbf4a291098af631d011ac5e Mon Sep 17 00:00:00 2001 From: Scott MacDougall Date: Sun, 2 May 2021 08:56:16 -0400 Subject: [PATCH 2/2] Renamed maintainState to MaintainBackLayerState, removed redundant comment. --- lib/scaffold.dart | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/scaffold.dart b/lib/scaffold.dart index 6616000..4b6b969 100644 --- a/lib/scaffold.dart +++ b/lib/scaffold.dart @@ -214,12 +214,12 @@ class BackdropScaffold extends StatefulWidget { /// Specifies whether the state of the [backLayer] is maintained when it is /// revealed and concealed. /// - /// When true (default), the [backLayer] is kept in the tree while concealed. + /// When true, the [backLayer] is kept in the tree while concealed. /// When false, the [backLayer] is removed from the tree when concealed and /// recreated when revealed. /// /// Defaults to `true`. - final bool maintainState; + final bool maintainBackLayerState; // ------------- PROPERTIES TAKEN OVER FROM SCAFFOLD ------------- // @@ -337,7 +337,7 @@ class BackdropScaffold extends StatefulWidget { this.backLayerScrim = Colors.black54, this.onBackLayerConcealed, this.onBackLayerRevealed, - this.maintainState = true, + this.maintainBackLayerState = true, this.scaffoldKey, this.appBar, this.floatingActionButton, @@ -603,9 +603,10 @@ class BackdropScaffoldState extends State child: _MeasureSize( onChange: (size) => setState(() => _backPanelHeight = size.height), - child: !widget.maintainState && isBackLayerConcealed - ? Container() - : widget.backLayer, + child: + !widget.maintainBackLayerState && isBackLayerConcealed + ? Container() + : widget.backLayer, ), ), ],