Unverified Commit 06f63aaa authored by xster's avatar xster Committed by GitHub

Create a CupertinoApp (#18469)

parent aad1bb4b
bc99a4bdea0533994b34bc49f160af75f4904952 413041fd6bbedd1c8bc6ca0b6ea6ea948079b669
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
library cupertino; library cupertino;
export 'src/cupertino/activity_indicator.dart'; export 'src/cupertino/activity_indicator.dart';
export 'src/cupertino/app.dart';
export 'src/cupertino/bottom_tab_bar.dart'; export 'src/cupertino/bottom_tab_bar.dart';
export 'src/cupertino/button.dart'; export 'src/cupertino/button.dart';
export 'src/cupertino/colors.dart'; export 'src/cupertino/colors.dart';
......
This diff is collapsed.
This diff is collapsed.
...@@ -123,6 +123,7 @@ class WidgetsApp extends StatefulWidget { ...@@ -123,6 +123,7 @@ class WidgetsApp extends StatefulWidget {
/// null, [navigatorKey] must also be null. /// null, [navigatorKey] must also be null.
final GlobalKey<NavigatorState> navigatorKey; final GlobalKey<NavigatorState> navigatorKey;
/// {@template flutter.widgets.widgetsApp.onGenerateRoute}
/// The route generator callback used when the app is navigated to a /// The route generator callback used when the app is navigated to a
/// named route. /// named route.
/// ///
...@@ -133,6 +134,7 @@ class WidgetsApp extends StatefulWidget { ...@@ -133,6 +134,7 @@ class WidgetsApp extends StatefulWidget {
/// During normal app operation, the [onGenerateRoute] callback will only be /// During normal app operation, the [onGenerateRoute] callback will only be
/// applied to route names pushed by the application, and so should never /// applied to route names pushed by the application, and so should never
/// return null. /// return null.
/// {@endtemplate}
/// ///
/// The [Navigator] is only built if [onGenerateRoute] is not null. If /// The [Navigator] is only built if [onGenerateRoute] is not null. If
/// [onGenerateRoute] is null, the [builder] must be non-null. /// [onGenerateRoute] is null, the [builder] must be non-null.
...@@ -140,18 +142,21 @@ class WidgetsApp extends StatefulWidget { ...@@ -140,18 +142,21 @@ class WidgetsApp extends StatefulWidget {
/// Called when [onGenerateRoute] fails to generate a route. /// Called when [onGenerateRoute] fails to generate a route.
/// ///
/// {@template flutter.widgets.widgetsApp.onUnknownRoute}
/// This callback is typically used for error handling. For example, this /// This callback is typically used for error handling. For example, this
/// callback might always generate a "not found" page that describes the route /// callback might always generate a "not found" page that describes the route
/// that wasn't found. /// that wasn't found.
/// ///
/// Unknown routes can arise either from errors in the app or from external /// Unknown routes can arise either from errors in the app or from external
/// requests to push routes, such as from Android intents. /// requests to push routes, such as from Android intents.
/// {@endtemplate}
/// ///
/// The [Navigator] is only built if [onGenerateRoute] is not null; if it is /// The [Navigator] is only built if [onGenerateRoute] is not null; if it is
/// null, [onUnknownRoute] must also be null. /// null, [onUnknownRoute] must also be null.
final RouteFactory onUnknownRoute; final RouteFactory onUnknownRoute;
/// The name of the first route to show. /// {@template flutter.widgets.widgetsApp.initialRoute}
/// The name of the first route to show, if a [Navigator] is built.
/// ///
/// Defaults to [Window.defaultRouteName], which may be overridden by the code /// Defaults to [Window.defaultRouteName], which may be overridden by the code
/// that launched the application. /// that launched the application.
...@@ -165,6 +170,7 @@ class WidgetsApp extends StatefulWidget { ...@@ -165,6 +170,7 @@ class WidgetsApp extends StatefulWidget {
/// [initialRoute] is ignored and [Navigator.defaultRouteName] is used instead /// [initialRoute] is ignored and [Navigator.defaultRouteName] is used instead
/// (`/`). This can happen if the app is started with an intent that specifies /// (`/`). This can happen if the app is started with an intent that specifies
/// a non-existent route. /// a non-existent route.
/// {@endtemplate}
/// ///
/// The [Navigator] is only built if [onGenerateRoute] is not null; if it is /// The [Navigator] is only built if [onGenerateRoute] is not null; if it is
/// null, [initialRoute] must also be null. /// null, [initialRoute] must also be null.
...@@ -176,16 +182,19 @@ class WidgetsApp extends StatefulWidget { ...@@ -176,16 +182,19 @@ class WidgetsApp extends StatefulWidget {
/// * [Navigator.pop], for removing a route from the stack. /// * [Navigator.pop], for removing a route from the stack.
final String initialRoute; final String initialRoute;
/// {@template flutter.widgets.widgetsApp.navigatorObservers}
/// The list of observers for the [Navigator] created for this app. /// The list of observers for the [Navigator] created for this app.
/// ///
/// This list must be replaced by a list of newly-created observers if the /// This list must be replaced by a list of newly-created observers if the
/// [navigatorKey] is changed. /// [navigatorKey] is changed.
/// {@endtemplate}
/// ///
/// The [Navigator] is only built if [onGenerateRoute] is not null; if it is /// The [Navigator] is only built if [onGenerateRoute] is not null; if it is
/// null, [navigatorObservers] must be left to its default value, the empty /// null, [navigatorObservers] must be left to its default value, the empty
/// list. /// list.
final List<NavigatorObserver> navigatorObservers; final List<NavigatorObserver> navigatorObservers;
/// {@template flutter.widgets.widgetsApp.builder}
/// A builder for inserting widgets above the [Navigator] but below the other /// A builder for inserting widgets above the [Navigator] but below the other
/// widgets created by the [WidgetsApp] widget, or for replacing the /// widgets created by the [WidgetsApp] widget, or for replacing the
/// [Navigator] entirely. /// [Navigator] entirely.
...@@ -200,8 +209,12 @@ class WidgetsApp extends StatefulWidget { ...@@ -200,8 +209,12 @@ class WidgetsApp extends StatefulWidget {
/// mode despite being in English, or to override the [MediaQuery] metrics /// mode despite being in English, or to override the [MediaQuery] metrics
/// (e.g. to leave a gap for advertisements shown by a plugin from OEM code). /// (e.g. to leave a gap for advertisements shown by a plugin from OEM code).
/// ///
/// For specifically overriding the [title] with a value based on the
/// [Localizations], consider [onGenerateTitle] instead.
///
/// The [builder] callback is passed two arguments, the [BuildContext] (as /// The [builder] callback is passed two arguments, the [BuildContext] (as
/// `context`) and a [Navigator] widget (as `child`). /// `context`) and a [Navigator] widget (as `child`).
/// {@endtemplate}
/// ///
/// If [onGenerateRoute] is null, the `child` will be null, and it is the /// If [onGenerateRoute] is null, the `child` will be null, and it is the
/// responsibility of the [builder] to provide the application's routing /// responsibility of the [builder] to provide the application's routing
...@@ -216,11 +229,9 @@ class WidgetsApp extends StatefulWidget { ...@@ -216,11 +229,9 @@ class WidgetsApp extends StatefulWidget {
/// If [builder] is null, it is as if a builder was specified that returned /// If [builder] is null, it is as if a builder was specified that returned
/// the `child` directly. At least one of either [onGenerateRoute] or /// the `child` directly. At least one of either [onGenerateRoute] or
/// [builder] must be non-null. /// [builder] must be non-null.
///
/// For specifically overriding the [title] with a value based on the
/// [Localizations], consider [onGenerateTitle] instead.
final TransitionBuilder builder; final TransitionBuilder builder;
/// {@template flutter.widgets.widgetsApp.title}
/// A one-line description used by the device to identify the app for the user. /// A one-line description used by the device to identify the app for the user.
/// ///
/// On Android the titles appear above the task manager's app snapshots which are /// On Android the titles appear above the task manager's app snapshots which are
...@@ -229,8 +240,10 @@ class WidgetsApp extends StatefulWidget { ...@@ -229,8 +240,10 @@ class WidgetsApp extends StatefulWidget {
/// home button. /// home button.
/// ///
/// To provide a localized title instead, use [onGenerateTitle]. /// To provide a localized title instead, use [onGenerateTitle].
/// {@endtemplate}
final String title; final String title;
/// {@template flutter.widgets.widgetsApp.onGenerateTitle}
/// If non-null this callback function is called to produce the app's /// If non-null this callback function is called to produce the app's
/// title string, otherwise [title] is used. /// title string, otherwise [title] is used.
/// ///
...@@ -242,29 +255,37 @@ class WidgetsApp extends StatefulWidget { ...@@ -242,29 +255,37 @@ class WidgetsApp extends StatefulWidget {
/// ///
/// The [onGenerateTitle] callback is called each time the [WidgetsApp] /// The [onGenerateTitle] callback is called each time the [WidgetsApp]
/// rebuilds. /// rebuilds.
/// {@endtemplate}
final GenerateAppTitle onGenerateTitle; final GenerateAppTitle onGenerateTitle;
/// The default text style for [Text] in the application. /// The default text style for [Text] in the application.
final TextStyle textStyle; final TextStyle textStyle;
/// {@template flutter.widgets.widgetsApp.color}
/// The primary color to use for the application in the operating system /// The primary color to use for the application in the operating system
/// interface. /// interface.
/// ///
/// For example, on Android this is the color used for the application in the /// For example, on Android this is the color used for the application in the
/// application switcher. /// application switcher.
/// {@endtemplate}
final Color color; final Color color;
/// {@template flutter.widgets.widgetsApp.locale}
/// The initial locale for this app's [Localizations] widget. /// The initial locale for this app's [Localizations] widget.
/// ///
/// If the 'locale' is null the system's locale value is used. /// If the 'locale' is null the system's locale value is used.
/// {@endtemplate}
final Locale locale; final Locale locale;
/// {@template flutter.widgets.widgetsApp.localizationsDelegates}
/// The delegates for this app's [Localizations] widget. /// The delegates for this app's [Localizations] widget.
/// ///
/// The delegates collectively define all of the localized resources /// The delegates collectively define all of the localized resources
/// for this application's [Localizations] widget. /// for this application's [Localizations] widget.
/// {@endtemplate}
final Iterable<LocalizationsDelegate<dynamic>> localizationsDelegates; final Iterable<LocalizationsDelegate<dynamic>> localizationsDelegates;
/// {@template flutter.widgets.widgetsApp.localeResolutionCallback}
/// This callback is responsible for choosing the app's locale /// This callback is responsible for choosing the app's locale
/// when the app is started, and when the user changes the /// when the app is started, and when the user changes the
/// device's locale. /// device's locale.
...@@ -281,6 +302,7 @@ class WidgetsApp extends StatefulWidget { ...@@ -281,6 +302,7 @@ class WidgetsApp extends StatefulWidget {
/// - The first supported locale with the same [Locale.languageCode] as the /// - The first supported locale with the same [Locale.languageCode] as the
/// callback's `locale` parameter. /// callback's `locale` parameter.
/// - The first locale in [supportedLocales]. /// - The first locale in [supportedLocales].
/// {@endtemplate}
/// ///
/// See also: /// See also:
/// ///
...@@ -288,6 +310,7 @@ class WidgetsApp extends StatefulWidget { ...@@ -288,6 +310,7 @@ class WidgetsApp extends StatefulWidget {
/// [WidgetsApp] it creates. /// [WidgetsApp] it creates.
final LocaleResolutionCallback localeResolutionCallback; final LocaleResolutionCallback localeResolutionCallback;
/// {@template flutter.widgets.widgetsApp.supportedLocales}
/// The list of locales that this app has been localized for. /// The list of locales that this app has been localized for.
/// ///
/// By default only the American English locale is supported. Apps should /// By default only the American English locale is supported. Apps should
...@@ -301,6 +324,7 @@ class WidgetsApp extends StatefulWidget { ...@@ -301,6 +324,7 @@ class WidgetsApp extends StatefulWidget {
/// [supportedLocales] with a matching [Locale.languageCode] is used. If that /// [supportedLocales] with a matching [Locale.languageCode] is used. If that
/// fails then the first locale in [supportedLocales] is used. The default /// fails then the first locale in [supportedLocales] is used. The default
/// locale resolution algorithm can be overridden with [localeResolutionCallback]. /// locale resolution algorithm can be overridden with [localeResolutionCallback].
/// {@endtemplate}
/// ///
/// See also: /// See also:
/// ///
...@@ -315,7 +339,10 @@ class WidgetsApp extends StatefulWidget { ...@@ -315,7 +339,10 @@ class WidgetsApp extends StatefulWidget {
final Iterable<Locale> supportedLocales; final Iterable<Locale> supportedLocales;
/// Turns on a performance overlay. /// Turns on a performance overlay.
/// https://flutter.io/debugging/#performanceoverlay ///
/// See also:
///
/// * <https://flutter.io/debugging/#performanceoverlay>
final bool showPerformanceOverlay; final bool showPerformanceOverlay;
/// Checkerboards raster cache images. /// Checkerboards raster cache images.
...@@ -347,7 +374,8 @@ class WidgetsApp extends StatefulWidget { ...@@ -347,7 +374,8 @@ class WidgetsApp extends StatefulWidget {
/// material package. /// material package.
final InspectorSelectButtonBuilder inspectorSelectButtonBuilder; final InspectorSelectButtonBuilder inspectorSelectButtonBuilder;
/// Turns on a "DEBUG" little banner in checked mode to indicate /// {@template flutter.widgets.widgetsApp.debugShowCheckedModeBanner}
/// Turns on a little "DEBUG" banner in checked mode to indicate
/// that the app is in checked mode. This is on by default (in /// that the app is in checked mode. This is on by default (in
/// checked mode), to turn it off, set the constructor argument to /// checked mode), to turn it off, set the constructor argument to
/// false. In release mode this has no effect. /// false. In release mode this has no effect.
...@@ -355,11 +383,12 @@ class WidgetsApp extends StatefulWidget { ...@@ -355,11 +383,12 @@ class WidgetsApp extends StatefulWidget {
/// To get this banner in your application if you're not using /// To get this banner in your application if you're not using
/// WidgetsApp, include a [CheckedModeBanner] widget in your app. /// WidgetsApp, include a [CheckedModeBanner] widget in your app.
/// ///
/// This banner is intended to avoid people complaining that your /// This banner is intended to deter people from complaining that your
/// app is slow when it's in checked mode. In checked mode, Flutter /// app is slow when it's in checked mode. In checked mode, Flutter
/// enables a large number of expensive diagnostics to aid in /// enables a large number of expensive diagnostics to aid in
/// development, and so performance in checked mode is not /// development, and so performance in checked mode is not
/// representative of what will happen in release mode. /// representative of what will happen in release mode.
/// {@endtemplate}
final bool debugShowCheckedModeBanner; final bool debugShowCheckedModeBanner;
/// If true, forces the performance overlay to be visible in all instances. /// If true, forces the performance overlay to be visible in all instances.
......
...@@ -8,8 +8,7 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -8,8 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() { void main() {
testWidgets('test iOS page transition (LTR)', (WidgetTester tester) async { testWidgets('test iOS page transition (LTR)', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new WidgetsApp( new CupertinoApp(
color: const Color(0xFFFFFFFF),
onGenerateRoute: (RouteSettings settings) { onGenerateRoute: (RouteSettings settings) {
return new CupertinoPageRoute<void>( return new CupertinoPageRoute<void>(
settings: settings, settings: settings,
...@@ -76,11 +75,10 @@ void main() { ...@@ -76,11 +75,10 @@ void main() {
testWidgets('test iOS page transition (RTL)', (WidgetTester tester) async { testWidgets('test iOS page transition (RTL)', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new WidgetsApp( new CupertinoApp(
localizationsDelegates: const <LocalizationsDelegate<dynamic>>[ localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
const RtlOverrideWidgetsDelegate(), const RtlOverrideWidgetsDelegate(),
], ],
color: const Color(0xFFFFFFFF),
onGenerateRoute: (RouteSettings settings) { onGenerateRoute: (RouteSettings settings) {
return new CupertinoPageRoute<void>( return new CupertinoPageRoute<void>(
settings: settings, settings: settings,
...@@ -148,16 +146,8 @@ void main() { ...@@ -148,16 +146,8 @@ void main() {
testWidgets('test iOS fullscreen dialog transition', (WidgetTester tester) async { testWidgets('test iOS fullscreen dialog transition', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new WidgetsApp( new CupertinoApp(
color: const Color(0xFFFFFFFF), home: const Center(child: const Text('Page 1')),
onGenerateRoute: (RouteSettings settings) {
return new CupertinoPageRoute<void>(
settings: settings,
builder: (BuildContext context) {
return const Center(child: const Text('Page 1'));
}
);
},
), ),
); );
...@@ -216,8 +206,7 @@ void main() { ...@@ -216,8 +206,7 @@ void main() {
testWidgets('test only edge swipes work (LTR)', (WidgetTester tester) async { testWidgets('test only edge swipes work (LTR)', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new WidgetsApp( new CupertinoApp(
color: const Color(0xFFFFFFFF),
onGenerateRoute: (RouteSettings settings) { onGenerateRoute: (RouteSettings settings) {
return new CupertinoPageRoute<void>( return new CupertinoPageRoute<void>(
settings: settings, settings: settings,
...@@ -278,11 +267,10 @@ void main() { ...@@ -278,11 +267,10 @@ void main() {
testWidgets('test only edge swipes work (RTL)', (WidgetTester tester) async { testWidgets('test only edge swipes work (RTL)', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new WidgetsApp( new CupertinoApp(
localizationsDelegates: const <LocalizationsDelegate<dynamic>>[ localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
const RtlOverrideWidgetsDelegate(), const RtlOverrideWidgetsDelegate(),
], ],
color: const Color(0xFFFFFFFF),
onGenerateRoute: (RouteSettings settings) { onGenerateRoute: (RouteSettings settings) {
return new CupertinoPageRoute<void>( return new CupertinoPageRoute<void>(
settings: settings, settings: settings,
......
...@@ -20,26 +20,18 @@ void main() { ...@@ -20,26 +20,18 @@ void main() {
final List<int> tabsPainted = <int>[]; final List<int> tabsPainted = <int>[];
await tester.pumpWidget( await tester.pumpWidget(
new WidgetsApp( new CupertinoApp(
color: const Color(0xFFFFFFFF), home: new CupertinoTabScaffold(
onGenerateRoute: (RouteSettings settings) { tabBar: _buildTabBar(),
return new CupertinoPageRoute<void>( tabBuilder: (BuildContext context, int index) {
settings: settings, return new CustomPaint(
builder: (BuildContext context) { child: new Text('Page ${index + 1}'),
return new CupertinoTabScaffold( painter: new TestCallbackPainter(
tabBar: _buildTabBar(), onPaint: () { tabsPainted.add(index); }
tabBuilder: (BuildContext context, int index) { )
return new CustomPaint( );
child: new Text('Page ${index + 1}'), },
painter: new TestCallbackPainter( ),
onPaint: () { tabsPainted.add(index); }
)
);
},
);
},
);
},
), ),
); );
...@@ -82,22 +74,14 @@ void main() { ...@@ -82,22 +74,14 @@ void main() {
final List<int> tabsBuilt = <int>[]; final List<int> tabsBuilt = <int>[];
await tester.pumpWidget( await tester.pumpWidget(
new WidgetsApp( new CupertinoApp(
color: const Color(0xFFFFFFFF), home: new CupertinoTabScaffold(
onGenerateRoute: (RouteSettings settings) { tabBar: _buildTabBar(),
return new CupertinoPageRoute<void>( tabBuilder: (BuildContext context, int index) {
settings: settings, tabsBuilt.add(index);
builder: (BuildContext context) { return new Text('Page ${index + 1}');
return new CupertinoTabScaffold( },
tabBar: _buildTabBar(), ),
tabBuilder: (BuildContext context, int index) {
tabsBuilt.add(index);
return new Text('Page ${index + 1}');
},
);
},
);
},
), ),
); );
...@@ -126,26 +110,18 @@ void main() { ...@@ -126,26 +110,18 @@ void main() {
final List<FocusNode> focusNodes = <FocusNode>[new FocusNode(), new FocusNode()]; final List<FocusNode> focusNodes = <FocusNode>[new FocusNode(), new FocusNode()];
await tester.pumpWidget( await tester.pumpWidget(
new WidgetsApp( new CupertinoApp(
color: const Color(0xFFFFFFFF), home: new Material(
onGenerateRoute: (RouteSettings settings) { child: new CupertinoTabScaffold(
return new CupertinoPageRoute<void>( tabBar: _buildTabBar(),
settings: settings, tabBuilder: (BuildContext context, int index) {
builder: (BuildContext context) { return new TextField(
return new Material( focusNode: focusNodes[index],
child: new CupertinoTabScaffold( autofocus: true,
tabBar: _buildTabBar(),
tabBuilder: (BuildContext context, int index) {
return new TextField(
focusNode: focusNodes[index],
autofocus: true,
);
},
),
); );
}, },
); ),
}, ),
), ),
); );
...@@ -170,38 +146,30 @@ void main() { ...@@ -170,38 +146,30 @@ void main() {
]; ];
await tester.pumpWidget( await tester.pumpWidget(
new WidgetsApp( new CupertinoApp(
color: const Color(0xFFFFFFFF), home: new Material(
onGenerateRoute: (RouteSettings settings) { child: new CupertinoTabScaffold(
return new CupertinoPageRoute<void>( tabBar: _buildTabBar(),
settings: settings, tabBuilder: (BuildContext context, int index) {
builder: (BuildContext context) { return new Column(
return new Material( children: <Widget>[
child: new CupertinoTabScaffold( new TextField(
tabBar: _buildTabBar(), focusNode: focusNodes[index * 2],
tabBuilder: (BuildContext context, int index) { decoration: const InputDecoration(
return new Column( hintText: 'TextField 1',
children: <Widget>[ ),
new TextField( ),
focusNode: focusNodes[index * 2], new TextField(
decoration: const InputDecoration( focusNode: focusNodes[index * 2 + 1],
hintText: 'TextField 1', decoration: const InputDecoration(
), hintText: 'TextField 2',
), ),
new TextField( ),
focusNode: focusNodes[index * 2 + 1], ],
decoration: const InputDecoration(
hintText: 'TextField 2',
),
),
],
);
},
),
); );
}, },
); ),
}, ),
), ),
); );
...@@ -242,42 +210,36 @@ void main() { ...@@ -242,42 +210,36 @@ void main() {
final List<int> tabsPainted = <int>[]; final List<int> tabsPainted = <int>[];
await tester.pumpWidget( await tester.pumpWidget(
new WidgetsApp( new CupertinoApp(
color: const Color(0xFFFFFFFF), home: new CupertinoTabScaffold(
builder: (BuildContext context, Widget child) { tabBar: _buildTabBar(),
return new CupertinoTabScaffold( tabBuilder: (BuildContext context, int index) {
tabBar: _buildTabBar(), return new CustomPaint(
tabBuilder: (BuildContext context, int index) { child: new Text('Page ${index + 1}'),
return new CustomPaint( painter: new TestCallbackPainter(
child: new Text('Page ${index + 1}'), onPaint: () { tabsPainted.add(index); }
painter: new TestCallbackPainter( )
onPaint: () { tabsPainted.add(index); } );
) },
); ),
},
);
},
), ),
); );
expect(tabsPainted, <int>[0]); expect(tabsPainted, <int>[0]);
await tester.pumpWidget( await tester.pumpWidget(
new WidgetsApp( new CupertinoApp(
color: const Color(0xFFFFFFFF), home: new CupertinoTabScaffold(
builder: (BuildContext context, Widget child) { tabBar: _buildTabBar(selectedTab: 1), // Programmatically change the tab now.
return new CupertinoTabScaffold( tabBuilder: (BuildContext context, int index) {
tabBar: _buildTabBar(selectedTab: 1), // Programmatically change the tab now. return new CustomPaint(
tabBuilder: (BuildContext context, int index) { child: new Text('Page ${index + 1}'),
return new CustomPaint( painter: new TestCallbackPainter(
child: new Text('Page ${index + 1}'), onPaint: () { tabsPainted.add(index); }
painter: new TestCallbackPainter( )
onPaint: () { tabsPainted.add(index); } );
) },
); ),
},
);
},
), ),
); );
......
...@@ -8,18 +8,10 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -8,18 +8,10 @@ import 'package:flutter_test/flutter_test.dart';
void main() { void main() {
testWidgets('Use home', (WidgetTester tester) async { testWidgets('Use home', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new WidgetsApp( new CupertinoApp(
color: const Color(0xFFFFFFFF), home: new CupertinoTabView(
onGenerateRoute: (RouteSettings settings) { builder: (BuildContext context) => const Text('home'),
return new CupertinoPageRoute<void>( ),
settings: settings,
builder: (BuildContext context) {
return new CupertinoTabView(
builder: (BuildContext context) => const Text('home'),
);
},
);
},
), ),
); );
...@@ -28,20 +20,12 @@ void main() { ...@@ -28,20 +20,12 @@ void main() {
testWidgets('Use routes', (WidgetTester tester) async { testWidgets('Use routes', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new WidgetsApp( new CupertinoApp(
color: const Color(0xFFFFFFFF), home: new CupertinoTabView(
onGenerateRoute: (RouteSettings settings) { routes: <String, WidgetBuilder>{
return new CupertinoPageRoute<void>( '/': (BuildContext context) => const Text('first route'),
settings: settings, },
builder: (BuildContext context) { ),
return new CupertinoTabView(
routes: <String, WidgetBuilder>{
'/': (BuildContext context) => const Text('first route'),
},
);
},
);
},
), ),
); );
...@@ -50,28 +34,20 @@ void main() { ...@@ -50,28 +34,20 @@ void main() {
testWidgets('Use home and named routes', (WidgetTester tester) async { testWidgets('Use home and named routes', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new WidgetsApp( new CupertinoApp(
color: const Color(0xFFFFFFFF), home: new CupertinoTabView(
onGenerateRoute: (RouteSettings settings) { builder: (BuildContext context) {
return new CupertinoPageRoute<void>( return new CupertinoButton(
settings: settings, child: const Text('go to second page'),
builder: (BuildContext context) { onPressed: () {
return new CupertinoTabView( Navigator.of(context).pushNamed('/2');
builder: (BuildContext context) { },
return new CupertinoButton( );
child: const Text('go to second page'), },
onPressed: () { routes: <String, WidgetBuilder>{
Navigator.of(context).pushNamed('/2'); '/2': (BuildContext context) => const Text('second named route'),
}, },
); ),
},
routes: <String, WidgetBuilder>{
'/2': (BuildContext context) => const Text('second named route'),
},
);
},
);
},
), ),
); );
...@@ -84,27 +60,19 @@ void main() { ...@@ -84,27 +60,19 @@ void main() {
testWidgets('Use onGenerateRoute', (WidgetTester tester) async { testWidgets('Use onGenerateRoute', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new WidgetsApp( new CupertinoApp(
color: const Color(0xFFFFFFFF), home: new CupertinoTabView(
onGenerateRoute: (RouteSettings settings) { onGenerateRoute: (RouteSettings settings) {
return new CupertinoPageRoute<void>( if (settings.name == Navigator.defaultRouteName) {
settings: settings, return new CupertinoPageRoute<void>(
builder: (BuildContext context) { settings: settings,
return new CupertinoTabView( builder: (BuildContext context) {
onGenerateRoute: (RouteSettings settings) { return const Text('generated home');
if (settings.name == Navigator.defaultRouteName) { }
return new CupertinoPageRoute<void>(
settings: settings,
builder: (BuildContext context) {
return const Text('generated home');
}
);
}
},
); );
}, }
); },
}, ),
), ),
); );
...@@ -114,20 +82,12 @@ void main() { ...@@ -114,20 +82,12 @@ void main() {
testWidgets('Use onUnknownRoute', (WidgetTester tester) async { testWidgets('Use onUnknownRoute', (WidgetTester tester) async {
String unknownForRouteCalled; String unknownForRouteCalled;
await tester.pumpWidget( await tester.pumpWidget(
new WidgetsApp( new CupertinoApp(
color: const Color(0xFFFFFFFF), home: new CupertinoTabView(
onGenerateRoute: (RouteSettings settings) { onUnknownRoute: (RouteSettings settings) {
return new CupertinoPageRoute<void>( unknownForRouteCalled = settings.name;
settings: settings, },
builder: (BuildContext context) { ),
return new CupertinoTabView(
onUnknownRoute: (RouteSettings settings) {
unknownForRouteCalled = settings.name;
},
);
},
);
},
), ),
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment