Skip to content

Commit

Permalink
concealable frontlayer when that's active by pressing back button on …
Browse files Browse the repository at this point in the history
…phone

By default, when the frontLayer widget  visibility is active, the user expects to hide it by pressing the back button. However, in the current version, this did not happen, and unfortunately, outside of this library, I was unable to hide the frontLayer widget. To achieve this, I removed the ‍concealBacklayerOnBackButton‍ argument and modified the Scaffold class in this library. Now, this operation is successfully executed.
  • Loading branch information
pishguy authored Sep 23, 2023
1 parent 0387c4f commit 822d9ae
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions lib/src/scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ class BackdropScaffold extends StatefulWidget {
/// Specifiy whether to conceal [backLayer] when back button pressed.
///
/// Default to `true`.
final bool concealBacklayerOnBackButton;
// ------------- PROPERTIES TAKEN OVER FROM SCAFFOLD ------------- //

Expand Down Expand Up @@ -336,7 +335,6 @@ class BackdropScaffold extends StatefulWidget {
this.onBackLayerConcealed,
this.onBackLayerRevealed,
this.maintainBackLayerState = true,
this.concealBacklayerOnBackButton = true,
this.scaffoldKey,
this.appBar,
this.floatingActionButton,
Expand Down Expand Up @@ -612,17 +610,16 @@ class BackdropScaffoldState extends State<BackdropScaffold>
);

Widget _wrapWillPopScope(BuildContext context, {required Widget child}) {
if (!widget.concealBacklayerOnBackButton) return child;
return WillPopScope(
onWillPop: () async {
if (isBackLayerRevealed) {
concealBackLayer();
if (!isBackLayerRevealed) {
return WillPopScope(
onWillPop: () async {
revealBackLayer();
return false;
}
return true;
},
child: child,
);
},
child: child,
);
}
return child;
}

Widget _buildBody(BuildContext context) => _wrapWillPopScope(
Expand Down

0 comments on commit 822d9ae

Please sign in to comment.