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
44ba6ab0
Unverified
Commit
44ba6ab0
authored
Jun 18, 2021
by
Wilson Wilson
Committed by
GitHub
Jun 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added null check before NavigationRail.onDestinationSelected is called (#78032)
parent
4465f688
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletion
+17
-1
navigation_rail.dart
packages/flutter/lib/src/material/navigation_rail.dart
+2
-1
navigation_rail_test.dart
packages/flutter/test/material/navigation_rail_test.dart
+15
-0
No files found.
packages/flutter/lib/src/material/navigation_rail.dart
View file @
44ba6ab0
...
...
@@ -498,7 +498,8 @@ class _NavigationRailState extends State<NavigationRail> with TickerProviderStat
labelTextStyle:
widget
.
selectedIndex
==
i
?
selectedLabelTextStyle
:
unselectedLabelTextStyle
,
padding:
widget
.
destinations
[
i
].
padding
,
onTap:
()
{
widget
.
onDestinationSelected
!(
i
);
if
(
widget
.
onDestinationSelected
!=
null
)
widget
.
onDestinationSelected
!(
i
);
},
indexLabel:
localizations
.
tabLabel
(
tabIndex:
i
+
1
,
...
...
packages/flutter/test/material/navigation_rail_test.dart
View file @
44ba6ab0
...
...
@@ -1918,6 +1918,21 @@ void main() {
expect
(
selectedIndex
,
2
);
});
testWidgets
(
'onDestinationSelected is not called if null'
,
(
WidgetTester
tester
)
async
{
const
int
selectedIndex
=
0
;
await
_pumpNavigationRail
(
tester
,
navigationRail:
NavigationRail
(
selectedIndex:
selectedIndex
,
destinations:
_destinations
(),
labelType:
NavigationRailLabelType
.
all
,
),
);
await
tester
.
tap
(
find
.
text
(
'Def'
));
expect
(
selectedIndex
,
0
);
});
testWidgets
(
'Changing destinations animate when [labelType]=selected'
,
(
WidgetTester
tester
)
async
{
int
selectedIndex
=
0
;
...
...
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