diff --git a/examples/api/lib/cupertino/bottom_tab_bar/bottom_tab_bar.0.dart b/examples/api/lib/cupertino/bottom_tab_bar/cupertino_tab_bar.0.dart similarity index 52% rename from examples/api/lib/cupertino/bottom_tab_bar/bottom_tab_bar.0.dart rename to examples/api/lib/cupertino/bottom_tab_bar/cupertino_tab_bar.0.dart index fdbfc8dff1..88abfdfcca 100644 --- a/examples/api/lib/cupertino/bottom_tab_bar/bottom_tab_bar.0.dart +++ b/examples/api/lib/cupertino/bottom_tab_bar/cupertino_tab_bar.0.dart @@ -6,42 +6,43 @@ import 'package:flutter/cupertino.dart'; -void main() => runApp(const MyApp()); +void main() => runApp(const CupertinoTabBarApp()); -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Flutter Code Sample'; +class CupertinoTabBarApp extends StatelessWidget { + const CupertinoTabBarApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const CupertinoApp( - title: _title, - home: MyStatefulWidget(), + theme: CupertinoThemeData(brightness: Brightness.light), + home: CupertinoTabBarExample(), ); } } -class MyStatefulWidget extends StatefulWidget { - const MyStatefulWidget({Key? key}) : super(key: key); +class CupertinoTabBarExample extends StatelessWidget { + const CupertinoTabBarExample({Key? key}) : super(key: key); - @override - State createState() => _MyStatefulWidgetState(); -} - -class _MyStatefulWidgetState extends State { @override Widget build(BuildContext context) { return CupertinoTabScaffold( tabBar: CupertinoTabBar( items: const [ BottomNavigationBarItem( - icon: Icon(CupertinoIcons.circle), - label: 'Tab 1', + icon: Icon(CupertinoIcons.star_fill), + label: 'Favourites', ), BottomNavigationBarItem( - icon: Icon(CupertinoIcons.add), - label: 'Tab 2', + icon: Icon(CupertinoIcons.clock_solid), + label: 'Recents', + ), + BottomNavigationBarItem( + icon: Icon(CupertinoIcons.person_alt_circle_fill), + label: 'Contacts', + ), + BottomNavigationBarItem( + icon: Icon(CupertinoIcons.circle_grid_3x3_fill), + label: 'Keypad', ), ], ), diff --git a/examples/api/lib/cupertino/button/cupertino_button.0.dart b/examples/api/lib/cupertino/button/cupertino_button.0.dart index 6b82b26e39..00062ec8df 100644 --- a/examples/api/lib/cupertino/button/cupertino_button.0.dart +++ b/examples/api/lib/cupertino/button/cupertino_button.0.dart @@ -6,51 +6,51 @@ import 'package:flutter/cupertino.dart'; -void main() => runApp(const MyApp()); +void main() => runApp(const CupertinoButtonApp()); -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Flutter Code Sample'; +class CupertinoButtonApp extends StatelessWidget { + const CupertinoButtonApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const CupertinoApp( - title: _title, - home: MyStatelessWidget(), + theme: CupertinoThemeData(brightness: Brightness.light), + home: CupertinoButtonExample(), ); } } -class MyStatelessWidget extends StatelessWidget { - const MyStatelessWidget({Key? key}) : super(key: key); +class CupertinoButtonExample extends StatelessWidget { + const CupertinoButtonExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { - return Center( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - const CupertinoButton( - onPressed: null, - child: Text('Disabled'), - ), - const SizedBox(height: 30), - const CupertinoButton.filled( - onPressed: null, - child: Text('Disabled'), - ), - const SizedBox(height: 30), - CupertinoButton( - onPressed: () {}, - child: const Text('Enabled'), - ), - const SizedBox(height: 30), - CupertinoButton.filled( - onPressed: () {}, - child: const Text('Enabled'), - ), - ], + return CupertinoPageScaffold( + child: Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const CupertinoButton( + onPressed: null, + child: Text('Disabled'), + ), + const SizedBox(height: 30), + const CupertinoButton.filled( + onPressed: null, + child: Text('Disabled'), + ), + const SizedBox(height: 30), + CupertinoButton( + onPressed: () {}, + child: const Text('Enabled'), + ), + const SizedBox(height: 30), + CupertinoButton.filled( + onPressed: () {}, + child: const Text('Enabled'), + ), + ], + ), ), ); } diff --git a/examples/api/lib/cupertino/date_picker/cupertino_date_picker.0.dart b/examples/api/lib/cupertino/date_picker/cupertino_date_picker.0.dart index 2763ae2408..1f7e487389 100644 --- a/examples/api/lib/cupertino/date_picker/cupertino_date_picker.0.dart +++ b/examples/api/lib/cupertino/date_picker/cupertino_date_picker.0.dart @@ -6,30 +6,28 @@ import 'package:flutter/cupertino.dart'; -void main() => runApp(const MyApp()); +void main() => runApp(const DatePickerApp()); -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Flutter Code Sample'; +class DatePickerApp extends StatelessWidget { + const DatePickerApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const CupertinoApp( - title: _title, - home: MyStatelessWidget(), + theme: CupertinoThemeData(brightness: Brightness.light), + home: DatePickerExample(), ); } } -class MyStatelessWidget extends StatefulWidget { - const MyStatelessWidget({Key? key}) : super(key: key); +class DatePickerExample extends StatefulWidget { + const DatePickerExample({Key? key}) : super(key: key); @override - State createState() => _MyStatelessWidgetState(); + State createState() => _DatePickerExampleState(); } -class _MyStatelessWidgetState extends State { +class _DatePickerExampleState extends State { DateTime date = DateTime(2016, 10, 26); DateTime time = DateTime(2016, 5, 10, 22, 35); DateTime dateTime = DateTime(2016, 8, 3, 17, 45); diff --git a/examples/api/lib/cupertino/date_picker/cupertino_timer_picker.0.dart b/examples/api/lib/cupertino/date_picker/cupertino_timer_picker.0.dart index 69b660fc2a..847b8b7ebb 100644 --- a/examples/api/lib/cupertino/date_picker/cupertino_timer_picker.0.dart +++ b/examples/api/lib/cupertino/date_picker/cupertino_timer_picker.0.dart @@ -6,30 +6,28 @@ import 'package:flutter/cupertino.dart'; -void main() => runApp(const MyApp()); +void main() => runApp(const TimerPickerApp()); -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'CupertinoTimerPicker Sample'; +class TimerPickerApp extends StatelessWidget { + const TimerPickerApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const CupertinoApp( - title: _title, - home: CupertinoTimerPickerSample(), + theme: CupertinoThemeData(brightness: Brightness.light), + home: TimerPickerExample(), ); } } -class CupertinoTimerPickerSample extends StatefulWidget { - const CupertinoTimerPickerSample({Key? key}) : super(key: key); +class TimerPickerExample extends StatefulWidget { + const TimerPickerExample({Key? key}) : super(key: key); @override - State createState() => _CupertinoTimerPickerSampleState(); + State createState() => _TimerPickerExampleState(); } -class _CupertinoTimerPickerSampleState extends State { +class _TimerPickerExampleState extends State { Duration duration = const Duration(hours: 1, minutes: 23); // This shows a CupertinoModalPopup with a reasonable fixed height which hosts CupertinoTimerPicker. diff --git a/examples/api/lib/cupertino/dialog/cupertino_action_sheet.0.dart b/examples/api/lib/cupertino/dialog/cupertino_action_sheet.0.dart index 4f51d92e03..ed761241a8 100644 --- a/examples/api/lib/cupertino/dialog/cupertino_action_sheet.0.dart +++ b/examples/api/lib/cupertino/dialog/cupertino_action_sheet.0.dart @@ -6,26 +6,22 @@ import 'package:flutter/cupertino.dart'; -void main() => runApp(const MyApp()); +void main() => runApp(const ActionSheetApp()); -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'CupertinoActionSheet Sample'; +class ActionSheetApp extends StatelessWidget { + const ActionSheetApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const CupertinoApp( - title: _title, - home: ActionSheetSample(title: _title), + theme: CupertinoThemeData(brightness: Brightness.light), + home: ActionSheetExample(), ); } } -class ActionSheetSample extends StatelessWidget { - const ActionSheetSample({Key? key, required this.title}) : super(key: key); - - final String title; +class ActionSheetExample extends StatelessWidget { + const ActionSheetExample({Key? key}) : super(key: key); // This shows a CupertinoModalPopup which hosts a CupertinoActionSheet. void _showActionSheet(BuildContext context) { @@ -68,8 +64,8 @@ class ActionSheetSample extends StatelessWidget { @override Widget build(BuildContext context) { return CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar( - middle: Text(title), + navigationBar: const CupertinoNavigationBar( + middle: Text('CupertinoActionSheet Sample'), ), child: Center( child: CupertinoButton( diff --git a/examples/api/lib/cupertino/dialog/cupertino_alert_dialog.0.dart b/examples/api/lib/cupertino/dialog/cupertino_alert_dialog.0.dart index cca1cf64f3..9c0ab10a53 100644 --- a/examples/api/lib/cupertino/dialog/cupertino_alert_dialog.0.dart +++ b/examples/api/lib/cupertino/dialog/cupertino_alert_dialog.0.dart @@ -6,26 +6,22 @@ import 'package:flutter/cupertino.dart'; -void main() => runApp(const MyApp()); +void main() => runApp(const AlertDialogApp()); -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'CupertinoAlertDialog Sample'; +class AlertDialogApp extends StatelessWidget { + const AlertDialogApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const CupertinoApp( - title: _title, - home: ActionSheetSample(title: _title), + theme: CupertinoThemeData(brightness: Brightness.light), + home: AlertDialogExample(), ); } } -class ActionSheetSample extends StatelessWidget { - const ActionSheetSample({Key? key, required this.title}) : super(key: key); - - final String title; +class AlertDialogExample extends StatelessWidget { + const AlertDialogExample({Key? key}) : super(key: key); // This shows a CupertinoModalPopup which hosts a CupertinoAlertDialog. void _showAlertDialog(BuildContext context) { @@ -62,8 +58,8 @@ class ActionSheetSample extends StatelessWidget { @override Widget build(BuildContext context) { return CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar( - middle: Text(title), + navigationBar: const CupertinoNavigationBar( + middle: Text('CupertinoAlertDialog Sample'), ), child: Center( child: CupertinoButton( diff --git a/examples/api/lib/cupertino/nav_bar/cupertino_navigation_bar.0.dart b/examples/api/lib/cupertino/nav_bar/cupertino_navigation_bar.0.dart index 5b6f7474b8..9266298f0e 100644 --- a/examples/api/lib/cupertino/nav_bar/cupertino_navigation_bar.0.dart +++ b/examples/api/lib/cupertino/nav_bar/cupertino_navigation_bar.0.dart @@ -6,37 +6,35 @@ import 'package:flutter/cupertino.dart'; -void main() => runApp(const MyApp()); +void main() => runApp(const NavBarApp()); -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Flutter Code Sample'; +class NavBarApp extends StatelessWidget { + const NavBarApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const CupertinoApp( - title: _title, - home: MyStatefulWidget(), + theme: CupertinoThemeData(brightness: Brightness.light), + home: NavBarExample(), ); } } -class MyStatefulWidget extends StatefulWidget { - const MyStatefulWidget({Key? key}) : super(key: key); +class NavBarExample extends StatefulWidget { + const NavBarExample({Key? key}) : super(key: key); @override - State createState() => _MyStatefulWidgetState(); + State createState() => _NavBarExampleState(); } -class _MyStatefulWidgetState extends State { +class _NavBarExampleState extends State { @override Widget build(BuildContext context) { return CupertinoPageScaffold( navigationBar: CupertinoNavigationBar( // Try removing opacity to observe the lack of a blur effect and of sliding content. backgroundColor: CupertinoColors.systemGrey.withOpacity(0.5), - middle: const Text('Sample Code'), + middle: const Text('CupertinoNavigationBar Sample'), ), child: Column( children: [ diff --git a/examples/api/lib/cupertino/nav_bar/cupertino_sliver_nav_bar.0.dart b/examples/api/lib/cupertino/nav_bar/cupertino_sliver_nav_bar.0.dart index 1db77aa4e9..5d8fa0e65a 100644 --- a/examples/api/lib/cupertino/nav_bar/cupertino_sliver_nav_bar.0.dart +++ b/examples/api/lib/cupertino/nav_bar/cupertino_sliver_nav_bar.0.dart @@ -6,24 +6,22 @@ import 'package:flutter/cupertino.dart'; -void main() => runApp(const MyApp()); +void main() => runApp(const SliverNavBarApp()); -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'CupertinoSliverNavigationBar Sample'; +class SliverNavBarApp extends StatelessWidget { + const SliverNavBarApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const CupertinoApp( - title: _title, - home: CupertinoNavBarSample(), + theme: CupertinoThemeData(brightness: Brightness.light), + home: SliverNavBarExample(), ); } } -class CupertinoNavBarSample extends StatelessWidget { - const CupertinoNavBarSample({Key? key}) : super(key: key); +class SliverNavBarExample extends StatelessWidget { + const SliverNavBarExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/examples/api/lib/cupertino/picker/cupertino_picker.0.dart b/examples/api/lib/cupertino/picker/cupertino_picker.0.dart index d1631638a4..9cf453bbfa 100644 --- a/examples/api/lib/cupertino/picker/cupertino_picker.0.dart +++ b/examples/api/lib/cupertino/picker/cupertino_picker.0.dart @@ -16,30 +16,27 @@ const List _fruitNames = [ 'Strawberry', ]; -void main() => runApp(const MyApp()); +void main() => runApp(const CupertinoPickerApp()); -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Flutter Code Sample'; +class CupertinoPickerApp extends StatelessWidget { + const CupertinoPickerApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const CupertinoApp( - title: _title, - home: CupertinoPickerSample(), + theme: CupertinoThemeData(brightness: Brightness.light), + home: CupertinoPickerExample(), ); } } - -class CupertinoPickerSample extends StatefulWidget { - const CupertinoPickerSample({Key? key}) : super(key: key); +class CupertinoPickerExample extends StatefulWidget { + const CupertinoPickerExample({Key? key}) : super(key: key); @override - State createState() => _CupertinoPickerSampleState(); + State createState() => _CupertinoPickerExampleState(); } -class _CupertinoPickerSampleState extends State { +class _CupertinoPickerExampleState extends State { int _selectedFruit = 0; // This shows a CupertinoModalPopup with a reasonable fixed height which hosts CupertinoPicker. diff --git a/examples/api/lib/cupertino/segmented_control/cupertino_segmented_control.0.dart b/examples/api/lib/cupertino/segmented_control/cupertino_segmented_control.0.dart index e4ae9f8231..99378bf043 100644 --- a/examples/api/lib/cupertino/segmented_control/cupertino_segmented_control.0.dart +++ b/examples/api/lib/cupertino/segmented_control/cupertino_segmented_control.0.dart @@ -14,30 +14,28 @@ Map skyColors = { Sky.cerulean: const Color(0xff007ba7), }; -void main() => runApp(const MyApp()); +void main() => runApp(const SegmentControlApp()); -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'CupertinoSegmentedControl Sample'; +class SegmentControlApp extends StatelessWidget { + const SegmentControlApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const CupertinoApp( - title: _title, - home: SegmentedControlSample(), + theme: CupertinoThemeData(brightness: Brightness.light), + home: SegmentedControlExample(), ); } } -class SegmentedControlSample extends StatefulWidget { - const SegmentedControlSample({Key? key}) : super(key: key); +class SegmentedControlExample extends StatefulWidget { + const SegmentedControlExample({Key? key}) : super(key: key); @override - State createState() => _SegmentedControlSampleState(); + State createState() => _SegmentedControlExampleState(); } -class _SegmentedControlSampleState extends State { +class _SegmentedControlExampleState extends State { Sky _selectedSegment = Sky.midnight; @override @@ -61,24 +59,15 @@ class _SegmentedControlSampleState extends State { children: const { Sky.midnight: Padding( padding: EdgeInsets.symmetric(horizontal: 20), - child: Text( - 'Midnight', - style: TextStyle(color: CupertinoColors.white), - ), + child: Text('Midnight'), ), Sky.viridian: Padding( padding: EdgeInsets.symmetric(horizontal: 20), - child: Text( - 'Viridian', - style: TextStyle(color: CupertinoColors.white), - ), + child: Text('Viridian'), ), Sky.cerulean: Padding( padding: EdgeInsets.symmetric(horizontal: 20), - child: Text( - 'Cerulean', - style: TextStyle(color: CupertinoColors.white), - ), + child: Text('Cerulean'), ), }, ), diff --git a/examples/api/lib/cupertino/segmented_control/cupertino_sliding_segmented_control.0.dart b/examples/api/lib/cupertino/segmented_control/cupertino_sliding_segmented_control.0.dart index f2db3c8bf8..90e938f258 100644 --- a/examples/api/lib/cupertino/segmented_control/cupertino_sliding_segmented_control.0.dart +++ b/examples/api/lib/cupertino/segmented_control/cupertino_sliding_segmented_control.0.dart @@ -14,30 +14,28 @@ Map skyColors = { Sky.cerulean: const Color(0xff007ba7), }; -void main() => runApp(const MyApp()); +void main() => runApp(const SegmentControlApp()); -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'CupertinoSlidingSegmentedControl Sample'; +class SegmentControlApp extends StatelessWidget { + const SegmentControlApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const CupertinoApp( - title: _title, - home: SegmentedControlSample(), + theme: CupertinoThemeData(brightness: Brightness.light), + home: SegmentedControlExample(), ); } } -class SegmentedControlSample extends StatefulWidget { - const SegmentedControlSample({Key? key}) : super(key: key); +class SegmentedControlExample extends StatefulWidget { + const SegmentedControlExample({Key? key}) : super(key: key); @override - State createState() => _SegmentedControlSampleState(); + State createState() => _SegmentedControlExampleState(); } -class _SegmentedControlSampleState extends State { +class _SegmentedControlExampleState extends State { Sky _selectedSegment = Sky.midnight; @override diff --git a/examples/api/lib/cupertino/slider/cupertino_slider.0.dart b/examples/api/lib/cupertino/slider/cupertino_slider.0.dart index 311f500841..9c0abdb2d3 100644 --- a/examples/api/lib/cupertino/slider/cupertino_slider.0.dart +++ b/examples/api/lib/cupertino/slider/cupertino_slider.0.dart @@ -6,30 +6,28 @@ import 'package:flutter/cupertino.dart'; -void main() => runApp(const MyApp()); +void main() => runApp(const CupertinoSliderApp()); -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Flutter Code Sample'; +class CupertinoSliderApp extends StatelessWidget { + const CupertinoSliderApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const CupertinoApp( - title: _title, - home: CupertinoSliderSample(), + theme: CupertinoThemeData(brightness: Brightness.light), + home: CupertinoSliderExample(), ); } } -class CupertinoSliderSample extends StatefulWidget { - const CupertinoSliderSample({Key? key}) : super(key: key); +class CupertinoSliderExample extends StatefulWidget { + const CupertinoSliderExample({Key? key}) : super(key: key); @override - State createState() => _CupertinoSliderSampleState(); + State createState() => _CupertinoSliderExampleState(); } -class _CupertinoSliderSampleState extends State { +class _CupertinoSliderExampleState extends State { double _currentSliderValue = 0.0; String? _sliderStatus; diff --git a/examples/api/lib/cupertino/text_field/cupertino_text_field.0.dart b/examples/api/lib/cupertino/text_field/cupertino_text_field.0.dart index 30d0e6fa23..50d734746f 100644 --- a/examples/api/lib/cupertino/text_field/cupertino_text_field.0.dart +++ b/examples/api/lib/cupertino/text_field/cupertino_text_field.0.dart @@ -6,30 +6,28 @@ import 'package:flutter/cupertino.dart'; -void main() => runApp(const MyApp()); +void main() => runApp(const CupertinoTextFieldApp()); -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - static const String _title = 'Flutter Code Sample'; +class CupertinoTextFieldApp extends StatelessWidget { + const CupertinoTextFieldApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const CupertinoApp( - title: _title, - home: MyStatefulWidget(), + theme: CupertinoThemeData(brightness: Brightness.light), + home: CupertinoTextFieldExample(), ); } } -class MyStatefulWidget extends StatefulWidget { - const MyStatefulWidget({Key? key}) : super(key: key); +class CupertinoTextFieldExample extends StatefulWidget { + const CupertinoTextFieldExample({Key? key}) : super(key: key); @override - State createState() => _MyStatefulWidgetState(); + State createState() => _CupertinoTextFieldExampleState(); } -class _MyStatefulWidgetState extends State { +class _CupertinoTextFieldExampleState extends State { late TextEditingController _textController; @override diff --git a/examples/api/test/cupertino/bottom_tab_bar/cupertino_tab_bar.0_test.dart b/examples/api/test/cupertino/bottom_tab_bar/cupertino_tab_bar.0_test.dart new file mode 100644 index 0000000000..906aeb576a --- /dev/null +++ b/examples/api/test/cupertino/bottom_tab_bar/cupertino_tab_bar.0_test.dart @@ -0,0 +1,23 @@ +// 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/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/bottom_tab_bar/cupertino_tab_bar.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can switch between tabs', (WidgetTester tester) async { + await tester.pumpWidget( + const example.CupertinoTabBarApp(), + ); + + expect(find.byType(CupertinoTabBar), findsOneWidget); + expect(find.text('Content of tab 0'), findsOneWidget); + + await tester.tap(find.text('Contacts')); + await tester.pump(); + + expect(find.text('Content of tab 2'), findsOneWidget); + }); +} diff --git a/examples/api/test/cupertino/button/cupertino_button.0_test.dart b/examples/api/test/cupertino/button/cupertino_button.0_test.dart index 9d9397e3b9..cdccda9385 100644 --- a/examples/api/test/cupertino/button/cupertino_button.0_test.dart +++ b/examples/api/test/cupertino/button/cupertino_button.0_test.dart @@ -9,7 +9,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Has 4 CupertinoButton variants', (WidgetTester tester) async { await tester.pumpWidget( - const example.MyApp(), + const example.CupertinoButtonApp(), ); expect(find.byType(CupertinoButton), findsNWidgets(4)); diff --git a/examples/api/test/cupertino/date_picker/cupertino_date_picker.0_test.dart b/examples/api/test/cupertino/date_picker/cupertino_date_picker.0_test.dart index af9a22bee1..8638aaa470 100644 --- a/examples/api/test/cupertino/date_picker/cupertino_date_picker.0_test.dart +++ b/examples/api/test/cupertino/date_picker/cupertino_date_picker.0_test.dart @@ -10,7 +10,7 @@ const Offset _kRowOffset = Offset(0.0, -50.0); void main() { testWidgets('Can change date, time and dateTime using CupertinoDatePicker', (WidgetTester tester) async { await tester.pumpWidget( - const example.MyApp(), + const example.DatePickerApp(), ); // Open the date picker. await tester.tap(find.text('10-26-2016')); diff --git a/examples/api/test/cupertino/date_picker/cupertino_timer_picker.0_test.dart b/examples/api/test/cupertino/date_picker/cupertino_timer_picker.0_test.dart index 328b04c642..8631467172 100644 --- a/examples/api/test/cupertino/date_picker/cupertino_timer_picker.0_test.dart +++ b/examples/api/test/cupertino/date_picker/cupertino_timer_picker.0_test.dart @@ -10,7 +10,7 @@ const Offset _kRowOffset = Offset(0.0, -50.0); void main() { testWidgets('Can pick a duration from CupertinoTimerPicker', (WidgetTester tester) async { await tester.pumpWidget( - const example.MyApp(), + const example.TimerPickerApp(), ); // Launch the timer picker. diff --git a/examples/api/test/cupertino/dialog/cupertino_action_sheet.0_test.dart b/examples/api/test/cupertino/dialog/cupertino_action_sheet.0_test.dart index 27c0ec4622..28162b9ad4 100644 --- a/examples/api/test/cupertino/dialog/cupertino_action_sheet.0_test.dart +++ b/examples/api/test/cupertino/dialog/cupertino_action_sheet.0_test.dart @@ -10,7 +10,7 @@ void main() { testWidgets('Perform an action on CupertinoActionSheet', (WidgetTester tester) async { const String actionText = 'Destructive Action'; await tester.pumpWidget( - const example.MyApp(), + const example.ActionSheetApp(), ); // Launch the CupertinoActionSheet. diff --git a/examples/api/test/cupertino/dialog/cupertino_alert_dialog.0_test.dart b/examples/api/test/cupertino/dialog/cupertino_alert_dialog.0_test.dart index 147bcac501..d9f554da45 100644 --- a/examples/api/test/cupertino/dialog/cupertino_alert_dialog.0_test.dart +++ b/examples/api/test/cupertino/dialog/cupertino_alert_dialog.0_test.dart @@ -10,7 +10,7 @@ void main() { testWidgets('Perform an action on CupertinoAlertDialog', (WidgetTester tester) async { const String actionText = 'Yes'; await tester.pumpWidget( - const example.MyApp(), + const example.AlertDialogApp(), ); // Launch the CupertinoAlertDialog. diff --git a/examples/api/test/cupertino/nav_bar/cupertino_navigation_bar.0_test.dart b/examples/api/test/cupertino/nav_bar/cupertino_navigation_bar.0_test.dart new file mode 100644 index 0000000000..0b8dc1b2d3 --- /dev/null +++ b/examples/api/test/cupertino/nav_bar/cupertino_navigation_bar.0_test.dart @@ -0,0 +1,20 @@ +// 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/cupertino.dart'; +import 'package:flutter_api_samples/cupertino/nav_bar/cupertino_navigation_bar.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('CupertinoNavigationBar is semi transparent', (WidgetTester tester) async { + await tester.pumpWidget( + const example.NavBarApp(), + ); + + final Finder navBarFinder = find.byType(CupertinoNavigationBar); + expect(navBarFinder, findsOneWidget); + final CupertinoNavigationBar cupertinoNavigationBar = tester.widget(navBarFinder); + expect(cupertinoNavigationBar.backgroundColor, CupertinoColors.systemGrey.withOpacity(0.5)); + }); +} diff --git a/examples/api/test/cupertino/nav_bar/cupertino_sliver_nav_bar.0_test.dart b/examples/api/test/cupertino/nav_bar/cupertino_sliver_nav_bar.0_test.dart index a02b5a4deb..dd74e80a01 100644 --- a/examples/api/test/cupertino/nav_bar/cupertino_sliver_nav_bar.0_test.dart +++ b/examples/api/test/cupertino/nav_bar/cupertino_sliver_nav_bar.0_test.dart @@ -11,7 +11,7 @@ const Offset dragUp = Offset(0.0, -150.0); void main() { testWidgets('Collapse and expand CupertinoSliverNavigationBar changes title position', (WidgetTester tester) async { await tester.pumpWidget( - const example.MyApp(), + const example.SliverNavBarApp(), ); // Large title is visible and at lower position. @@ -25,7 +25,7 @@ void main() { testWidgets('Middle widget is visible in both collapsed and expanded states', (WidgetTester tester) async { await tester.pumpWidget( - const example.MyApp(), + const example.SliverNavBarApp(), ); // Navigate to a page that has both middle and large titles. @@ -48,7 +48,7 @@ void main() { testWidgets('CupertinoSliverNavigationBar with previous route has back button', (WidgetTester tester) async { await tester.pumpWidget( - const example.MyApp(), + const example.SliverNavBarApp(), ); // Navigate to a page that has back button diff --git a/examples/api/test/cupertino/picker/cupertino_picker.0_test.dart b/examples/api/test/cupertino/picker/cupertino_picker.0_test.dart index 168e2f57ac..f2e9a97fa6 100644 --- a/examples/api/test/cupertino/picker/cupertino_picker.0_test.dart +++ b/examples/api/test/cupertino/picker/cupertino_picker.0_test.dart @@ -10,7 +10,7 @@ const Offset _kRowOffset = Offset(0.0, -50.0); void main() { testWidgets('Change selected fruit using CupertinoPicker', (WidgetTester tester) async { await tester.pumpWidget( - const example.MyApp(), + const example.CupertinoPickerApp(), ); // Open the Cupertino picker. diff --git a/examples/api/test/cupertino/segmented_control/cupertino_segmented_control.0_test.dart b/examples/api/test/cupertino/segmented_control/cupertino_segmented_control.0_test.dart index 2e0319d307..0ecbc88f9b 100644 --- a/examples/api/test/cupertino/segmented_control/cupertino_segmented_control.0_test.dart +++ b/examples/api/test/cupertino/segmented_control/cupertino_segmented_control.0_test.dart @@ -8,12 +8,14 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Can change a selected segmented control', (WidgetTester tester) async { await tester.pumpWidget( - const example.MyApp(), + const example.SegmentControlApp(), ); expect(find.text('Selected Segment: midnight'), findsOneWidget); + await tester.tap(find.text('Cerulean')); await tester.pumpAndSettle(); + expect(find.text('Selected Segment: cerulean'), findsOneWidget); }); } diff --git a/examples/api/test/cupertino/segmented_control/cupertino_sliding_segmented_control.0_test.dart b/examples/api/test/cupertino/segmented_control/cupertino_sliding_segmented_control.0_test.dart index 3498b23cac..5367378153 100644 --- a/examples/api/test/cupertino/segmented_control/cupertino_sliding_segmented_control.0_test.dart +++ b/examples/api/test/cupertino/segmented_control/cupertino_sliding_segmented_control.0_test.dart @@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Can change a selected segmented control', (WidgetTester tester) async { await tester.pumpWidget( - const example.MyApp(), + const example.SegmentControlApp(), ); expect(find.text('Selected Segment: midnight'), findsOneWidget); diff --git a/examples/api/test/cupertino/slider/cupertino_slider.0_test.dart b/examples/api/test/cupertino/slider/cupertino_slider.0_test.dart index c5a270698c..d37a6c2cc2 100644 --- a/examples/api/test/cupertino/slider/cupertino_slider.0_test.dart +++ b/examples/api/test/cupertino/slider/cupertino_slider.0_test.dart @@ -16,7 +16,7 @@ void main() { testWidgets('Can change value using CupertinoSlider', (WidgetTester tester) async { await tester.pumpWidget( - const example.MyApp(), + const example.CupertinoSliderApp(), ); // Check for the initial slider value. diff --git a/examples/api/test/cupertino/text_field/cupertino_text_field.0.dart b/examples/api/test/cupertino/text_field/cupertino_text_field.0.dart index 9be9c55e9d..ae6f2db4de 100644 --- a/examples/api/test/cupertino/text_field/cupertino_text_field.0.dart +++ b/examples/api/test/cupertino/text_field/cupertino_text_field.0.dart @@ -2,15 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'package:flutter/cupertino.dart'; import 'package:flutter_api_samples/cupertino/text_field/cupertino_text_field.0.dart' as example; import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('CupertinoTextField has initial text', (WidgetTester tester) async { await tester.pumpWidget( - const example.MyApp(), + const example.CupertinoTextFieldApp(), ); + expect(find.byType(CupertinoTextField), findsOneWidget); expect(find.text('initial text'), findsOneWidget); + + await tester.enterText(find.byType(CupertinoTextField), 'new text'); + await tester.pump(); + + expect(find.text('new text'), findsOneWidget); }); } diff --git a/packages/flutter/lib/src/cupertino/bottom_tab_bar.dart b/packages/flutter/lib/src/cupertino/bottom_tab_bar.dart index ed8d124dd6..58a779765b 100644 --- a/packages/flutter/lib/src/cupertino/bottom_tab_bar.dart +++ b/packages/flutter/lib/src/cupertino/bottom_tab_bar.dart @@ -48,7 +48,7 @@ const Color _kDefaultTabBarInactiveColor = CupertinoColors.inactiveGray; /// {@tool dartpad} /// This example shows a [CupertinoTabBar] placed in a [CupertinoTabScaffold]. /// -/// ** See code in examples/api/lib/cupertino/bottom_tab_bar/bottom_tab_bar.0.dart ** +/// ** See code in examples/api/lib/cupertino/bottom_tab_bar/cupertino_tab_bar.0.dart ** /// {@end-tool} /// /// See also: