Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d57f59d
[adaptive_scaffold] : FIX - Drawer stays open even on destination tap…
aliasgar4558 Mar 9, 2024
ea98de7
📝 : Bug Id Typo fix added.
aliasgar4558 Mar 9, 2024
061b49b
✅ : Test case added for drawer auto dismissal upon destination tap.
aliasgar4558 Mar 9, 2024
23c9e39
📝 : Authors updated.
aliasgar4558 Mar 10, 2024
042e859
Merge branch 'main' into main
aliasgar4558 Mar 13, 2024
8d1760d
Merge branch 'flutter:main' into main
aliasgar4558 Mar 14, 2024
32160d1
Merge branch 'main' into main
aliasgar4558 Mar 14, 2024
f2ae73f
Merge branch 'main' into main
aliasgar4558 Mar 15, 2024
6755661
Merge branch 'main' into main
aliasgar4558 Mar 15, 2024
2455f11
Merge branch 'main' into main
aliasgar4558 Mar 15, 2024
479c5c2
Merge branch 'main' into main
aliasgar4558 Mar 16, 2024
6dd463d
Merge branch 'main' into main
aliasgar4558 Mar 17, 2024
a048665
Merge branch 'main' into main
aliasgar4558 Mar 18, 2024
cfb2ec6
Merge branch 'main' into main
aliasgar4558 Mar 19, 2024
cd0c5e1
Merge branch 'main' into main
aliasgar4558 Mar 20, 2024
f772bf0
🐛 : #110902 : Assertion added when tried with less than 2 destinations.
aliasgar4558 Mar 20, 2024
baee5f0
Merge branch 'main' into main
aliasgar4558 Mar 21, 2024
d52457b
🔖 : Updated changelog.md
aliasgar4558 Mar 21, 2024
0a33f89
🔖 : Removed unpublished version change logs.
aliasgar4558 Mar 21, 2024
1267521
Merge branch 'main' into Code/Fix/#110902
aliasgar4558 Mar 21, 2024
3eb6b5f
Merge branch 'flutter:main' into main
aliasgar4558 Mar 21, 2024
313f288
Merge branch 'main' into Code/Fix/#110902
aliasgar4558 Mar 21, 2024
d211842
Updated assertion message.
aliasgar4558 Mar 21, 2024
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
Next Next commit
[adaptive_scaffold] : FIX - Drawer stays open even on destination tap…
… (#141938)
  • Loading branch information
aliasgar4558 committed Mar 9, 2024
commit d57f59d673fceb48a560a0b8fb494d2c38de6262
4 changes: 4 additions & 0 deletions packages/flutter_adaptive_scaffold/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.9

* FIX : Drawer stays open even on destination tap - [flutter/flutter#41938](https://github.com/flutter/flutter/issues/141938)

## NEXT

* Updates minimum supported SDK version to Flutter 3.13/Dart 3.1.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,12 +502,16 @@ class AdaptiveScaffold extends StatefulWidget {
}

class _AdaptiveScaffoldState extends State<AdaptiveScaffold> {
// Global scaffold key that will help to manage drawer state.
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();

@override
Widget build(BuildContext context) {
final NavigationRailThemeData navRailTheme =
Theme.of(context).navigationRailTheme;

return Scaffold(
key: _scaffoldKey,
appBar: widget.drawerBreakpoint.isActive(context) && widget.useDrawer ||
(widget.appBarBreakpoint?.isActive(context) ?? false)
? widget.appBar ?? AppBar()
Expand All @@ -523,7 +527,7 @@ class _AdaptiveScaffoldState extends State<AdaptiveScaffold> {
.map((NavigationDestination destination) =>
AdaptiveScaffold.toRailDestination(destination))
.toList(),
onDestinationSelected: widget.onSelectedIndexChange,
onDestinationSelected: _onDrawerDestinationSelected,
),
)
: null,
Expand Down Expand Up @@ -670,6 +674,20 @@ class _AdaptiveScaffoldState extends State<AdaptiveScaffold> {
),
);
}

void _onDrawerDestinationSelected(int index) {
if (widget.useDrawer) {
// If [useDrawer] is true, then retrieve the current state.
final ScaffoldState? scaffoldCurrentContext = _scaffoldKey.currentState;
if (scaffoldCurrentContext != null) {
if (scaffoldCurrentContext.isDrawerOpen) {
// If drawer is open, call [closeDrawer] to dismiss drawer as per material guidelines.
scaffoldCurrentContext.closeDrawer();
}
}
}
widget.onSelectedIndexChange?.call(index);
}
}

class _BrickLayout extends StatelessWidget {
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_adaptive_scaffold/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_adaptive_scaffold
description: Widgets to easily build adaptive layouts, including navigation elements.
version: 0.1.8
version: 0.1.9
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_adaptive_scaffold%22
repository: https://github.com/flutter/packages/tree/main/packages/flutter_adaptive_scaffold

Expand Down