Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
db4c98fc
Unverified
Commit
db4c98fc
authored
Feb 15, 2022
by
Hans Muller
Committed by
GitHub
Feb 15, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a NavgationBar example with nested Navigators (#98440)
parent
4ee22ed2
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
493 additions
and
0 deletions
+493
-0
navigation_bar.0.dart
...les/api/lib/material/navigation_bar/navigation_bar.0.dart
+370
-0
navigation_bar.0.test.dart
...i/test/material/navigation_bar/navigation_bar.0.test.dart
+108
-0
navigation_bar.dart
packages/flutter/lib/src/material/navigation_bar.dart
+15
-0
No files found.
examples/api/lib/material/navigation_bar/navigation_bar.0.dart
0 → 100644
View file @
db4c98fc
This diff is collapsed.
Click to expand it.
examples/api/test/material/navigation_bar/navigation_bar.0.test.dart
0 → 100644
View file @
db4c98fc
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/material.dart'
;
import
'package:flutter_api_samples/material/navigation_bar/navigation_bar.0.dart'
as
example
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
testWidgets
(
'RootPage: only selected destination is on stage'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
example
.
Home
()));
const
String
tealTitle
=
'Teal RootPage - /'
;
const
String
cyanTitle
=
'Cyan RootPage - /'
;
const
String
orangeTitle
=
'Orange RootPage - /'
;
const
String
blueTitle
=
'Blue RootPage - /'
;
await
tester
.
tap
(
find
.
widgetWithText
(
NavigationDestination
,
'Teal'
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
tealTitle
),
findsOneWidget
);
expect
(
find
.
text
(
cyanTitle
),
findsNothing
);
expect
(
find
.
text
(
orangeTitle
),
findsNothing
);
expect
(
find
.
text
(
blueTitle
),
findsNothing
);
await
tester
.
tap
(
find
.
widgetWithText
(
NavigationDestination
,
'Cyan'
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
tealTitle
),
findsNothing
);
expect
(
find
.
text
(
cyanTitle
),
findsOneWidget
);
expect
(
find
.
text
(
orangeTitle
),
findsNothing
);
expect
(
find
.
text
(
blueTitle
),
findsNothing
);
await
tester
.
tap
(
find
.
widgetWithText
(
NavigationDestination
,
'Orange'
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
tealTitle
),
findsNothing
);
expect
(
find
.
text
(
cyanTitle
),
findsNothing
);
expect
(
find
.
text
(
orangeTitle
),
findsOneWidget
);
expect
(
find
.
text
(
blueTitle
),
findsNothing
);
await
tester
.
tap
(
find
.
widgetWithText
(
NavigationDestination
,
'Blue'
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
tealTitle
),
findsNothing
);
expect
(
find
.
text
(
cyanTitle
),
findsNothing
);
expect
(
find
.
text
(
orangeTitle
),
findsNothing
);
expect
(
find
.
text
(
blueTitle
),
findsOneWidget
);
});
testWidgets
(
'RootPage'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
example
.
Home
()));
await
tester
.
tap
(
find
.
widgetWithText
(
NavigationDestination
,
'Teal'
));
await
tester
.
pumpAndSettle
();
await
tester
.
tap
(
find
.
text
(
'Local Dialog'
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Teal AlertDialog'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'OK'
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Teal AlertDialog'
),
findsNothing
);
await
tester
.
pumpAndSettle
();
await
tester
.
tap
(
find
.
text
(
'Root Dialog'
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Teal AlertDialog'
),
findsOneWidget
);
await
tester
.
tapAt
(
const
Offset
(
5
,
5
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Teal AlertDialog'
),
findsNothing
);
await
tester
.
tap
(
find
.
text
(
'Local BottomSheet'
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
byType
(
BottomSheet
),
findsOneWidget
);
await
tester
.
tap
(
find
.
byType
(
BackButton
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
byType
(
BottomSheet
),
findsNothing
);
await
tester
.
tap
(
find
.
text
(
'Push /list'
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Teal ListPage - /list'
),
findsOneWidget
);
});
testWidgets
(
'ListPage'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
example
.
Home
()));
expect
(
find
.
text
(
'Teal RootPage - /'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
widgetWithText
(
ElevatedButton
,
'Push /list'
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Teal ListPage - /list'
),
findsOneWidget
);
expect
(
find
.
text
(
'Push /text [0]'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
widgetWithText
(
NavigationDestination
,
'Orange'
));
await
tester
.
pumpAndSettle
();
await
tester
.
tap
(
find
.
widgetWithText
(
ElevatedButton
,
'Push /list'
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Orange ListPage - /list'
),
findsOneWidget
);
expect
(
find
.
text
(
'Push /text [0]'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
byType
(
BackButton
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Orange RootPage - /'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
widgetWithText
(
NavigationDestination
,
'Teal'
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Teal ListPage - /list'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
byType
(
BackButton
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Teal RootPage - /'
),
findsOneWidget
);
});
}
packages/flutter/lib/src/material/navigation_bar.dart
View file @
db4c98fc
...
...
@@ -59,6 +59,21 @@ import 'tooltip.dart';
/// ),
/// ),
/// ```
///
/// {@tool dartpad}
/// This example has a [NavigationBar] where each destination has its
/// own Navigator, Scaffold, and Appbar. That means that each
/// destination has an independent route history and (app bar) back
/// button. A [Stack] is used to display one destination at a time and
/// destination changes are handled by cross fade transitions. Destinations
/// that have been completely faded out are [Offstage].
///
/// One can see that the appearance of each destination's dialogs, bottom sheet,
/// list scrolling state, and text field state, persist when another destination
/// is selected.
///
/// ** See code in examples/api/lib/material/navigation_bar/navigation_bar.0.dart **
/// {@end-tool}
class
NavigationBar
extends
StatelessWidget
{
/// Creates a Material 3 Navigation Bar component.
///
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment