Rename Sample classes (#124080)

Rename Sample classes
This commit is contained in:
Greg Spencer 2023-04-04 13:34:29 -07:00 committed by GitHub
parent c8a3dbaf06
commit e3bc8efd39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
480 changed files with 3125 additions and 3816 deletions

View file

@ -2,22 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [Curve2D].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [Curve2D].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const Curve2DExampleApp());
static const String _title = 'Flutter Code Sample';
class Curve2DExampleApp extends StatelessWidget {
const Curve2DExampleApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: _title,
home: MyStatelessWidget(),
home: Curve2DExample(),
);
}
}
@ -59,8 +56,7 @@ class FollowCurve2D extends StatefulWidget {
State<FollowCurve2D> createState() => _FollowCurve2DState();
}
class _FollowCurve2DState extends State<FollowCurve2D>
with TickerProviderStateMixin {
class _FollowCurve2DState extends State<FollowCurve2D> with TickerProviderStateMixin {
// The animation controller for this animation.
late AnimationController controller;
// The animation that will be used to apply the widget's animation curve.
@ -87,8 +83,7 @@ class _FollowCurve2DState extends State<FollowCurve2D>
@override
Widget build(BuildContext context) {
// Scale the path values to match the -1.0 to 1.0 domain of the Alignment widget.
final Offset position =
widget.path.transform(animation.value) * 2.0 - const Offset(1.0, 1.0);
final Offset position = widget.path.transform(animation.value) * 2.0 - const Offset(1.0, 1.0);
return Align(
alignment: Alignment(position.dx, position.dy),
child: widget.child,
@ -96,8 +91,8 @@ class _FollowCurve2DState extends State<FollowCurve2D>
}
}
class MyStatelessWidget extends StatelessWidget {
const MyStatelessWidget({super.key});
class Curve2DExample extends StatelessWidget {
const Curve2DExample({super.key});
@override
Widget build(BuildContext context) {

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoActivityIndicator].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoActivityIndicator].
void main() => runApp(const CupertinoIndicatorApp());
class CupertinoIndicatorApp extends StatelessWidget {
@ -69,7 +69,7 @@ class CupertinoIndicatorExample extends StatelessWidget {
),
],
),
)
),
);
}
}

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoTabBar].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoTabBar].
void main() => runApp(const CupertinoTabBarApp());
class CupertinoTabBarApp extends StatelessWidget {
@ -30,7 +30,7 @@ class CupertinoTabBarExample extends StatelessWidget {
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(CupertinoIcons.star_fill),
label: 'Favourites',
label: 'Favorites',
),
BottomNavigationBarItem(
icon: Icon(CupertinoIcons.clock_solid),

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoButton].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoButton].
void main() => runApp(const CupertinoButtonApp());
class CupertinoButtonApp extends StatelessWidget {

View file

@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoContextMenu].
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
/// Flutter code sample for [CupertinoContextMenu].
void main() => runApp(const ContextMenuApp());
class ContextMenuApp extends StatelessWidget {

View file

@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoContextMenu].
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
/// Flutter code sample for [CupertinoContextMenu].
final DecorationTween _tween = DecorationTween(
begin: BoxDecoration(
color: CupertinoColors.systemYellow,
@ -93,15 +93,12 @@ class ContextMenuExample extends StatelessWidget {
child: const Text('Delete'),
),
],
builder:(BuildContext context, Animation<double> animation) {
final Animation<Decoration> boxDecorationAnimation =
_boxDecorationAnimation(animation);
builder: (BuildContext context, Animation<double> animation) {
final Animation<Decoration> boxDecorationAnimation = _boxDecorationAnimation(animation);
return Container(
decoration:
animation.value < CupertinoContextMenu.animationOpensAt
? boxDecorationAnimation.value
: null,
animation.value < CupertinoContextMenu.animationOpensAt ? boxDecorationAnimation.value : null,
child: Container(
decoration: BoxDecoration(
color: CupertinoColors.systemYellow,

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoDatePicker].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoDatePicker].
void main() => runApp(const DatePickerApp());
class DatePickerApp extends StatelessWidget {
@ -52,7 +52,7 @@ class _DatePickerExampleState extends State<DatePickerExample> {
top: false,
child: child,
),
)
),
);
}
@ -92,7 +92,8 @@ class _DatePickerExampleState extends State<DatePickerExample> {
// In this example, the date is formatted manually. You can
// use the intl package to format the value based on the
// user's locale settings.
child: Text('${date.month}-${date.day}-${date.year}',
child: Text(
'${date.month}-${date.day}-${date.year}',
style: const TextStyle(
fontSize: 22.0,
),
@ -119,7 +120,8 @@ class _DatePickerExampleState extends State<DatePickerExample> {
// In this example, the time value is formatted manually.
// You can use the intl package to format the value based on
// the user's locale settings.
child: Text('${time.hour}:${time.minute}',
child: Text(
'${time.hour}:${time.minute}',
style: const TextStyle(
fontSize: 22.0,
),
@ -145,7 +147,8 @@ class _DatePickerExampleState extends State<DatePickerExample> {
// In this example, the time value is formatted manually. You
// can use the intl package to format the value based on the
// user's locale settings.
child: Text('${dateTime.month}-${dateTime.day}-${dateTime.year} ${dateTime.hour}:${dateTime.minute}',
child: Text(
'${dateTime.month}-${dateTime.day}-${dateTime.year} ${dateTime.hour}:${dateTime.minute}',
style: const TextStyle(
fontSize: 22.0,
),

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoTimerPicker].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoTimerPicker].
void main() => runApp(const TimerPickerApp());
class TimerPickerApp extends StatelessWidget {
@ -50,7 +50,7 @@ class _TimerPickerExampleState extends State<TimerPickerExample> {
top: false,
child: child,
),
)
),
);
}
@ -88,7 +88,8 @@ class _TimerPickerExampleState extends State<TimerPickerExample> {
// In this example, the timer's value is formatted manually.
// You can use the intl package to format the value based on
// the user's locale settings.
child: Text('$duration',
child: Text(
'$duration',
style: const TextStyle(
fontSize: 22.0,
),

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoActionSheet].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoActionSheet].
void main() => runApp(const ActionSheetApp());
class ActionSheetApp extends StatelessWidget {

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoAlertDialog].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoAlertDialog].
void main() => runApp(const AlertDialogApp());
class AlertDialogApp extends StatelessWidget {

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoFormRow].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoFormRow].
void main() => runApp(const CupertinoFormRowApp());
class CupertinoFormRowApp extends StatelessWidget {
@ -65,11 +65,7 @@ class _CupertinoFormRowExampleState extends State<CupertinoFormRowExample> {
error: Text('Home network unavailable'),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text('Not connected'),
SizedBox(width: 5),
Icon(CupertinoIcons.forward)
],
children: <Widget>[Text('Not connected'), SizedBox(width: 5), Icon(CupertinoIcons.forward)],
),
),
const CupertinoFormRow(
@ -93,7 +89,7 @@ class _CupertinoFormRowExampleState extends State<CupertinoFormRowExample> {
children: <Widget>[
Text('On'),
SizedBox(width: 5),
Icon(CupertinoIcons.forward)
Icon(CupertinoIcons.forward),
],
),
),

View file

@ -2,28 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for base [CupertinoListSection] and [CupertinoListTile].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for base [CupertinoListSection] and [CupertinoListTile].
void main() => runApp(const CupertinoListSectionBaseApp());
class CupertinoListSectionBaseApp extends StatelessWidget {
const CupertinoListSectionBaseApp({super.key});
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return const CupertinoApp(
title: _title,
home: MyStatelessWidget(),
home: ListSectionBaseExample(),
);
}
}
class MyStatelessWidget extends StatelessWidget {
const MyStatelessWidget({super.key});
class ListSectionBaseExample extends StatelessWidget {
const ListSectionBaseExample({super.key});
@override
Widget build(BuildContext context) {

View file

@ -2,28 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for inset [CupertinoListSection] and [CupertinoListTile].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for inset [CupertinoListSection] and [CupertinoListTile].
void main() => runApp(const CupertinoListSectionInsetApp());
class CupertinoListSectionInsetApp extends StatelessWidget {
const CupertinoListSectionInsetApp({super.key});
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return const CupertinoApp(
title: _title,
home: MyStatelessWidget(),
home: ListSectionInsetExample(),
);
}
}
class MyStatelessWidget extends StatelessWidget {
const MyStatelessWidget({super.key});
class ListSectionInsetExample extends StatelessWidget {
const ListSectionInsetExample({super.key});
@override
Widget build(BuildContext context) {

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoNavigationBar].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoNavigationBar].
void main() => runApp(const NavBarApp());
class NavBarApp extends StatelessWidget {

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoSliverNavigationBar].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoSliverNavigationBar].
void main() => runApp(const SliverNavBarApp());
class SliverNavBarApp extends StatelessWidget {
@ -47,9 +47,14 @@ class SliverNavBarExample extends StatelessWidget {
const Text('Drag me up', textAlign: TextAlign.center),
CupertinoButton.filled(
onPressed: () {
Navigator.push(context, CupertinoPageRoute<Widget>(builder: (BuildContext context) {
return const NextPage();
}));
Navigator.push(
context,
CupertinoPageRoute<Widget>(
builder: (BuildContext context) {
return const NextPage();
},
),
);
},
child: const Text('Go to Next Page'),
),
@ -63,21 +68,19 @@ class SliverNavBarExample extends StatelessWidget {
}
class NextPage extends StatelessWidget {
const NextPage({ super.key });
const NextPage({super.key});
@override
Widget build(BuildContext context) {
final Brightness brightness = CupertinoTheme.brightnessOf(context);
return CupertinoPageScaffold(
return CupertinoPageScaffold(
child: CustomScrollView(
slivers: <Widget>[
CupertinoSliverNavigationBar(
backgroundColor: CupertinoColors.systemYellow,
border: Border(
bottom: BorderSide(
color: brightness == Brightness.light
? CupertinoColors.black
: CupertinoColors.white,
color: brightness == Brightness.light ? CupertinoColors.black : CupertinoColors.white,
),
),
// The middle widget is visible in both collapsed and expanded states.

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoPageScaffold].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoPageScaffold].
void main() => runApp(const PageScaffoldApp());
class PageScaffoldApp extends StatelessWidget {

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoPicker].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoPicker].
const double _kItemExtent = 32.0;
const List<String> _fruitNames = <String>[
'Apple',

View file

@ -11,15 +11,13 @@ void main() => runApp(const CupertinoRadioApp());
class CupertinoRadioApp extends StatelessWidget {
const CupertinoRadioApp({super.key});
static const String _title = 'CuptertinoRadio Example';
@override
Widget build(BuildContext context) {
return const CupertinoApp(
theme: CupertinoThemeData(brightness: Brightness.light),
home: CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
middle: Text(_title),
middle: Text('CupertinoRadio Example'),
),
child: SafeArea(
child: CupertinoRadioExample(),

View file

@ -11,14 +11,12 @@ void main() => runApp(const CupertinoRadioApp());
class CupertinoRadioApp extends StatelessWidget {
const CupertinoRadioApp({super.key});
static const String _title = 'CuptertinoRadio Toggleable Example';
@override
Widget build(BuildContext context) {
return const CupertinoApp(
home: CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
middle: Text(_title),
middle: Text('CupertinoRadio Toggleable Example'),
),
child: SafeArea(
child: CupertinoRadioExample(),

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoSliverRefreshControl].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoSliverRefreshControl].
void main() => runApp(const RefreshControlApp());
class RefreshControlApp extends StatelessWidget {

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [showCupertinoDialog].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [showCupertinoDialog].
void main() => runApp(const CupertinoDialogApp());
class CupertinoDialogApp extends StatelessWidget {
@ -42,8 +42,7 @@ class CupertinoDialogExample extends StatelessWidget {
}
@pragma('vm:entry-point')
static Route<Object?> _dialogBuilder(
BuildContext context, Object? arguments) {
static Route<Object?> _dialogBuilder(BuildContext context, Object? arguments) {
return CupertinoDialogRoute<void>(
context: context,
builder: (BuildContext context) {

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [showCupertinoModalPopup].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [showCupertinoModalPopup].
void main() => runApp(const ModalPopupApp());
class ModalPopupApp extends StatelessWidget {

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoScrollbar].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoScrollbar].
void main() => runApp(const ScrollbarApp());
class ScrollbarApp extends StatelessWidget {

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoScrollbar].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoScrollbar].
void main() => runApp(const ScrollbarApp());
class ScrollbarApp extends StatelessWidget {

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoSearchTextField].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoSearchTextField].
void main() => runApp(const SearchTextFieldApp());
class SearchTextFieldApp extends StatelessWidget {

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoSearchTextField].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoSearchTextField].
void main() => runApp(const SearchTextFieldApp());
class SearchTextFieldApp extends StatelessWidget {

View file

@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoSegmentedControl].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoSegmentedControl].
enum Sky { midnight, viridian, cerulean }
Map<Sky, Color> skyColors = <Sky, Color> {
Map<Sky, Color> skyColors = <Sky, Color>{
Sky.midnight: const Color(0xff191970),
Sky.viridian: const Color(0xff40826d),
Sky.cerulean: const Color(0xff007ba7),

View file

@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoSlidingSegmentedControl].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoSlidingSegmentedControl].
enum Sky { midnight, viridian, cerulean }
Map<Sky, Color> skyColors = <Sky, Color> {
Map<Sky, Color> skyColors = <Sky, Color>{
Sky.midnight: const Color(0xff191970),
Sky.viridian: const Color(0xff40826d),
Sky.cerulean: const Color(0xff007ba7),

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoSlider].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoSlider].
void main() => runApp(const CupertinoSliderApp());
class CupertinoSliderApp extends StatelessWidget {
@ -28,7 +28,7 @@ class CupertinoSliderExample extends StatefulWidget {
}
class _CupertinoSliderExampleState extends State<CupertinoSliderExample> {
double _currentSliderValue = 0.0;
double _currentSliderValue = 0.0;
String? _sliderStatus;
@override
@ -75,8 +75,8 @@ class _CupertinoSliderExampleState extends State<CupertinoSliderExample> {
Text(
_sliderStatus ?? '',
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
fontSize: 12,
),
fontSize: 12,
),
),
],
),

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoSwitch].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoSwitch].
void main() => runApp(const CupertinoSwitchApp());
class CupertinoSwitchApp extends StatelessWidget {

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoTabController].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoTabController].
void main() => runApp(const TabControllerApp());
class TabControllerApp extends StatelessWidget {
@ -64,7 +64,7 @@ class _TabControllerExampleState extends State<TabControllerExample> {
child: const Text('Go to first tab'),
),
],
)
),
);
},
);

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoTabScaffold].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoTabScaffold].
void main() => runApp(const TabScaffoldApp());
class TabScaffoldApp extends StatelessWidget {

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoTextField].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoTextField].
void main() => runApp(const CupertinoTextFieldApp());
class CupertinoTextFieldApp extends StatelessWidget {
@ -51,7 +51,7 @@ class _CupertinoTextFieldExampleState extends State<CupertinoTextFieldExample> {
child: Center(
child: CupertinoTextField(
controller: _textController,
)
),
),
);
}

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CupertinoTextFormFieldRow].
import 'package:flutter/cupertino.dart';
/// Flutter code sample for [CupertinoTextFormFieldRow].
void main() => runApp(const FormSectionApp());
class FormSectionApp extends StatelessWidget {

View file

@ -2,24 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [PointerSignalResolver].
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [PointerSignalResolver].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const PointerSignalResolverExampleApp());
static const String _title = 'Flutter Code Sample';
class PointerSignalResolverExampleApp extends StatelessWidget {
const PointerSignalResolverExampleApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: _title,
home: MyStatefulWidget(),
home: PointerSignalResolverExample(),
);
}
}
@ -65,8 +62,7 @@ class _ColorChangerState extends State<ColorChanger> {
child: Listener(
onPointerSignal: (PointerSignalEvent event) {
if (widget.useResolver) {
GestureBinding.instance.pointerSignalResolver.register(event,
(PointerSignalEvent event) {
GestureBinding.instance.pointerSignalResolver.register(event, (PointerSignalEvent event) {
rotateColor();
});
} else {
@ -85,14 +81,14 @@ class _ColorChangerState extends State<ColorChanger> {
}
}
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({super.key});
class PointerSignalResolverExample extends StatefulWidget {
const PointerSignalResolverExample({super.key});
@override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
State<PointerSignalResolverExample> createState() => _PointerSignalResolverExampleState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
class _PointerSignalResolverExampleState extends State<PointerSignalResolverExample> {
bool useResolver = false;
@override

View file

@ -2,28 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [AboutListTile].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [AboutListTile].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const AboutListTileExampleApp());
static const String _title = 'Flutter Code Sample';
class AboutListTileExampleApp extends StatelessWidget {
const AboutListTileExampleApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: _title,
home: MyStatelessWidget(),
home: AboutListTileExample(),
);
}
}
class MyStatelessWidget extends StatelessWidget {
const MyStatelessWidget({super.key});
class AboutListTileExample extends StatelessWidget {
const AboutListTileExample({super.key});
@override
Widget build(BuildContext context) {
@ -39,9 +36,7 @@ class MyStatelessWidget extends StatelessWidget {
text: "Flutter is Google's UI toolkit for building beautiful, "
'natively compiled applications for mobile, web, and desktop '
'from a single codebase. Learn more about Flutter at '),
TextSpan(
style: textStyle.copyWith(color: theme.colorScheme.primary),
text: 'https://flutter.dev'),
TextSpan(style: textStyle.copyWith(color: theme.colorScheme.primary), text: 'https://flutter.dev'),
TextSpan(style: textStyle, text: '.'),
],
),

View file

@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [ActionIconTheme].
import 'package:flutter/material.dart';
/// Flutter code sample for [ActionIconTheme].
void main() {
runApp(const MyApp());
runApp(const ActionIconThemeExampleApp());
}
class _CustomEndDrawerIcon extends StatelessWidget {
@ -36,13 +36,12 @@ class _CustomDrawerIcon extends StatelessWidget {
}
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
class ActionIconThemeExampleApp extends StatelessWidget {
const ActionIconThemeExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
useMaterial3: true,

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [AnimatedIcon].
import 'package:flutter/material.dart';
/// Flutter code sample for [AnimatedIcon].
void main() {
runApp(const AnimatedIconApp());
}
@ -44,8 +44,9 @@ class _AnimatedIconExampleState extends State<AnimatedIconExample> with SingleTi
controller = AnimationController(
vsync: this,
duration: const Duration(seconds: 2),
)..forward()
..repeat(reverse: true);
)
..forward()
..repeat(reverse: true);
animation = Tween<double>(begin: 0.0, end: 1.0).animate(controller);
}

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [AnimatedIcon].
import 'package:flutter/material.dart';
/// Flutter code sample for [AnimatedIcon].
final Map<String, AnimatedIconData> iconsList = <String, AnimatedIconData>{
'add_event': AnimatedIcons.add_event,
'arrow_menu': AnimatedIcons.arrow_menu,
@ -61,8 +61,9 @@ class _AnimatedIconExampleState extends State<AnimatedIconExample> with SingleTi
controller = AnimationController(
vsync: this,
duration: const Duration(seconds: 2),
)..forward()
..repeat(reverse: true);
)
..forward()
..repeat(reverse: true);
animation = Tween<double>(begin: 0.0, end: 1.0).animate(controller);
}

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [AppBar].
import 'package:flutter/material.dart';
/// Flutter code sample for [AppBar].
void main() => runApp(const AppBarApp());
class AppBarApp extends StatelessWidget {
@ -32,8 +32,7 @@ class AppBarExample extends StatelessWidget {
icon: const Icon(Icons.add_alert),
tooltip: 'Show Snackbar',
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('This is a snackbar')));
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('This is a snackbar')));
},
),
IconButton(

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [AppBar].
import 'package:flutter/material.dart';
/// Flutter code sample for [AppBar].
final List<int> _items = List<int>.generate(51, (int index) => index);
void main() => runApp(const AppBarApp());

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [AppBar].
import 'package:flutter/material.dart';
/// Flutter code sample for [AppBar].
void main() => runApp(const AppBarApp());
class AppBarApp extends StatelessWidget {

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [AppBar].
import 'package:flutter/material.dart';
/// Flutter code sample for [AppBar].
List<String> titles = <String>[
'Cloud',
'Beach',
@ -80,7 +80,7 @@ class AppBarExample extends StatelessWidget {
ListView.builder(
itemCount: 25,
itemBuilder: (BuildContext context, int index) {
return ListTile(
return ListTile(
tileColor: index.isOdd ? oddItemColor : evenItemColor,
title: Text('${titles[0]} $index'),
);
@ -89,7 +89,7 @@ class AppBarExample extends StatelessWidget {
ListView.builder(
itemCount: 25,
itemBuilder: (BuildContext context, int index) {
return ListTile(
return ListTile(
tileColor: index.isOdd ? oddItemColor : evenItemColor,
title: Text('${titles[1]} $index'),
);
@ -98,7 +98,7 @@ class AppBarExample extends StatelessWidget {
ListView.builder(
itemCount: 25,
itemBuilder: (BuildContext context, int index) {
return ListTile(
return ListTile(
tileColor: index.isOdd ? oddItemColor : evenItemColor,
title: Text('${titles[2]} $index'),
);

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [SliverAppBar].
import 'package:flutter/material.dart';
/// Flutter code sample for [SliverAppBar].
void main() => runApp(const AppBarApp());
class AppBarApp extends StatelessWidget {

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [SliverAppBar.medium].
import 'package:flutter/material.dart';
/// Flutter code sample for [SliverAppBar.medium].
void main() {
runApp(const AppBarMediumApp());
}
@ -18,7 +18,7 @@ class AppBarMediumApp extends StatelessWidget {
return MaterialApp(
theme: ThemeData(
useMaterial3: true,
colorSchemeSeed: const Color(0xff6750A4)
colorSchemeSeed: const Color(0xff6750A4),
),
home: Material(
child: CustomScrollView(

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [SliverAppBar.large].
import 'package:flutter/material.dart';
/// Flutter code sample for [SliverAppBar.large].
void main() {
runApp(const AppBarLargeApp());
}
@ -18,7 +18,7 @@ class AppBarLargeApp extends StatelessWidget {
return MaterialApp(
theme: ThemeData(
useMaterial3: true,
colorSchemeSeed: const Color(0xff6750A4)
colorSchemeSeed: const Color(0xff6750A4),
),
home: Material(
child: CustomScrollView(

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [Autocomplete].
import 'package:flutter/material.dart';
/// Flutter code sample for [Autocomplete].
void main() => runApp(const AutocompleteExampleApp());
class AutocompleteExampleApp extends StatelessWidget {

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [Autocomplete].
import 'package:flutter/material.dart';
/// Flutter code sample for [Autocomplete].
void main() => runApp(const AutocompleteExampleApp());
class AutocompleteExampleApp extends StatelessWidget {
@ -73,9 +73,7 @@ class AutocompleteBasicUserExample extends StatelessWidget {
return const Iterable<User>.empty();
}
return _userOptions.where((User option) {
return option
.toString()
.contains(textEditingValue.text.toLowerCase());
return option.toString().contains(textEditingValue.text.toLowerCase());
});
},
onSelected: (User selection) {

View file

@ -2,28 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [MaterialBanner].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [MaterialBanner].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const MaterialBannerExampleApp());
static const String _title = 'Flutter Code Sample';
class MaterialBannerExampleApp extends StatelessWidget {
const MaterialBannerExampleApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: _title,
home: MyStatelessWidget(),
home: MaterialBannerExample(),
);
}
}
class MyStatelessWidget extends StatelessWidget {
const MyStatelessWidget({super.key});
class MaterialBannerExample extends StatelessWidget {
const MaterialBannerExample({super.key});
@override
Widget build(BuildContext context) {

View file

@ -2,28 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [MaterialBanner].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [MaterialBanner].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const MaterialBannerExampleApp());
static const String _title = 'Flutter Code Sample';
class MaterialBannerExampleApp extends StatelessWidget {
const MaterialBannerExampleApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: _title,
home: MyStatelessWidget(),
home: MaterialBannerExample(),
);
}
}
class MyStatelessWidget extends StatelessWidget {
const MyStatelessWidget({super.key});
class MaterialBannerExample extends StatelessWidget {
const MaterialBannerExample({super.key});
@override
Widget build(BuildContext context) {

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [BottomAppBar].
import 'package:flutter/material.dart';
/// Flutter code sample for [BottomAppBar].
void main() {
runApp(const BottomAppBarDemo());
}
@ -20,8 +20,7 @@ class BottomAppBarDemo extends StatefulWidget {
class _BottomAppBarDemoState extends State<BottomAppBarDemo> {
bool _showFab = true;
bool _showNotch = true;
FloatingActionButtonLocation _fabLocation =
FloatingActionButtonLocation.endDocked;
FloatingActionButtonLocation _fabLocation = FloatingActionButtonLocation.endDocked;
void _onShowNotchChanged(bool value) {
setState(() {
@ -120,8 +119,7 @@ class _DemoBottomAppBar extends StatelessWidget {
final FloatingActionButtonLocation fabLocation;
final NotchedShape? shape;
static final List<FloatingActionButtonLocation> centerLocations =
<FloatingActionButtonLocation>[
static final List<FloatingActionButtonLocation> centerLocations = <FloatingActionButtonLocation>[
FloatingActionButtonLocation.centerDocked,
FloatingActionButtonLocation.centerFloat,
];

View file

@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for BottomAppBar with Material 3
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
/// Flutter code sample for [BottomAppBar] with Material 3.
void main() {
runApp(const BottomAppBarDemo());
}
@ -37,9 +37,8 @@ class _BottomAppBarDemoState extends State<BottomAppBarDemo> {
bool _isElevated = true;
bool _isVisible = true;
FloatingActionButtonLocation get _fabLocation => _isVisible
? FloatingActionButtonLocation.endContained
: FloatingActionButtonLocation.endFloat;
FloatingActionButtonLocation get _fabLocation =>
_isVisible ? FloatingActionButtonLocation.endContained : FloatingActionButtonLocation.endFloat;
void _listen() {
final ScrollDirection direction = _controller.position.userScrollDirection;

View file

@ -2,37 +2,33 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [BottomNavigationBar].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [BottomNavigationBar].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const BottomNavigationBarExampleApp());
static const String _title = 'Flutter Code Sample';
class BottomNavigationBarExampleApp extends StatelessWidget {
const BottomNavigationBarExampleApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: _title,
home: MyStatefulWidget(),
home: BottomNavigationBarExample(),
);
}
}
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({super.key});
class BottomNavigationBarExample extends StatefulWidget {
const BottomNavigationBarExample({super.key});
@override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
State<BottomNavigationBarExample> createState() => _BottomNavigationBarExampleState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
class _BottomNavigationBarExampleState extends State<BottomNavigationBarExample> {
int _selectedIndex = 0;
static const TextStyle optionStyle =
TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
static const TextStyle optionStyle = TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
static const List<Widget> _widgetOptions = <Widget>[
Text(
'Index 0: Home',

View file

@ -2,37 +2,33 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [BottomNavigationBar].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [BottomNavigationBar].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const BottomNavigationBarExampleApp());
static const String _title = 'Flutter Code Sample';
class BottomNavigationBarExampleApp extends StatelessWidget {
const BottomNavigationBarExampleApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: _title,
home: MyStatefulWidget(),
home: BottomNavigationBarExample(),
);
}
}
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({super.key});
class BottomNavigationBarExample extends StatefulWidget {
const BottomNavigationBarExample({super.key});
@override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
State<BottomNavigationBarExample> createState() => _BottomNavigationBarExampleState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
class _BottomNavigationBarExampleState extends State<BottomNavigationBarExample> {
int _selectedIndex = 0;
static const TextStyle optionStyle =
TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
static const TextStyle optionStyle = TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
static const List<Widget> _widgetOptions = <Widget>[
Text(
'Index 0: Home',

View file

@ -2,34 +2,31 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [BottomNavigationBar].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [BottomNavigationBar].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const BottomNavigationBarExampleApp());
static const String _title = 'Flutter Code Sample';
class BottomNavigationBarExampleApp extends StatelessWidget {
const BottomNavigationBarExampleApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: _title,
home: MyStatefulWidget(),
home: BottomNavigationBarExample(),
);
}
}
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({super.key});
class BottomNavigationBarExample extends StatefulWidget {
const BottomNavigationBarExample({super.key});
@override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
State<BottomNavigationBarExample> createState() => _BottomNavigationBarExampleState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
class _BottomNavigationBarExampleState extends State<BottomNavigationBarExample> {
int _selectedIndex = 0;
final ScrollController _homeController = ScrollController();

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [showModalBottomSheet].
import 'package:flutter/material.dart';
/// Flutter code sample for [showModalBottomSheet].
void main() => runApp(const BottomSheetApp());
class BottomSheetApp extends StatelessWidget {

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [showModalBottomSheet].
import 'package:flutter/material.dart';
/// Flutter code sample for [showModalBottomSheet].
void main() => runApp(const BottomSheetApp());
class BottomSheetApp extends StatelessWidget {

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [ElevatedButton].
import 'package:flutter/material.dart';
/// Flutter code sample for [ElevatedButton].
void main() {
runApp(const ButtonApp());
}
@ -45,7 +45,7 @@ class ButtonTypesExample extends StatelessWidget {
}
class ButtonTypesGroup extends StatelessWidget {
const ButtonTypesGroup({ super.key, required this.enabled });
const ButtonTypesGroup({super.key, required this.enabled});
final bool enabled;

View file

@ -2,31 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [Card].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [Card].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const CardExampleApp());
static const String _title = 'Flutter Code Sample';
class CardExampleApp extends StatelessWidget {
const CardExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: const MyStatelessWidget(),
appBar: AppBar(title: const Text('Card Sample')),
body: const CardExample(),
),
);
}
}
class MyStatelessWidget extends StatelessWidget {
const MyStatelessWidget({super.key});
class CardExample extends StatelessWidget {
const CardExample({super.key});
@override
Widget build(BuildContext context) {

View file

@ -2,31 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [Card].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [Card].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const CardExampleApp());
static const String _title = 'Flutter Code Sample';
class CardExampleApp extends StatelessWidget {
const CardExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: const MyStatelessWidget(),
appBar: AppBar(title: const Text('Card Sample')),
body: const CardExample(),
),
);
}
}
class MyStatelessWidget extends StatelessWidget {
const MyStatelessWidget({super.key});
class CardExample extends StatelessWidget {
const CardExample({super.key});
@override
Widget build(BuildContext context) {

View file

@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [Card].
import 'package:flutter/material.dart';
void main() { runApp(const CardExamplesApp()); }
/// Flutter code sample for [Card].
void main() {
runApp(const CardExamplesApp());
}
class CardExamplesApp extends StatelessWidget {
const CardExamplesApp({super.key});
@ -38,7 +40,7 @@ class CardExamplesApp extends StatelessWidget {
///
/// https://m3.material.io/components/cards/specs#a012d40d-7a5c-4b07-8740-491dec79d58b
class ElevatedCardExample extends StatelessWidget {
const ElevatedCardExample({ super.key });
const ElevatedCardExample({super.key});
@override
Widget build(BuildContext context) {
@ -61,7 +63,7 @@ class ElevatedCardExample extends StatelessWidget {
///
/// https://m3.material.io/components/cards/specs#0f55bf62-edf2-4619-b00d-b9ed462f2c5a
class FilledCardExample extends StatelessWidget {
const FilledCardExample({ super.key });
const FilledCardExample({super.key});
@override
Widget build(BuildContext context) {
@ -86,7 +88,7 @@ class FilledCardExample extends StatelessWidget {
///
/// https://m3.material.io/components/cards/specs#0f55bf62-edf2-4619-b00d-b9ed462f2c5a
class OutlinedCardExample extends StatelessWidget {
const OutlinedCardExample({ super.key });
const OutlinedCardExample({super.key});
@override
Widget build(BuildContext context) {

View file

@ -2,39 +2,36 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [Checkbox].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [Checkbox].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const CheckboxExampleApp());
static const String _title = 'Flutter Code Sample';
class CheckboxExampleApp extends StatelessWidget {
const CheckboxExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
appBar: AppBar(title: const Text('Checkbox Sample')),
body: const Center(
child: MyStatefulWidget(),
child: CheckboxExample(),
),
),
);
}
}
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({super.key});
class CheckboxExample extends StatefulWidget {
const CheckboxExample({super.key});
@override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
State<CheckboxExample> createState() => _CheckboxExampleState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
class _CheckboxExampleState extends State<CheckboxExample> {
bool isChecked = false;
@override

View file

@ -2,40 +2,38 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for M3 Checkbox with error state
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for M3 [Checkbox] with error state.
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const CheckboxExampleApp());
static const String _title = 'Flutter Code Sample';
class CheckboxExampleApp extends StatelessWidget {
const CheckboxExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(useMaterial3: true, colorSchemeSeed: const Color(0xff6750a4)),
title: _title,
title: 'Checkbox Sample',
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
appBar: AppBar(title: const Text('Checkbox Sample')),
body: const Center(
child: MyStatefulWidget(),
child: CheckboxExample(),
),
),
);
}
}
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({super.key});
class CheckboxExample extends StatefulWidget {
const CheckboxExample({super.key});
@override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
State<CheckboxExample> createState() => _CheckboxExampleState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
class _CheckboxExampleState extends State<CheckboxExample> {
bool? isChecked = true;
@override

View file

@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CheckboxListTile].
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart' show timeDilation;
/// Flutter code sample for [CheckboxListTile].
void main() => runApp(const CheckboxListTileApp());
class CheckboxListTileApp extends StatelessWidget {

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [CheckboxListTile].
import 'package:flutter/material.dart';
/// Flutter code sample for [CheckboxListTile].
void main() => runApp(const CheckboxListTileApp());
class CheckboxListTileApp extends StatelessWidget {
@ -57,7 +57,8 @@ class _CheckboxListTileExampleState extends State<CheckboxListTileExample> {
});
},
title: const Text('Headline'),
subtitle: const Text('Longer supporting text to demonstrate how the text wraps and the checkbox is centered vertically with the text.'),
subtitle: const Text(
'Longer supporting text to demonstrate how the text wraps and the checkbox is centered vertically with the text.'),
),
const Divider(height: 0),
CheckboxListTile(
@ -68,7 +69,8 @@ class _CheckboxListTileExampleState extends State<CheckboxListTileExample> {
});
},
title: const Text('Headline'),
subtitle: const Text("Longer supporting text to demonstrate how the text wraps and how setting 'CheckboxListTile.isThreeLine = true' aligns the checkbox to the top vertically with the text."),
subtitle: const Text(
"Longer supporting text to demonstrate how the text wraps and how setting 'CheckboxListTile.isThreeLine = true' aligns the checkbox to the top vertically with the text."),
isThreeLine: true,
),
const Divider(height: 0),

View file

@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for custom labeled checkbox.
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
/// Flutter code sample for custom labeled checkbox.
void main() => runApp(const LabeledCheckboxApp());
class LabeledCheckboxApp extends StatelessWidget {

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for custom labeled checkbox.
import 'package:flutter/material.dart';
/// Flutter code sample for custom labeled checkbox.
void main() => runApp(const LabeledCheckboxApp());
class LabeledCheckboxApp extends StatelessWidget {

View file

@ -2,25 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [DeletableChipAttributes.onDeleted].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [DeletableChipAttributes.onDeleted].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const OnDeletedExampleApp());
static const String _title = 'Flutter Code Sample';
class OnDeletedExampleApp extends StatelessWidget {
const OnDeletedExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
appBar: AppBar(title: const Text('DeletableChipAttributes.onDeleted Sample')),
body: const Center(
child: MyStatefulWidget(),
child: OnDeletedExample(),
),
),
);
@ -75,14 +72,14 @@ class CastListState extends State<CastList> {
}
}
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({super.key});
class OnDeletedExample extends StatefulWidget {
const OnDeletedExample({super.key});
@override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
State<OnDeletedExample> createState() => _OnDeletedExampleState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
class _OnDeletedExampleState extends State<OnDeletedExample> {
@override
Widget build(BuildContext context) {
return const CastList();

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [ActionChoice].
import 'package:flutter/material.dart';
/// Flutter code sample for [ActionChoice].
void main() => runApp(const ChipApp());
class ChipApp extends StatelessWidget {

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [ColorScheme.fromImageProvider] with content-based dynamic color.
import 'package:flutter/material.dart';
/// Flutter code sample for [ColorScheme.fromImageProvider] with content-based dynamic color.
const Widget divider = SizedBox(height: 10);
const double narrowScreenWidthThreshold = 400;
const double imageSize = 150;
@ -16,12 +16,18 @@ class DynamicColorExample extends StatefulWidget {
DynamicColorExample({super.key});
final List<ImageProvider> images = <NetworkImage>[
const NetworkImage('https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_1.png'),
const NetworkImage('https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_2.png'),
const NetworkImage('https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_3.png'),
const NetworkImage('https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_4.png'),
const NetworkImage('https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_5.png'),
const NetworkImage('https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_6.png'),
const NetworkImage(
'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_1.png'),
const NetworkImage(
'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_2.png'),
const NetworkImage(
'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_3.png'),
const NetworkImage(
'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_4.png'),
const NetworkImage(
'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_5.png'),
const NetworkImage(
'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_6.png'),
];
@override
@ -69,9 +75,7 @@ class _DynamicColorExampleState extends State<DynamicColorExample> {
padding: const EdgeInsets.symmetric(vertical: 15),
child: Text(
brightness,
style: TextStyle(
fontWeight: FontWeight.bold,
color: colorScheme.onSecondaryContainer),
style: TextStyle(fontWeight: FontWeight.bold, color: colorScheme.onSecondaryContainer),
),
);
}
@ -84,7 +88,6 @@ class _DynamicColorExampleState extends State<DynamicColorExample> {
}
return MaterialApp(
title: 'Content Based Dynamic Color',
theme: ThemeData(useMaterial3: true, colorScheme: colorScheme),
debugShowCheckedModeBanner: false,
home: Builder(
@ -125,21 +128,17 @@ class _DynamicColorExampleState extends State<DynamicColorExample> {
Expanded(
child: ColoredBox(
color: colorScheme.background,
child: LayoutBuilder(builder: (BuildContext context,
BoxConstraints constraints) {
if (constraints.maxWidth <
narrowScreenWidthThreshold) {
child: LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
if (constraints.maxWidth < narrowScreenWidthThreshold) {
return SingleChildScrollView(
child: Column(
children: <Widget>[
divider,
schemeLabel(
'Light ColorScheme', colorScheme),
schemeLabel('Light ColorScheme', colorScheme),
schemeView(lightTheme),
divider,
divider,
schemeLabel(
'Dark ColorScheme', colorScheme),
schemeLabel('Dark ColorScheme', colorScheme),
schemeView(darkTheme),
],
),
@ -155,9 +154,7 @@ class _DynamicColorExampleState extends State<DynamicColorExample> {
Expanded(
child: Column(
children: <Widget>[
schemeLabel(
'Light ColorScheme',
colorScheme),
schemeLabel('Light ColorScheme', colorScheme),
schemeView(lightTheme),
],
),
@ -165,9 +162,7 @@ class _DynamicColorExampleState extends State<DynamicColorExample> {
Expanded(
child: Column(
children: <Widget>[
schemeLabel(
'Dark ColorScheme',
colorScheme),
schemeLabel('Dark ColorScheme', colorScheme),
schemeView(darkTheme),
],
),
@ -193,8 +188,7 @@ class _DynamicColorExampleState extends State<DynamicColorExample> {
Future<void> _updateImage(ImageProvider provider) async {
final ColorScheme newColorScheme = await ColorScheme.fromImageProvider(
provider: provider,
brightness: isLight ? Brightness.light : Brightness.dark);
provider: provider, brightness: isLight ? Brightness.light : Brightness.dark);
setState(() {
selectedImage = widget.images.indexOf(provider);
currentColorScheme = newColorScheme;
@ -203,30 +197,25 @@ class _DynamicColorExampleState extends State<DynamicColorExample> {
// For small screens, have two rows of image selection. For wide screens,
// fit them onto one row.
Widget _imagesRow(BuildContext context, List<ImageProvider> images,
ColorScheme colorScheme) {
Widget _imagesRow(BuildContext context, List<ImageProvider> images, ColorScheme colorScheme) {
final double windowHeight = MediaQuery.of(context).size.height;
final double windowWidth = MediaQuery.of(context).size.width;
return Padding(
padding: const EdgeInsets.all(8.0),
child: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
child: LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
if (constraints.maxWidth > 800) {
return _adaptiveLayoutImagesRow(images, colorScheme, windowHeight);
} else {
return Column(children: <Widget>[
_adaptiveLayoutImagesRow(
images.sublist(0, 3), colorScheme, windowWidth),
_adaptiveLayoutImagesRow(
images.sublist(3), colorScheme, windowWidth),
_adaptiveLayoutImagesRow(images.sublist(0, 3), colorScheme, windowWidth),
_adaptiveLayoutImagesRow(images.sublist(3), colorScheme, windowWidth),
]);
}
}),
);
}
Widget _adaptiveLayoutImagesRow(
List<ImageProvider> images, ColorScheme colorScheme, double windowWidth) {
Widget _adaptiveLayoutImagesRow(List<ImageProvider> images, ColorScheme colorScheme, double windowWidth) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: images
@ -268,18 +257,10 @@ class ColorSchemeView extends StatelessWidget {
return Column(
children: <Widget>[
ColorGroup(children: <ColorChip>[
ColorChip(label: 'primary', color: colorScheme.primary, onColor: colorScheme.onPrimary),
ColorChip(label: 'onPrimary', color: colorScheme.onPrimary, onColor: colorScheme.primary),
ColorChip(
label: 'primary',
color: colorScheme.primary,
onColor: colorScheme.onPrimary),
ColorChip(
label: 'onPrimary',
color: colorScheme.onPrimary,
onColor: colorScheme.primary),
ColorChip(
label: 'primaryContainer',
color: colorScheme.primaryContainer,
onColor: colorScheme.onPrimaryContainer),
label: 'primaryContainer', color: colorScheme.primaryContainer, onColor: colorScheme.onPrimaryContainer),
ColorChip(
label: 'onPrimaryContainer',
color: colorScheme.onPrimaryContainer,
@ -287,14 +268,8 @@ class ColorSchemeView extends StatelessWidget {
]),
divider,
ColorGroup(children: <ColorChip>[
ColorChip(
label: 'secondary',
color: colorScheme.secondary,
onColor: colorScheme.onSecondary),
ColorChip(
label: 'onSecondary',
color: colorScheme.onSecondary,
onColor: colorScheme.secondary),
ColorChip(label: 'secondary', color: colorScheme.secondary, onColor: colorScheme.onSecondary),
ColorChip(label: 'onSecondary', color: colorScheme.onSecondary, onColor: colorScheme.secondary),
ColorChip(
label: 'secondaryContainer',
color: colorScheme.secondaryContainer,
@ -307,14 +282,8 @@ class ColorSchemeView extends StatelessWidget {
divider,
ColorGroup(
children: <ColorChip>[
ColorChip(
label: 'tertiary',
color: colorScheme.tertiary,
onColor: colorScheme.onTertiary),
ColorChip(
label: 'onTertiary',
color: colorScheme.onTertiary,
onColor: colorScheme.tertiary),
ColorChip(label: 'tertiary', color: colorScheme.tertiary, onColor: colorScheme.onTertiary),
ColorChip(label: 'onTertiary', color: colorScheme.onTertiary, onColor: colorScheme.tertiary),
ColorChip(
label: 'tertiaryContainer',
color: colorScheme.tertiaryContainer,
@ -328,56 +297,30 @@ class ColorSchemeView extends StatelessWidget {
divider,
ColorGroup(
children: <ColorChip>[
ColorChip(label: 'error', color: colorScheme.error, onColor: colorScheme.onError),
ColorChip(label: 'onError', color: colorScheme.onError, onColor: colorScheme.error),
ColorChip(
label: 'error',
color: colorScheme.error,
onColor: colorScheme.onError),
label: 'errorContainer', color: colorScheme.errorContainer, onColor: colorScheme.onErrorContainer),
ColorChip(
label: 'onError',
color: colorScheme.onError,
onColor: colorScheme.error),
ColorChip(
label: 'errorContainer',
color: colorScheme.errorContainer,
onColor: colorScheme.onErrorContainer),
ColorChip(
label: 'onErrorContainer',
color: colorScheme.onErrorContainer,
onColor: colorScheme.errorContainer),
label: 'onErrorContainer', color: colorScheme.onErrorContainer, onColor: colorScheme.errorContainer),
],
),
divider,
ColorGroup(
children: <ColorChip>[
ColorChip(
label: 'background',
color: colorScheme.background,
onColor: colorScheme.onBackground),
ColorChip(
label: 'onBackground',
color: colorScheme.onBackground,
onColor: colorScheme.background),
ColorChip(label: 'background', color: colorScheme.background, onColor: colorScheme.onBackground),
ColorChip(label: 'onBackground', color: colorScheme.onBackground, onColor: colorScheme.background),
],
),
divider,
ColorGroup(
children: <ColorChip>[
ColorChip(label: 'surface', color: colorScheme.surface, onColor: colorScheme.onSurface),
ColorChip(label: 'onSurface', color: colorScheme.onSurface, onColor: colorScheme.surface),
ColorChip(
label: 'surface',
color: colorScheme.surface,
onColor: colorScheme.onSurface),
label: 'surfaceVariant', color: colorScheme.surfaceVariant, onColor: colorScheme.onSurfaceVariant),
ColorChip(
label: 'onSurface',
color: colorScheme.onSurface,
onColor: colorScheme.surface),
ColorChip(
label: 'surfaceVariant',
color: colorScheme.surfaceVariant,
onColor: colorScheme.onSurfaceVariant),
ColorChip(
label: 'onSurfaceVariant',
color: colorScheme.onSurfaceVariant,
onColor: colorScheme.surfaceVariant),
label: 'onSurfaceVariant', color: colorScheme.onSurfaceVariant, onColor: colorScheme.surfaceVariant),
],
),
divider,
@ -386,17 +329,10 @@ class ColorSchemeView extends StatelessWidget {
ColorChip(label: 'outline', color: colorScheme.outline),
ColorChip(label: 'shadow', color: colorScheme.shadow),
ColorChip(
label: 'inverseSurface',
color: colorScheme.inverseSurface,
onColor: colorScheme.onInverseSurface),
label: 'inverseSurface', color: colorScheme.inverseSurface, onColor: colorScheme.onInverseSurface),
ColorChip(
label: 'onInverseSurface',
color: colorScheme.onInverseSurface,
onColor: colorScheme.inverseSurface),
ColorChip(
label: 'inversePrimary',
color: colorScheme.inversePrimary,
onColor: colorScheme.primary),
label: 'onInverseSurface', color: colorScheme.onInverseSurface, onColor: colorScheme.inverseSurface),
ColorChip(label: 'inversePrimary', color: colorScheme.inversePrimary, onColor: colorScheme.primary),
],
),
],
@ -412,8 +348,7 @@ class ColorGroup extends StatelessWidget {
@override
Widget build(BuildContext context) {
return RepaintBoundary(
child:
Card(clipBehavior: Clip.antiAlias, child: Column(children: children)),
child: Card(clipBehavior: Clip.antiAlias, child: Column(children: children)),
);
}
}

View file

@ -9,25 +9,24 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() => runApp(const MyApp());
void main() => runApp(const ContextMenuControllerExampleApp());
/// A builder that includes an Offset to draw the context menu at.
typedef ContextMenuBuilder = Widget Function(BuildContext context, Offset offset);
class MyApp extends StatefulWidget {
const MyApp({super.key});
class ContextMenuControllerExampleApp extends StatefulWidget {
const ContextMenuControllerExampleApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
State<ContextMenuControllerExampleApp> createState() => _ContextMenuControllerExampleAppState();
}
class _MyAppState extends State<MyApp> {
void _showDialog (BuildContext context) {
class _ContextMenuControllerExampleAppState extends State<ContextMenuControllerExampleApp> {
void _showDialog(BuildContext context) {
Navigator.of(context).push(
DialogRoute<void>(
context: context,
builder: (BuildContext context) =>
const AlertDialog(title: Text('You clicked print!')),
builder: (BuildContext context) => const AlertDialog(title: Text('You clicked print!')),
),
);
}
@ -82,7 +81,8 @@ class _MyAppState extends State<MyApp> {
child: ListView(
children: <Widget>[
Container(height: 20.0),
const Text('Right click (desktop) or long press (mobile) anywhere, not just on this text, to show the custom menu.'),
const Text(
'Right click (desktop) or long press (mobile) anywhere, not just on this text, to show the custom menu.'),
],
),
),

View file

@ -10,16 +10,16 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() => runApp(const MyApp());
void main() => runApp(const EditableTextToolbarBuilderExampleApp());
class MyApp extends StatefulWidget {
const MyApp({super.key});
class EditableTextToolbarBuilderExampleApp extends StatefulWidget {
const EditableTextToolbarBuilderExampleApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
State<EditableTextToolbarBuilderExampleApp> createState() => _EditableTextToolbarBuilderExampleAppState();
}
class _MyAppState extends State<MyApp> {
class _EditableTextToolbarBuilderExampleAppState extends State<EditableTextToolbarBuilderExampleApp> {
final TextEditingController _controller = TextEditingController(
text: 'Right click (desktop) or long press (mobile) to see the menu with custom buttons.',
);

View file

@ -9,30 +9,28 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() => runApp(const MyApp());
void main() => runApp(const EditableTextToolbarBuilderExampleApp());
const String emailAddress = 'me@example.com';
const String text = 'Select the email address and open the menu: $emailAddress';
class MyApp extends StatefulWidget {
const MyApp({super.key});
class EditableTextToolbarBuilderExampleApp extends StatefulWidget {
const EditableTextToolbarBuilderExampleApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
State<EditableTextToolbarBuilderExampleApp> createState() => _EditableTextToolbarBuilderExampleAppState();
}
class _MyAppState extends State<MyApp> {
class _EditableTextToolbarBuilderExampleAppState extends State<EditableTextToolbarBuilderExampleApp> {
final TextEditingController _controller = TextEditingController(
text: text,
);
void _showDialog (BuildContext context) {
void _showDialog(BuildContext context) {
Navigator.of(context).push(
DialogRoute<void>(
context: context,
builder: (BuildContext context) =>
const AlertDialog(title: Text('You clicked send email!')),
builder: (BuildContext context) => const AlertDialog(title: Text('You clicked send email!')),
),
);
}
@ -69,20 +67,22 @@ class _MyAppState extends State<MyApp> {
TextField(
controller: _controller,
contextMenuBuilder: (BuildContext context, EditableTextState editableTextState) {
final List<ContextMenuButtonItem> buttonItems =
editableTextState.contextMenuButtonItems;
final List<ContextMenuButtonItem> buttonItems = editableTextState.contextMenuButtonItems;
// Here we add an "Email" button to the default TextField
// context menu for the current platform, but only if an email
// address is currently selected.
final TextEditingValue value = _controller.value;
if (_isValidEmail(value.selection.textInside(value.text))) {
buttonItems.insert(0, ContextMenuButtonItem(
label: 'Send email',
onPressed: () {
ContextMenuController.removeAny();
_showDialog(context);
},
));
buttonItems.insert(
0,
ContextMenuButtonItem(
label: 'Send email',
onPressed: () {
ContextMenuController.removeAny();
_showDialog(context);
},
),
);
}
return AdaptiveTextSelectionToolbar.buttonItems(
anchors: editableTextState.contextMenuAnchors,

View file

@ -9,16 +9,16 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() => runApp(const MyApp());
void main() => runApp(const EditableTextToolbarBuilderExampleApp());
class MyApp extends StatefulWidget {
const MyApp({super.key});
class EditableTextToolbarBuilderExampleApp extends StatefulWidget {
const EditableTextToolbarBuilderExampleApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
State<EditableTextToolbarBuilderExampleApp> createState() => _EditableTextToolbarBuilderExampleAppState();
}
class _MyAppState extends State<MyApp> {
class _EditableTextToolbarBuilderExampleAppState extends State<EditableTextToolbarBuilderExampleApp> {
final TextEditingController _controller = TextEditingController(
text: 'Right click (desktop) or long press (mobile) to see the menu with a custom toolbar.',
);

View file

@ -9,24 +9,24 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() => runApp(const MyApp());
void main() => runApp(const SelectableRegionToolbarBuilderExampleApp());
const String text = 'I am some text inside of SelectionArea. Right click (desktop) or long press (mobile) me to show the customized context menu.';
const String text =
'I am some text inside of SelectionArea. Right click (desktop) or long press (mobile) me to show the customized context menu.';
class MyApp extends StatefulWidget {
const MyApp({super.key});
class SelectableRegionToolbarBuilderExampleApp extends StatefulWidget {
const SelectableRegionToolbarBuilderExampleApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
State<SelectableRegionToolbarBuilderExampleApp> createState() => _SelectableRegionToolbarBuilderExampleAppState();
}
class _MyAppState extends State<MyApp> {
void _showDialog (BuildContext context) {
class _SelectableRegionToolbarBuilderExampleAppState extends State<SelectableRegionToolbarBuilderExampleApp> {
void _showDialog(BuildContext context) {
Navigator.of(context).push(
DialogRoute<void>(
context: context,
builder: (BuildContext context) =>
const AlertDialog(title: Text('You clicked print!')),
builder: (BuildContext context) => const AlertDialog(title: Text('You clicked print!')),
),
);
}

View file

@ -2,31 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [DataTable].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [DataTable].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const DataTableExampleApp());
static const String _title = 'Flutter Code Sample';
class DataTableExampleApp extends StatelessWidget {
const DataTableExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: const MyStatelessWidget(),
appBar: AppBar(title: const Text('DataTable Sample')),
body: const DataTableExample(),
),
);
}
}
class MyStatelessWidget extends StatelessWidget {
const MyStatelessWidget({super.key});
class DataTableExample extends StatelessWidget {
const DataTableExample({super.key});
@override
Widget build(BuildContext context) {

View file

@ -2,37 +2,34 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [DataTable].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [DataTable].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const DataTableExampleApp());
static const String _title = 'Flutter Code Sample';
class DataTableExampleApp extends StatelessWidget {
const DataTableExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: const MyStatefulWidget(),
appBar: AppBar(title: const Text('DataTable Sample')),
body: const DataTableExample(),
),
);
}
}
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({super.key});
class DataTableExample extends StatefulWidget {
const DataTableExample({super.key});
@override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
State<DataTableExample> createState() => _DataTableExampleState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
class _DataTableExampleState extends State<DataTableExample> {
static const int numItems = 10;
List<bool> selected = List<bool>.generate(numItems, (int index) => false);
@ -49,8 +46,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
rows: List<DataRow>.generate(
numItems,
(int index) => DataRow(
color: MaterialStateProperty.resolveWith<Color?>(
(Set<MaterialState> states) {
color: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
// All rows will have the same selected color.
if (states.contains(MaterialState.selected)) {
return Theme.of(context).colorScheme.primary.withOpacity(0.08);

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [showDatePicker].
import 'package:flutter/material.dart';
/// Flutter code sample for [showDatePicker].
void main() => runApp(const DatePickerApp());
class DatePickerApp extends StatelessWidget {
@ -31,17 +31,14 @@ class DatePickerExample extends StatefulWidget {
}
/// RestorationProperty objects can be used because of RestorationMixin.
class _DatePickerExampleState extends State<DatePickerExample>
with RestorationMixin {
class _DatePickerExampleState extends State<DatePickerExample> with RestorationMixin {
// In this example, the restoration ID for the mixin is passed in through
// the [StatefulWidget]'s constructor.
@override
String? get restorationId => widget.restorationId;
final RestorableDateTime _selectedDate =
RestorableDateTime(DateTime(2021, 7, 25));
late final RestorableRouteFuture<DateTime?> _restorableDatePickerRouteFuture =
RestorableRouteFuture<DateTime?>(
final RestorableDateTime _selectedDate = RestorableDateTime(DateTime(2021, 7, 25));
late final RestorableRouteFuture<DateTime?> _restorableDatePickerRouteFuture = RestorableRouteFuture<DateTime?>(
onComplete: _selectDate,
onPresent: (NavigatorState navigator, Object? arguments) {
return navigator.restorablePush(
@ -73,8 +70,7 @@ class _DatePickerExampleState extends State<DatePickerExample>
@override
void restoreState(RestorationBucket? oldBucket, bool initialRestore) {
registerForRestoration(_selectedDate, 'selected_date');
registerForRestoration(
_restorableDatePickerRouteFuture, 'date_picker_route_future');
registerForRestoration(_restorableDatePickerRouteFuture, 'date_picker_route_future');
}
void _selectDate(DateTime? newSelectedDate) {
@ -82,8 +78,8 @@ class _DatePickerExampleState extends State<DatePickerExample>
setState(() {
_selectedDate.value = newSelectedDate;
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(
'Selected: ${_selectedDate.value.day}/${_selectedDate.value.month}/${_selectedDate.value.year}'),
content:
Text('Selected: ${_selectedDate.value.day}/${_selectedDate.value.month}/${_selectedDate.value.year}'),
));
});
}

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [showDateRangePicker].
import 'package:flutter/material.dart';
/// Flutter code sample for [showDateRangePicker].
void main() => runApp(const DatePickerApp());
class DatePickerApp extends StatelessWidget {
@ -21,7 +21,6 @@ class DatePickerApp extends StatelessWidget {
}
}
class DatePickerExample extends StatefulWidget {
const DatePickerExample({super.key, this.restorationId});
@ -32,24 +31,19 @@ class DatePickerExample extends StatefulWidget {
}
/// RestorationProperty objects can be used because of RestorationMixin.
class _DatePickerExampleState extends State<DatePickerExample>
with RestorationMixin {
class _DatePickerExampleState extends State<DatePickerExample> with RestorationMixin {
// In this example, the restoration ID for the mixin is passed in through
// the [StatefulWidget]'s constructor.
@override
String? get restorationId => widget.restorationId;
final RestorableDateTimeN _startDate =
RestorableDateTimeN(DateTime(2021));
final RestorableDateTimeN _endDate =
RestorableDateTimeN(DateTime(2021, 1, 5));
late final RestorableRouteFuture<DateTimeRange?>
_restorableDateRangePickerRouteFuture =
final RestorableDateTimeN _startDate = RestorableDateTimeN(DateTime(2021));
final RestorableDateTimeN _endDate = RestorableDateTimeN(DateTime(2021, 1, 5));
late final RestorableRouteFuture<DateTimeRange?> _restorableDateRangePickerRouteFuture =
RestorableRouteFuture<DateTimeRange?>(
onComplete: _selectDateRange,
onPresent: (NavigatorState navigator, Object? arguments) {
return navigator
.restorablePush(_dateRangePickerRoute, arguments: <String, dynamic>{
return navigator.restorablePush(_dateRangePickerRoute, arguments: <String, dynamic>{
'initialStartDate': _startDate.value?.millisecondsSinceEpoch,
'initialEndDate': _endDate.value?.millisecondsSinceEpoch,
});
@ -69,8 +63,7 @@ class _DatePickerExampleState extends State<DatePickerExample>
void restoreState(RestorationBucket? oldBucket, bool initialRestore) {
registerForRestoration(_startDate, 'start_date');
registerForRestoration(_endDate, 'end_date');
registerForRestoration(
_restorableDateRangePickerRouteFuture, 'date_picker_route_future');
registerForRestoration(_restorableDateRangePickerRouteFuture, 'date_picker_route_future');
}
@pragma('vm:entry-point')
@ -83,8 +76,7 @@ class _DatePickerExampleState extends State<DatePickerExample>
builder: (BuildContext context) {
return DateRangePickerDialog(
restorationId: 'date_picker_dialog',
initialDateRange:
_initialDateTimeRange(arguments! as Map<dynamic, dynamic>),
initialDateRange: _initialDateTimeRange(arguments! as Map<dynamic, dynamic>),
firstDate: DateTime(2021),
currentDate: DateTime(2021, 1, 25),
lastDate: DateTime(2022),
@ -94,13 +86,10 @@ class _DatePickerExampleState extends State<DatePickerExample>
}
static DateTimeRange? _initialDateTimeRange(Map<dynamic, dynamic> arguments) {
if (arguments['initialStartDate'] != null &&
arguments['initialEndDate'] != null) {
if (arguments['initialStartDate'] != null && arguments['initialEndDate'] != null) {
return DateTimeRange(
start: DateTime.fromMillisecondsSinceEpoch(
arguments['initialStartDate'] as int),
end: DateTime.fromMillisecondsSinceEpoch(
arguments['initialEndDate'] as int),
start: DateTime.fromMillisecondsSinceEpoch(arguments['initialStartDate'] as int),
end: DateTime.fromMillisecondsSinceEpoch(arguments['initialEndDate'] as int),
);
}

View file

@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [AlertDialog].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [AlertDialog].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const AlertDialogExampleApp());
class AlertDialogExampleApp extends StatelessWidget {
const AlertDialogExampleApp({super.key});
@override
Widget build(BuildContext context) {

View file

@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [AlertDialog].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [AlertDialog].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const AlertDialogExampleApp());
class AlertDialogExampleApp extends StatelessWidget {
const AlertDialogExampleApp({super.key});
@override
Widget build(BuildContext context) {

View file

@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [Dialog].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [Dialog].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const DialogExampleApp());
class DialogExampleApp extends StatelessWidget {
const DialogExampleApp({super.key});
@override
Widget build(BuildContext context) {
@ -42,7 +42,7 @@ class DialogExample extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text('This is a typical dialog.'),
const Text('This is a typical dialog.'),
const SizedBox(height: 15),
TextButton(
onPressed: () {
@ -66,7 +66,7 @@ class DialogExample extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text('This is a fullscreen dialog.'),
const Text('This is a fullscreen dialog.'),
const SizedBox(height: 15),
TextButton(
onPressed: () {

View file

@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [showDialog].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [showDialog].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const ShowDialogExampleApp());
class ShowDialogExampleApp extends StatelessWidget {
const ShowDialogExampleApp({super.key});
@override
Widget build(BuildContext context) {
@ -42,10 +42,11 @@ class DialogExample extends StatelessWidget {
return AlertDialog(
title: const Text('Basic dialog title'),
content: const Text(
'A dialog is a type of modal window that\n'
'appears in front of app content to\n'
'provide critical information, or prompt\n'
'for a decision to be made.'),
'A dialog is a type of modal window that\n'
'appears in front of app content to\n'
'provide critical information, or prompt\n'
'for a decision to be made.',
),
actions: <Widget>[
TextButton(
style: TextButton.styleFrom(

View file

@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [showDialog].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [showDialog].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const ShowDialogExampleApp());
class ShowDialogExampleApp extends StatelessWidget {
const ShowDialogExampleApp({super.key});
@override
Widget build(BuildContext context) {
@ -43,10 +43,11 @@ class DialogExample extends StatelessWidget {
return AlertDialog(
title: const Text('Basic dialog title'),
content: const Text(
'A dialog is a type of modal window that\n'
'appears in front of app content to\n'
'provide critical information, or prompt\n'
'for a decision to be made.'),
'A dialog is a type of modal window that\n'
'appears in front of app content to\n'
'provide critical information, or prompt\n'
'for a decision to be made.',
),
actions: <Widget>[
TextButton(
style: TextButton.styleFrom(

View file

@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [showDialog].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [showDialog].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const ShowDialogExampleApp());
class ShowDialogExampleApp extends StatelessWidget {
const ShowDialogExampleApp({super.key});
@override
Widget build(BuildContext context) {
@ -39,18 +39,18 @@ class DialogExample extends StatelessWidget {
}
@pragma('vm:entry-point')
static Route<Object?> _dialogBuilder(
BuildContext context, Object? arguments) {
static Route<Object?> _dialogBuilder(BuildContext context, Object? arguments) {
return DialogRoute<void>(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Basic dialog title'),
content: const Text(
'A dialog is a type of modal window that\n'
'appears in front of app content to\n'
'provide critical information, or prompt\n'
'for a decision to be made.'),
'A dialog is a type of modal window that\n'
'appears in front of app content to\n'
'provide critical information, or prompt\n'
'for a decision to be made.',
),
actions: <Widget>[
TextButton(
style: TextButton.styleFrom(

View file

@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [Divider].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [Divider].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const DividerExampleApp());
class DividerExampleApp extends StatelessWidget {
const DividerExampleApp({super.key});
@override
Widget build(BuildContext context) {

View file

@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [Divider].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [Divider].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const DividerExampleApp());
class DividerExampleApp extends StatelessWidget {
const DividerExampleApp({super.key});
@override
Widget build(BuildContext context) {

View file

@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [VerticalDivider].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [VerticalDivider].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const VerticalDividerExampleApp());
class VerticalDividerExampleApp extends StatelessWidget {
const VerticalDividerExampleApp({super.key});
@override
Widget build(BuildContext context) {

View file

@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [Divider].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [Divider].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const VerticalDividerExampleApp());
class VerticalDividerExampleApp extends StatelessWidget {
const VerticalDividerExampleApp({super.key});
@override
Widget build(BuildContext context) {

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [DropdownButton].
import 'package:flutter/material.dart';
/// Flutter code sample for [DropdownButton].
const List<String> list = <String>['One', 'Two', 'Three', 'Four'];
void main() => runApp(const DropdownButtonApp());

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [DropdownButton.selectedItemBuilder].
import 'package:flutter/material.dart';
/// Flutter code sample for [DropdownButton.selectedItemBuilder].
Map<String, String> cities = <String, String>{
'New York': 'NYC',
'Los Angeles': 'LA',
@ -61,7 +61,7 @@ class _DropdownButtonExampleState extends State<DropdownButtonExample> {
// Here custom text style, alignment and layout size can be applied
// to selected item string.
return Container(
alignment:Alignment.centerLeft,
alignment: Alignment.centerLeft,
constraints: const BoxConstraints(minWidth: 100),
child: Text(
item,

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [DropdownButton.style].
import 'package:flutter/material.dart';
/// Flutter code sample for [DropdownButton.style].
void main() => runApp(const DropdownButtonApp());
class DropdownButtonApp extends StatelessWidget {

View file

@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [DropdownMenu]s. The first dropdown menu has an outlined border
// which is the default configuration, and the second one has a filled input decoration.
import 'package:flutter/material.dart';
/// Flutter code sample for [DropdownMenu]s. The first dropdown menu has an outlined border.
void main() => runApp(const DropdownMenuExample());
class DropdownMenuExample extends StatefulWidget {
@ -27,7 +28,8 @@ class _DropdownMenuExampleState extends State<DropdownMenuExample> {
final List<DropdownMenuEntry<ColorLabel>> colorEntries = <DropdownMenuEntry<ColorLabel>>[];
for (final ColorLabel color in ColorLabel.values) {
colorEntries.add(
DropdownMenuEntry<ColorLabel>(value: color, label: color.label, enabled: color.label != 'Grey'));
DropdownMenuEntry<ColorLabel>(value: color, label: color.label, enabled: color.label != 'Grey'),
);
}
final List<DropdownMenuEntry<IconLabel>> iconEntries = <DropdownMenuEntry<IconLabel>>[];
@ -38,7 +40,7 @@ class _DropdownMenuExampleState extends State<DropdownMenuExample> {
return MaterialApp(
theme: ThemeData(
useMaterial3: true,
colorSchemeSeed: Colors.green
colorSchemeSeed: Colors.green,
),
home: Scaffold(
body: SafeArea(
@ -69,7 +71,8 @@ class _DropdownMenuExampleState extends State<DropdownMenuExample> {
dropdownMenuEntries: iconEntries,
inputDecorationTheme: const InputDecorationTheme(
filled: true,
contentPadding: EdgeInsets.symmetric(vertical: 5.0)),
contentPadding: EdgeInsets.symmetric(vertical: 5.0),
),
onSelected: (IconLabel? icon) {
setState(() {
selectedIcon = icon;
@ -86,12 +89,17 @@ class _DropdownMenuExampleState extends State<DropdownMenuExample> {
Text('You selected a ${selectedColor?.label} ${selectedIcon?.label}'),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 5),
child: Icon(selectedIcon?.icon, color: selectedColor?.color,))
child: Icon(
selectedIcon?.icon,
color: selectedColor?.color,
),
)
],
)
else const Text('Please select a color and an icon.')
else
const Text('Please select a color and an icon.')
],
)
),
),
),
);
@ -112,7 +120,10 @@ enum ColorLabel {
enum IconLabel {
smile('Smile', Icons.sentiment_satisfied_outlined),
cloud('Cloud', Icons.cloud_outlined,),
cloud(
'Cloud',
Icons.cloud_outlined,
),
brush('Brush', Icons.brush_outlined),
heart('Heart', Icons.favorite);

View file

@ -2,41 +2,37 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [ElevatedButton].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [ElevatedButton].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const ElevatedButtonExampleApp());
static const String _title = 'Flutter Code Sample';
class ElevatedButtonExampleApp extends StatelessWidget {
const ElevatedButtonExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: const MyStatefulWidget(),
appBar: AppBar(title: const Text('ElevatedButton Sample')),
body: const ElevatedButtonExample(),
),
);
}
}
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({super.key});
class ElevatedButtonExample extends StatefulWidget {
const ElevatedButtonExample({super.key});
@override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
State<ElevatedButtonExample> createState() => _ElevatedButtonExampleState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
class _ElevatedButtonExampleState extends State<ElevatedButtonExample> {
@override
Widget build(BuildContext context) {
final ButtonStyle style =
ElevatedButton.styleFrom(textStyle: const TextStyle(fontSize: 20));
final ButtonStyle style = ElevatedButton.styleFrom(textStyle: const TextStyle(fontSize: 20));
return Center(
child: Column(

View file

@ -2,24 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [ExpansionPanelList].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [ExpansionPanelList].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const ExpansionPanelListExampleApp());
static const String _title = 'Flutter Code Sample';
class ExpansionPanelListExampleApp extends StatelessWidget {
const ExpansionPanelListExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: const MyStatefulWidget(),
appBar: AppBar(title: const Text('ExpansionPanelList Sample')),
body: const ExpansionPanelListExample(),
),
);
}
@ -47,14 +44,14 @@ List<Item> generateItems(int numberOfItems) {
});
}
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({super.key});
class ExpansionPanelListExample extends StatefulWidget {
const ExpansionPanelListExample({super.key});
@override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
State<ExpansionPanelListExample> createState() => _ExpansionPanelListExampleState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
class _ExpansionPanelListExampleState extends State<ExpansionPanelListExample> {
final List<Item> _data = generateItems(8);
@override
@ -82,8 +79,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
},
body: ListTile(
title: Text(item.expandedValue),
subtitle:
const Text('To delete this panel, tap the trash can icon'),
subtitle: const Text('To delete this panel, tap the trash can icon'),
trailing: const Icon(Icons.delete),
onTap: () {
setState(() {

View file

@ -2,24 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [ExpansionPanelList.ExpansionPanelList.radio].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// Flutter code sample for [ExpansionPanelList.ExpansionPanelList.radio].
class MyApp extends StatelessWidget {
const MyApp({super.key});
void main() => runApp(const ExpansionPanelListRadioExampleApp());
static const String _title = 'Flutter Code Sample';
class ExpansionPanelListRadioExampleApp extends StatelessWidget {
const ExpansionPanelListRadioExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: const MyStatefulWidget(),
appBar: AppBar(title: const Text('ExpansionPanelList.radio Sample')),
body: const ExpansionPanelListRadioExample(),
),
);
}
@ -48,14 +45,14 @@ List<Item> generateItems(int numberOfItems) {
});
}
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({super.key});
class ExpansionPanelListRadioExample extends StatefulWidget {
const ExpansionPanelListRadioExample({super.key});
@override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
State<ExpansionPanelListRadioExample> createState() => _ExpansionPanelListRadioExampleState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
class _ExpansionPanelListRadioExampleState extends State<ExpansionPanelListRadioExample> {
final List<Item> _data = generateItems(8);
@override
@ -80,13 +77,11 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
},
body: ListTile(
title: Text(item.expandedValue),
subtitle:
const Text('To delete this panel, tap the trash can icon'),
subtitle: const Text('To delete this panel, tap the trash can icon'),
trailing: const Icon(Icons.delete),
onTap: () {
setState(() {
_data
.removeWhere((Item currentItem) => item == currentItem);
_data.removeWhere((Item currentItem) => item == currentItem);
});
}));
}).toList(),

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [ExpansionTile].
import 'package:flutter/material.dart';
/// Flutter code sample for [ExpansionTile].
void main() => runApp(const ExpansionTileApp());
class ExpansionTileApp extends StatelessWidget {
@ -48,9 +48,7 @@ class _ExpansionTileExampleState extends State<ExpansionTileExample> {
title: const Text('ExpansionTile 2'),
subtitle: const Text('Custom expansion arrow icon'),
trailing: Icon(
_customTileExpanded
? Icons.arrow_drop_down_circle
: Icons.arrow_drop_down,
_customTileExpanded ? Icons.arrow_drop_down_circle : Icons.arrow_drop_down,
),
children: const <Widget>[
ListTile(title: Text('This is tile number 2')),

View file

@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [ExpansionTile] and [ExpansionTileController]
import 'package:flutter/material.dart';
/// Flutter code sample for [ExpansionTile] and [ExpansionTileController].
void main() {
runApp(const ExpansionTileControllerApp());
}
class ExpansionTileControllerApp extends StatefulWidget {
const ExpansionTileControllerApp({ super.key });
const ExpansionTileControllerApp({super.key});
@override
State<ExpansionTileControllerApp> createState() => _ExpansionTileControllerAppState();
@ -23,10 +23,9 @@ class _ExpansionTileControllerAppState extends State<ExpansionTileControllerApp>
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Code Sample for ExpansionTileController.',
theme: ThemeData(useMaterial3: true),
home: Scaffold(
appBar: AppBar(title: const Text('ExpansionTileController Example')),
appBar: AppBar(title: const Text('ExpansionTileController Sample')),
body: Column(
children: <Widget>[
// A controller has been provided to the ExpansionTile because it's

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [FilledButton].
import 'package:flutter/material.dart';
/// Flutter code sample for [FilledButton].
void main() {
runApp(const FilledButtonApp());
}

View file

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for [FilterChip].
import 'package:flutter/material.dart';
/// Flutter code sample for [FilterChip].
enum ExerciseFilter { walking, running, cycling, hiking }
void main() => runApp(const ChipApp());
@ -67,8 +67,7 @@ class _FilterChipExampleState extends State<FilterChipExample> {
),
const SizedBox(height: 10.0),
Text(
'Looking for: ${filters.map(
(ExerciseFilter e) => e.name).join(', ')}',
'Looking for: ${filters.map((ExerciseFilter e) => e.name).join(', ')}',
style: textTheme.labelLarge,
),
],

Some files were not shown because too many files have changed in this diff Show more