Unverified Commit d80f3e39 authored by Taha Tesser's avatar Taha Tesser Committed by GitHub

Cupertino examples improvements and clean up (#103044)

parent 27fee486
......@@ -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);
@override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
}
class CupertinoTabBarExample extends StatelessWidget {
const CupertinoTabBarExample({Key? key}) : super(key: key);
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
@override
Widget build(BuildContext context) {
return CupertinoTabScaffold(
tabBar: CupertinoTabBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(CupertinoIcons.circle),
label: 'Tab 1',
icon: Icon(CupertinoIcons.star_fill),
label: 'Favourites',
),
BottomNavigationBarItem(
icon: Icon(CupertinoIcons.clock_solid),
label: 'Recents',
),
BottomNavigationBarItem(
icon: Icon(CupertinoIcons.person_alt_circle_fill),
label: 'Contacts',
),
BottomNavigationBarItem(
icon: Icon(CupertinoIcons.add),
label: 'Tab 2',
icon: Icon(CupertinoIcons.circle_grid_3x3_fill),
label: 'Keypad',
),
],
),
......
......@@ -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: <Widget>[
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: <Widget>[
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'),
),
],
),
),
);
}
......
......@@ -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<MyStatelessWidget> createState() => _MyStatelessWidgetState();
State<DatePickerExample> createState() => _DatePickerExampleState();
}
class _MyStatelessWidgetState extends State<MyStatelessWidget> {
class _DatePickerExampleState extends State<DatePickerExample> {
DateTime date = DateTime(2016, 10, 26);
DateTime time = DateTime(2016, 5, 10, 22, 35);
DateTime dateTime = DateTime(2016, 8, 3, 17, 45);
......
......@@ -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<CupertinoTimerPickerSample> createState() => _CupertinoTimerPickerSampleState();
State<TimerPickerExample> createState() => _TimerPickerExampleState();
}
class _CupertinoTimerPickerSampleState extends State<CupertinoTimerPickerSample> {
class _TimerPickerExampleState extends State<TimerPickerExample> {
Duration duration = const Duration(hours: 1, minutes: 23);
// This shows a CupertinoModalPopup with a reasonable fixed height which hosts CupertinoTimerPicker.
......
......@@ -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(
......
......@@ -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(
......
......@@ -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<MyStatefulWidget> createState() => _MyStatefulWidgetState();
State<NavBarExample> createState() => _NavBarExampleState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
class _NavBarExampleState extends State<NavBarExample> {
@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: <Widget>[
......
......@@ -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) {
......
......@@ -16,30 +16,27 @@ const List<String> _fruitNames = <String>[
'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<CupertinoPickerSample> createState() => _CupertinoPickerSampleState();
State<CupertinoPickerExample> createState() => _CupertinoPickerExampleState();
}
class _CupertinoPickerSampleState extends State<CupertinoPickerSample> {
class _CupertinoPickerExampleState extends State<CupertinoPickerExample> {
int _selectedFruit = 0;
// This shows a CupertinoModalPopup with a reasonable fixed height which hosts CupertinoPicker.
......
......@@ -14,30 +14,28 @@ Map<Sky, Color> skyColors = <Sky, Color> {
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<SegmentedControlSample> createState() => _SegmentedControlSampleState();
State<SegmentedControlExample> createState() => _SegmentedControlExampleState();
}
class _SegmentedControlSampleState extends State<SegmentedControlSample> {
class _SegmentedControlExampleState extends State<SegmentedControlExample> {
Sky _selectedSegment = Sky.midnight;
@override
......@@ -61,24 +59,15 @@ class _SegmentedControlSampleState extends State<SegmentedControlSample> {
children: const <Sky, Widget>{
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'),
),
},
),
......
......@@ -14,30 +14,28 @@ Map<Sky, Color> skyColors = <Sky, Color> {
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<SegmentedControlSample> createState() => _SegmentedControlSampleState();
State<SegmentedControlExample> createState() => _SegmentedControlExampleState();
}
class _SegmentedControlSampleState extends State<SegmentedControlSample> {
class _SegmentedControlExampleState extends State<SegmentedControlExample> {
Sky _selectedSegment = Sky.midnight;
@override
......
......@@ -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<CupertinoSliderSample> createState() => _CupertinoSliderSampleState();
State<CupertinoSliderExample> createState() => _CupertinoSliderExampleState();
}
class _CupertinoSliderSampleState extends State<CupertinoSliderSample> {
class _CupertinoSliderExampleState extends State<CupertinoSliderExample> {
double _currentSliderValue = 0.0;
String? _sliderStatus;
......
......@@ -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<MyStatefulWidget> createState() => _MyStatefulWidgetState();
State<CupertinoTextFieldExample> createState() => _CupertinoTextFieldExampleState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
class _CupertinoTextFieldExampleState extends State<CupertinoTextFieldExample> {
late TextEditingController _textController;
@override
......
// 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);
});
}
......@@ -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));
......
......@@ -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'));
......
......@@ -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.
......
......@@ -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.
......
......@@ -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.
......
// 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<CupertinoNavigationBar>(navBarFinder);
expect(cupertinoNavigationBar.backgroundColor, CupertinoColors.systemGrey.withOpacity(0.5));
});
}
......@@ -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
......
......@@ -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.
......
......@@ -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);
});
}
......@@ -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);
......
......@@ -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.
......
......@@ -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);
});
}
......@@ -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:
......
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