File tree 2 files changed +28
-5
lines changed
2 files changed +28
-5
lines changed Original file line number Diff line number Diff line change @@ -827,7 +827,6 @@ class _AppBarState extends State<AppBar> {
827
827
828
828
final bool hasDrawer = scaffold? .hasDrawer ?? false ;
829
829
final bool hasEndDrawer = scaffold? .hasEndDrawer ?? false ;
830
- final bool canPop = parentRoute? .canPop ?? false ;
831
830
final bool useCloseButton = parentRoute is PageRoute <dynamic > && parentRoute.fullscreenDialog;
832
831
833
832
final double toolbarHeight = widget.toolbarHeight ?? appBarTheme.toolbarHeight ?? kToolbarHeight;
@@ -897,10 +896,7 @@ class _AppBarState extends State<AppBar> {
897
896
leading = DrawerButton (
898
897
style: IconButton .styleFrom (iconSize: overallIconTheme.size ?? 24 ),
899
898
);
900
- // TODO(chunhtai): remove (!hasEndDrawer && canPop) once internal tests
901
- // are migrated.
902
- // https://github.com/flutter/flutter/issues/80256.
903
- } else if ((! hasEndDrawer && canPop) || (parentRoute? .impliesAppBarDismissal ?? false )) {
899
+ } else if (parentRoute? .impliesAppBarDismissal ?? false ) {
904
900
leading = useCloseButton ? const CloseButton () : const BackButton ();
905
901
}
906
902
}
Original file line number Diff line number Diff line change @@ -3946,6 +3946,33 @@ void main() {
3946
3946
);
3947
3947
});
3948
3948
3949
+ testWidgets ('Only local entries that imply app bar dismissal will introduce an back button' , (WidgetTester tester) async {
3950
+ final GlobalKey key = GlobalKey ();
3951
+ await tester.pumpWidget (
3952
+ MaterialApp (
3953
+ home: Scaffold (
3954
+ key: key,
3955
+ appBar: AppBar (),
3956
+ ),
3957
+ ),
3958
+ );
3959
+ expect (find.byType (BackButton ), findsNothing);
3960
+
3961
+ // Push one entry that doesn't imply app bar dismissal.
3962
+ ModalRoute .of (key.currentContext! )! .addLocalHistoryEntry (
3963
+ LocalHistoryEntry (onRemove: () {}, impliesAppBarDismissal: false ),
3964
+ );
3965
+ await tester.pump ();
3966
+ expect (find.byType (BackButton ), findsNothing);
3967
+
3968
+ // Push one entry that implies app bar dismissal.
3969
+ ModalRoute .of (key.currentContext! )! .addLocalHistoryEntry (
3970
+ LocalHistoryEntry (onRemove: () {}),
3971
+ );
3972
+ await tester.pump ();
3973
+ expect (find.byType (BackButton ), findsOneWidget);
3974
+ });
3975
+
3949
3976
testWidgets ('AppBar.preferredHeightFor' , (WidgetTester tester) async {
3950
3977
late double preferredHeight;
3951
3978
late Size preferredSize;
You can’t perform that action at this time.
0 commit comments