Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added maintainState property #93

Merged
merged 2 commits into from
May 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 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 (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].
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -592,7 +603,9 @@ class BackdropScaffoldState extends State<BackdropScaffold>
child: _MeasureSize(
onChange: (size) =>
setState(() => _backPanelHeight = size.height),
child: widget.backLayer,
child: !widget.maintainState && 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 <felix.wielander@gmail.com>
- Daniel Borges <https://github.com/danielborges93>
- Felix Wortmann <https://github.com/felixwortmann>
- Scott MacDougall <me@scottmacdougall.ca>

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