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
3d01e89e
Unverified
Commit
3d01e89e
authored
Nov 07, 2018
by
Dan Field
Committed by
GitHub
Nov 07, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unbreak WidgetsApp when only a builder specified (#23976)
* update assert add test * update docs
parent
6c88b2e9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
12 deletions
+61
-12
app.dart
packages/flutter/lib/src/widgets/app.dart
+43
-12
app_test.dart
packages/flutter/test/widgets/app_test.dart
+18
-0
No files found.
packages/flutter/lib/src/widgets/app.dart
View file @
3d01e89e
...
@@ -71,14 +71,41 @@ class WidgetsApp extends StatefulWidget {
...
@@ -71,14 +71,41 @@ class WidgetsApp extends StatefulWidget {
///
///
/// The boolean arguments, [color], and [navigatorObservers] must not be null.
/// The boolean arguments, [color], and [navigatorObservers] must not be null.
///
///
/// If the [builder] is null, the [onGenerateRoute] and [pageRouteBuilder]
/// Most callers will want to use the [home] or [routes] parameters, or both.
/// arguments are required. The [onGenerateRoute] parameter corresponds to
/// The [home] parameter is a convenience for the following [routes] map:
/// [Navigator.onGenerateRoute], and [pageRouteBuilder] will create a [PageRoute]
///
/// that wraps newly built routes. If the [builder] is non-null
/// ```dart
/// and the [onGenerateRoute] argument is null, then the [builder] will not be
/// <String, WidgetBuilder>{ '/': (BuildContext context) => myWidget }
/// provided with a [Navigator]. If [onGenerateRoute] is not provided,
/// ```
/// [navigatorKey], [onUnknownRoute], [navigatorObservers], and [initialRoute]
///
/// must have their default values, as they will have no effect.
/// It is possible to specify both [home] and [routes], but only if [routes] does
/// _not_ contain an entry for `'/'`. Conversely, if [home] is omitted, [routes]
/// _must_ contain an entry for `'/'`.
///
/// If [home] or [routes] are not null, then either the [pageRoutebuilder] or
/// the [builder] parameter is required. These parameters will be used so
/// that the default routing implementation in [WidgetsApp] can wrap routes in
/// appropriate transitions. For example, [MaterialApp] will provide a
/// [pageRoutebuilder] that creates Material compliant hero animations between
/// routes, whereas the [CupertinoApp] provides Cupertino compliant hero
/// animations. Other implementations can provide other custom transitions here.
///
/// The [builder] parameter is optional in all cases. It can be used to ensure that
/// all route entries get wrapped in another widget. It is invoked during the build
/// phase of this widget. If it is specified,
///
/// It is also possible to provide a custom implementation of routing via the
/// [onGeneratedRoute] and [onUnknownRoute] parameters. These parameters correspond
/// to [Navigator.onGenerateRoute] and [Navigator.onUnknownRoute]. If [home], [routes],
/// and [builder] are null, or if they fail to create a requested route,
/// [onGeneratedRoute] will be invoked. If that fails, [onUnknownRoute] will be invoked.
///
/// The [pageRouteBuilder] will create a [PageRoute] that wraps newly built routes.
/// If the [builder] is non-null and the [onGenerateRoute] argument is null, then the
/// [builder] will not be provided only with the context and the child widget, whereas
/// the [pageRouteBuilder] will be provided with [RouteSettings]. If [onGenerateRoute]
/// is not provided, [navigatorKey], [onUnknownRoute], [navigatorObservers], and
/// [initialRoute] must have their default values, as they will have no effect.
///
///
/// The `supportedLocales` argument must be a list of one or more elements.
/// The `supportedLocales` argument must be a list of one or more elements.
/// By default supportedLocales is `[const Locale('en', 'US')]`.
/// By default supportedLocales is `[const Locale('en', 'US')]`.
...
@@ -148,10 +175,14 @@ class WidgetsApp extends StatefulWidget {
...
@@ -148,10 +175,14 @@ class WidgetsApp extends StatefulWidget {
'must have their initial values '
'must have their initial values '
'(null, null, and the empty list, respectively).'
'(null, null, and the empty list, respectively).'
),
),
assert
(
onGenerateRoute
!=
null
||
pageRouteBuilder
!=
null
,
assert
(
'If onGenerateRoute is not provided, the pageRouteBuilder must be specified '
builder
!=
null
||
'so that the default handler will know what kind of PageRoute transition '
onGenerateRoute
!=
null
||
'bo build.'
),
pageRouteBuilder
!=
null
,
'If neither builder nor onGenerateRoute are provided, the '
'pageRouteBuilder must be specified so that the default handler '
'will know what kind of PageRoute transition to build.'
),
assert
(
title
!=
null
),
assert
(
title
!=
null
),
assert
(
color
!=
null
),
assert
(
color
!=
null
),
assert
(
supportedLocales
!=
null
&&
supportedLocales
.
isNotEmpty
),
assert
(
supportedLocales
!=
null
&&
supportedLocales
.
isNotEmpty
),
...
...
packages/flutter/test/widgets/app_test.dart
0 → 100644
View file @
3d01e89e
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
testWidgets
(
'WidgetsApp with builder only'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
key
=
GlobalKey
();
await
tester
.
pumpWidget
(
WidgetsApp
(
key:
key
,
builder:
(
BuildContext
context
,
Widget
child
)
{
return
const
Placeholder
();
},
color:
const
Color
(
0xFF123456
),
),
);
expect
(
find
.
byKey
(
key
),
findsOneWidget
);
});
}
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