Skip to content

Commit

Permalink
Merge pull request #93 from ScottMacDougall/master
Browse files Browse the repository at this point in the history
Added maintainState property
  • Loading branch information
daadu authored May 3, 2021
2 parents 3c23e7a + 2f834e6 commit 29d6674
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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, 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 maintainBackLayerState;

// ------------- PROPERTIES TAKEN OVER FROM SCAFFOLD ------------- //

/// A key to use when building the [Scaffold].
Expand Down Expand Up @@ -327,6 +337,7 @@ class BackdropScaffold extends StatefulWidget {
this.backLayerScrim = Colors.black54,
this.onBackLayerConcealed,
this.onBackLayerRevealed,
this.maintainBackLayerState = true,
this.scaffoldKey,
this.appBar,
this.floatingActionButton,
Expand Down Expand Up @@ -592,7 +603,10 @@ class BackdropScaffoldState extends State<BackdropScaffold>
child: _MeasureSize(
onChange: (size) =>
setState(() => _backPanelHeight = size.height),
child: widget.backLayer,
child:
!widget.maintainBackLayerState && isBackLayerConcealed
? Container()
: widget.backLayer,
),
),
],
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ authors:
- Felix Wielander <[email protected]>
- Daniel Borges <https://github.com/danielborges93>
- Felix Wortmann <https://github.com/felixwortmann>
- Scott MacDougall <[email protected]>

environment:
sdk: '>=2.12.0 <3.0.0'
Expand Down

0 comments on commit 29d6674

Please sign in to comment.