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
fef2d6cc
Unverified
Commit
fef2d6cc
authored
Feb 27, 2020
by
Darren Austin
Committed by
GitHub
Feb 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass RouteSettings into all callers of showGeneralDialog. (#51525)
parent
4fb9ce84
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
96 additions
and
6 deletions
+96
-6
route.dart
packages/flutter/lib/src/cupertino/route.dart
+2
-0
about.dart
packages/flutter/lib/src/material/about.dart
+4
-2
date_picker.dart
packages/flutter/lib/src/material/date_picker.dart
+4
-2
dialog.dart
packages/flutter/lib/src/material/dialog.dart
+5
-0
time_picker.dart
packages/flutter/lib/src/material/time_picker.dart
+4
-2
routes.dart
packages/flutter/lib/src/widgets/routes.dart
+5
-0
dialog_test.dart
packages/flutter/test/material/dialog_test.dart
+72
-0
No files found.
packages/flutter/lib/src/cupertino/route.dart
View file @
fef2d6cc
...
...
@@ -976,6 +976,7 @@ Future<T> showCupertinoDialog<T>({
@required
BuildContext
context
,
@required
WidgetBuilder
builder
,
bool
useRootNavigator
=
true
,
RouteSettings
routeSettings
,
})
{
assert
(
builder
!=
null
);
assert
(
useRootNavigator
!=
null
);
...
...
@@ -990,5 +991,6 @@ Future<T> showCupertinoDialog<T>({
},
transitionBuilder:
_buildCupertinoDialogTransitions
,
useRootNavigator:
useRootNavigator
,
routeSettings:
routeSettings
,
);
}
packages/flutter/lib/src/material/about.dart
View file @
fef2d6cc
...
...
@@ -223,8 +223,8 @@ class AboutListTile extends StatelessWidget {
/// The licenses shown on the [LicensePage] are those returned by the
/// [LicenseRegistry] API, which can be used to add more licenses to the list.
///
/// The [context]
and [useRootNavigator] arguments are passed to [showDialog],
/// the documentation for which discusses how it is used.
/// The [context]
, [useRootNavigator] and [routeSettings] arguments are passed to
///
[showDialog],
the documentation for which discusses how it is used.
void
showAboutDialog
(
{
@required
BuildContext
context
,
String
applicationName
,
...
...
@@ -233,6 +233,7 @@ void showAboutDialog({
String
applicationLegalese
,
List
<
Widget
>
children
,
bool
useRootNavigator
=
true
,
RouteSettings
routeSettings
,
})
{
assert
(
context
!=
null
);
assert
(
useRootNavigator
!=
null
);
...
...
@@ -248,6 +249,7 @@ void showAboutDialog({
children:
children
,
);
},
routeSettings:
routeSettings
,
);
}
...
...
packages/flutter/lib/src/material/date_picker.dart
View file @
fef2d6cc
...
...
@@ -1086,8 +1086,8 @@ typedef SelectableDayPredicate = bool Function(DateTime day);
/// provided by [Directionality]. If both [locale] and [textDirection] are not
/// null, [textDirection] overrides the direction chosen for the [locale].
///
/// The [context]
and [useRootNavigator] arguments are passed to [showDialog],
/// the documentation for which discusses how it is used.
/// The [context]
, [useRootNavigator] and [routeSettings] arguments are passed to
///
[showDialog],
the documentation for which discusses how it is used.
///
/// The [builder] parameter can be used to wrap the dialog widget
/// to add inherited widgets like [Theme].
...
...
@@ -1137,6 +1137,7 @@ Future<DateTime> showDatePicker({
TextDirection
textDirection
,
TransitionBuilder
builder
,
bool
useRootNavigator
=
true
,
RouteSettings
routeSettings
,
})
async
{
assert
(
initialDate
!=
null
);
assert
(
firstDate
!=
null
);
...
...
@@ -1182,5 +1183,6 @@ Future<DateTime> showDatePicker({
builder:
(
BuildContext
context
)
{
return
builder
==
null
?
child
:
builder
(
context
,
child
);
},
routeSettings:
routeSettings
,
);
}
packages/flutter/lib/src/material/dialog.dart
View file @
fef2d6cc
...
...
@@ -872,6 +872,9 @@ Widget _buildMaterialDialogTransitions(BuildContext context, Animation<double> a
/// By default, `useRootNavigator` is `true` and the dialog route created by
/// this method is pushed to the root navigator.
///
/// The `routeSettings` argument is passed to [showGeneralDialog],
/// see [RouteSettings] for details.
///
/// If the application has multiple [Navigator] objects, it may be necessary to
/// call `Navigator.of(context, rootNavigator: true).pop(result)` to close the
/// dialog rather than just `Navigator.pop(context, result)`.
...
...
@@ -900,6 +903,7 @@ Future<T> showDialog<T>({
Widget
child
,
WidgetBuilder
builder
,
bool
useRootNavigator
=
true
,
RouteSettings
routeSettings
,
})
{
assert
(
child
==
null
||
builder
==
null
);
assert
(
useRootNavigator
!=
null
);
...
...
@@ -926,5 +930,6 @@ Future<T> showDialog<T>({
transitionDuration:
const
Duration
(
milliseconds:
150
),
transitionBuilder:
_buildMaterialDialogTransitions
,
useRootNavigator:
useRootNavigator
,
routeSettings:
routeSettings
,
);
}
packages/flutter/lib/src/material/time_picker.dart
View file @
fef2d6cc
...
...
@@ -1749,8 +1749,8 @@ class _TimePickerDialogState extends State<_TimePickerDialog> {
/// ```
/// {@end-tool}
///
/// The [context]
and [useRootNavigator] arguments are passed to [showDialog],
/// the documentation for which discusses how it is used.
/// The [context]
, [useRootNavigator] and [routeSettings] arguments are passed to
///
[showDialog],
the documentation for which discusses how it is used.
///
/// The [builder] parameter can be used to wrap the dialog widget
/// to add inherited widgets like [Localizations.override],
...
...
@@ -1799,6 +1799,7 @@ Future<TimeOfDay> showTimePicker({
@required
TimeOfDay
initialTime
,
TransitionBuilder
builder
,
bool
useRootNavigator
=
true
,
RouteSettings
routeSettings
,
})
async
{
assert
(
context
!=
null
);
assert
(
initialTime
!=
null
);
...
...
@@ -1812,6 +1813,7 @@ Future<TimeOfDay> showTimePicker({
builder:
(
BuildContext
context
)
{
return
builder
==
null
?
dialog
:
builder
(
context
,
dialog
);
},
routeSettings:
routeSettings
,
);
}
...
...
packages/flutter/lib/src/widgets/routes.dart
View file @
fef2d6cc
...
...
@@ -1727,6 +1727,9 @@ class _DialogRoute<T> extends PopupRoute<T> {
/// and leaves off the screen. By default, the transition is a linear fade of
/// the page's contents.
///
/// The `routeSettings` will be used in the construction of the dialog's route.
/// See [RouteSettings] for more details.
///
/// Returns a [Future] that resolves to the value (if any) that was passed to
/// [Navigator.pop] when the dialog was closed.
///
...
...
@@ -1743,6 +1746,7 @@ Future<T> showGeneralDialog<T>({
Duration
transitionDuration
,
RouteTransitionsBuilder
transitionBuilder
,
bool
useRootNavigator
=
true
,
RouteSettings
routeSettings
,
})
{
assert
(
pageBuilder
!=
null
);
assert
(
useRootNavigator
!=
null
);
...
...
@@ -1754,6 +1758,7 @@ Future<T> showGeneralDialog<T>({
barrierColor:
barrierColor
,
transitionDuration:
transitionDuration
,
transitionBuilder:
transitionBuilder
,
settings:
routeSettings
,
));
}
...
...
packages/flutter/test/material/dialog_test.dart
View file @
fef2d6cc
...
...
@@ -1170,6 +1170,60 @@ void main() {
expect
(
content
.
localToGlobal
(
Offset
.
zero
),
equals
(
contentOriginalOffset
));
});
});
testWidgets
(
'Dialog with RouteSettings'
,
(
WidgetTester
tester
)
async
{
RouteSettings
currentRouteSetting
;
await
tester
.
pumpWidget
(
MaterialApp
(
navigatorObservers:
<
NavigatorObserver
>[
_ClosureNavigatorObserver
(
onDidChange:
(
Route
<
dynamic
>
newRoute
)
{
currentRouteSetting
=
newRoute
?.
settings
;
})
],
home:
const
Material
(
child:
Center
(
child:
RaisedButton
(
onPressed:
null
,
child:
Text
(
'Go'
),
),
),
),
),
);
final
BuildContext
context
=
tester
.
element
(
find
.
text
(
'Go'
));
const
RouteSettings
exampleSetting
=
RouteSettings
(
name:
'simple'
);
final
Future
<
int
>
result
=
showDialog
<
int
>(
context:
context
,
builder:
(
BuildContext
context
)
{
return
SimpleDialog
(
title:
const
Text
(
'Title'
),
children:
<
Widget
>[
SimpleDialogOption
(
child:
const
Text
(
'X'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pop
();
},
),
],
);
},
routeSettings:
exampleSetting
,
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Title'
),
findsOneWidget
);
expect
(
currentRouteSetting
,
exampleSetting
);
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
expect
(
await
result
,
isNull
);
await
tester
.
pumpAndSettle
();
expect
(
currentRouteSetting
?.
name
,
'/'
);
});
}
class
DialogObserver
extends
NavigatorObserver
{
...
...
@@ -1183,3 +1237,21 @@ class DialogObserver extends NavigatorObserver {
super
.
didPush
(
route
,
previousRoute
);
}
}
class
_ClosureNavigatorObserver
extends
NavigatorObserver
{
_ClosureNavigatorObserver
({
@required
this
.
onDidChange
});
final
void
Function
(
Route
<
dynamic
>
newRoute
)
onDidChange
;
@override
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
=>
onDidChange
(
route
);
@override
void
didPop
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
=>
onDidChange
(
previousRoute
);
@override
void
didRemove
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
=>
onDidChange
(
previousRoute
);
@override
void
didReplace
({
Route
<
dynamic
>
newRoute
,
Route
<
dynamic
>
oldRoute
})
=>
onDidChange
(
newRoute
);
}
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