Auto-format Framework (#160545)

This auto-formats all *.dart files in the repository outside of the
`engine` subdirectory and enforces that these files stay formatted with
a presubmit check.

**Reviewers:** Please carefully review all the commits except for the
one titled "formatted". The "formatted" commit was auto-generated by
running `dev/tools/format.sh -a -f`. The other commits were hand-crafted
to prepare the repo for the formatting change. I recommend reviewing the
commits one-by-one via the "Commits" tab and avoiding Github's "Files
changed" tab as it will likely slow down your browser because of the
size of this PR.

---------

Co-authored-by: Kate Lovett <katelovett@google.com>
Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
This commit is contained in:
Michael Goderbauer
2024-12-19 12:06:21 -08:00
committed by GitHub
parent 8e0993eda8
commit 5491c8c146
4411 changed files with 455108 additions and 415991 deletions

View File

@@ -8,13 +8,7 @@ import 'package:flutter/services.dart';
/// Flutter code sample for [Action.overridable].
void main() {
runApp(
const MaterialApp(
home: Scaffold(
body: Center(child: VerificationCodeGenerator()),
),
),
);
runApp(const MaterialApp(home: Scaffold(body: Center(child: VerificationCodeGenerator()))));
}
const CopyTextIntent copyTextIntent = CopyTextIntent._();
@@ -32,16 +26,21 @@ class CopyableText extends StatelessWidget {
@override
Widget build(BuildContext context) {
final Action<CopyTextIntent> defaultCopyAction = CallbackAction<CopyTextIntent>(onInvoke: _copy);
final Action<CopyTextIntent> defaultCopyAction = CallbackAction<CopyTextIntent>(
onInvoke: _copy,
);
return Shortcuts(
shortcuts: const <ShortcutActivator, Intent>{
SingleActivator(LogicalKeyboardKey.keyC, control: true): copyTextIntent
SingleActivator(LogicalKeyboardKey.keyC, control: true): copyTextIntent,
},
child: Actions(
actions: <Type, Action<Intent>>{
// The Action is made overridable so the VerificationCodeGenerator
// widget can override how copying is handled.
CopyTextIntent: Action<CopyTextIntent>.overridable(defaultAction: defaultCopyAction, context: context),
CopyTextIntent: Action<CopyTextIntent>.overridable(
defaultAction: defaultCopyAction,
context: context,
),
},
child: Focus(
autofocus: true,
@@ -66,7 +65,9 @@ class VerificationCodeGenerator extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Actions(
actions: <Type, Action<Intent>>{CopyTextIntent: CallbackAction<CopyTextIntent>(onInvoke: _copy)},
actions: <Type, Action<Intent>>{
CopyTextIntent: CallbackAction<CopyTextIntent>(onInvoke: _copy),
},
child: const Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[

View File

@@ -16,9 +16,7 @@ class ActionListenerExampleApp extends StatelessWidget {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('ActionListener Sample')),
body: const Center(
child: ActionListenerExample(),
),
body: const Center(child: ActionListenerExample()),
),
);
}
@@ -54,10 +52,7 @@ class _ActionListenerExampleState extends State<ActionListenerExample> {
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: OutlinedButton(
onPressed: _toggleState,
child: Text(_on ? 'Disable' : 'Enable'),
),
child: OutlinedButton(onPressed: _toggleState, child: Text(_on ? 'Disable' : 'Enable')),
),
if (_on)
Padding(
@@ -65,9 +60,9 @@ class _ActionListenerExampleState extends State<ActionListenerExample> {
child: ActionListener(
listener: (Action<Intent> action) {
if (action.intentType == MyIntent) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text('Action Listener Called'),
));
ScaffoldMessenger.of(
context,
).showSnackBar(const SnackBar(content: Text('Action Listener Called')));
}
},
action: _myAction,

View File

@@ -16,9 +16,7 @@ class ActionsExampleApp extends StatelessWidget {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Actions Sample')),
body: const Center(
child: ActionsExample(),
),
body: const Center(child: ActionsExample()),
),
);
}

View File

@@ -14,18 +14,12 @@ class FocusableActionDetectorExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: FocusableActionDetectorExample(),
);
return const MaterialApp(home: FocusableActionDetectorExample());
}
}
class FadButton extends StatefulWidget {
const FadButton({
super.key,
required this.onPressed,
required this.child,
});
const FadButton({super.key, required this.onPressed, required this.child});
final VoidCallback onPressed;
final Widget child;
@@ -47,9 +41,7 @@ class _FadButtonState extends State<FadButton> {
void initState() {
super.initState();
_actionMap = <Type, Action<Intent>>{
ActivateIntent: CallbackAction<Intent>(
onInvoke: (Intent intent) => _toggleState(),
),
ActivateIntent: CallbackAction<Intent>(onInvoke: (Intent intent) => _toggleState()),
};
}
@@ -93,11 +85,7 @@ class _FadButtonState extends State<FadButton> {
onShowHoverHighlight: _handleHoveHighlight,
child: Row(
children: <Widget>[
Container(
padding: const EdgeInsets.all(10.0),
color: color,
child: widget.child,
),
Container(padding: const EdgeInsets.all(10.0), color: color, child: widget.child),
Container(
width: 30,
height: 30,
@@ -122,9 +110,7 @@ class _FocusableActionDetectorExampleState extends State<FocusableActionDetector
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('FocusableActionDetector Example'),
),
appBar: AppBar(title: const Text('FocusableActionDetector Example')),
body: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,

View File

@@ -90,10 +90,7 @@ class _AnimatedGridSampleState extends State<AnimatedGridSample> {
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
title: const Text(
'AnimatedGrid',
style: TextStyle(fontSize: 30),
),
title: const Text('AnimatedGrid', style: TextStyle(fontSize: 30)),
centerTitle: true,
leading: IconButton(
icon: const Icon(Icons.remove_circle),
@@ -128,7 +125,8 @@ class _AnimatedGridSampleState extends State<AnimatedGridSample> {
}
}
typedef RemovedItemBuilder<T> = Widget Function(T item, BuildContext context, Animation<double> animation);
typedef RemovedItemBuilder<T> =
Widget Function(T item, BuildContext context, Animation<double> animation);
/// Keeps a Dart [List] in sync with an [AnimatedGrid].
///
@@ -140,11 +138,8 @@ typedef RemovedItemBuilder<T> = Widget Function(T item, BuildContext context, An
/// mutate the list must make the same changes to the animated list in terms
/// of [AnimatedGridState.insertItem] and [AnimatedGridState.removeItem].
class ListModel<E> {
ListModel({
required this.listKey,
required this.removedItemBuilder,
Iterable<E>? initialItems,
}) : _items = List<E>.from(initialItems ?? <E>[]);
ListModel({required this.listKey, required this.removedItemBuilder, Iterable<E>? initialItems})
: _items = List<E>.from(initialItems ?? <E>[]);
final GlobalKey<AnimatedGridState> listKey;
final RemovedItemBuilder<E> removedItemBuilder;
@@ -154,21 +149,15 @@ class ListModel<E> {
void insert(int index, E item) {
_items.insert(index, item);
_animatedGrid!.insertItem(
index,
duration: const Duration(milliseconds: 500),
);
_animatedGrid!.insertItem(index, duration: const Duration(milliseconds: 500));
}
E removeAt(int index) {
final E removedItem = _items.removeAt(index);
if (removedItem != null) {
_animatedGrid!.removeItem(
index,
(BuildContext context, Animation<double> animation) {
return removedItemBuilder(removedItem, context, animation);
},
);
_animatedGrid!.removeItem(index, (BuildContext context, Animation<double> animation) {
return removedItemBuilder(removedItem, context, animation);
});
}
return removedItem;
}
@@ -211,7 +200,10 @@ class CardItem extends StatelessWidget {
return Padding(
padding: const EdgeInsets.all(2.0),
child: ScaleTransition(
scale: CurvedAnimation(parent: animation, curve: removing ? Curves.easeInOut : Curves.bounceOut),
scale: CurvedAnimation(
parent: animation,
curve: removing ? Curves.easeInOut : Curves.bounceOut,
),
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: onTap,
@@ -219,9 +211,7 @@ class CardItem extends StatelessWidget {
height: 80.0,
child: Card(
color: Colors.primaries[item % Colors.primaries.length],
child: Center(
child: Text('${item + 1}', style: textStyle),
),
child: Center(child: Text('${item + 1}', style: textStyle)),
),
),
),

View File

@@ -18,7 +18,8 @@ class SliverAnimatedGridSample extends StatefulWidget {
class _SliverAnimatedGridSampleState extends State<SliverAnimatedGridSample> {
final GlobalKey<SliverAnimatedGridState> _listKey = GlobalKey<SliverAnimatedGridState>();
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
final GlobalKey<ScaffoldMessengerState> _scaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();
final GlobalKey<ScaffoldMessengerState> _scaffoldMessengerKey =
GlobalKey<ScaffoldMessengerState>();
late ListModel<int> _list;
int? _selectedItem;
late int _nextItem; // The next item inserted when the user presses the '+' button.
@@ -55,11 +56,7 @@ class _SliverAnimatedGridSampleState extends State<SliverAnimatedGridSample> {
// [AnimatedGridState.removeItem] method's
// [AnimatedGridRemovedItemBuilder] parameter.
Widget _buildRemovedItem(int item, BuildContext context, Animation<double> animation) {
return CardItem(
animation: animation,
removing: true,
item: item,
);
return CardItem(animation: animation, removing: true, item: item);
}
// Insert the "next item" into the list model.
@@ -90,10 +87,7 @@ class _SliverAnimatedGridSampleState extends State<SliverAnimatedGridSample> {
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
title: const Text(
'SliverAnimatedGrid',
style: TextStyle(fontSize: 30),
),
title: const Text('SliverAnimatedGrid', style: TextStyle(fontSize: 30)),
expandedHeight: 60,
centerTitle: true,
backgroundColor: Colors.amber[900],
@@ -129,7 +123,8 @@ class _SliverAnimatedGridSampleState extends State<SliverAnimatedGridSample> {
}
}
typedef RemovedItemBuilder = Widget Function(int item, BuildContext context, Animation<double> animation);
typedef RemovedItemBuilder =
Widget Function(int item, BuildContext context, Animation<double> animation);
// Keeps a Dart [List] in sync with an [AnimatedGrid].
//
@@ -141,11 +136,8 @@ typedef RemovedItemBuilder = Widget Function(int item, BuildContext context, Ani
// mutate the list must make the same changes to the animated list in terms
// of [AnimatedGridState.insertItem] and [AnimatedGrid.removeItem].
class ListModel<E> {
ListModel({
required this.listKey,
required this.removedItemBuilder,
Iterable<E>? initialItems,
}) : _items = List<E>.from(initialItems ?? <E>[]);
ListModel({required this.listKey, required this.removedItemBuilder, Iterable<E>? initialItems})
: _items = List<E>.from(initialItems ?? <E>[]);
final GlobalKey<SliverAnimatedGridState> listKey;
final RemovedItemBuilder removedItemBuilder;
@@ -163,7 +155,8 @@ class ListModel<E> {
if (removedItem != null) {
_animatedGrid.removeItem(
index,
(BuildContext context, Animation<double> animation) => removedItemBuilder(index, context, animation),
(BuildContext context, Animation<double> animation) =>
removedItemBuilder(index, context, animation),
);
}
return removedItem;
@@ -201,13 +194,12 @@ class CardItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(
left: 2.0,
right: 2.0,
top: 2.0,
),
padding: const EdgeInsets.only(left: 2.0, right: 2.0, top: 2.0),
child: ScaleTransition(
scale: CurvedAnimation(parent: animation, curve: removing ? Curves.easeInOut : Curves.bounceOut),
scale: CurvedAnimation(
parent: animation,
curve: removing ? Curves.easeInOut : Curves.bounceOut,
),
child: GestureDetector(
onTap: onTap,
child: SizedBox(

View File

@@ -112,7 +112,8 @@ class _AnimatedListSampleState extends State<AnimatedListSample> {
}
}
typedef RemovedItemBuilder<T> = Widget Function(T item, BuildContext context, Animation<double> animation);
typedef RemovedItemBuilder<T> =
Widget Function(T item, BuildContext context, Animation<double> animation);
/// Keeps a Dart [List] in sync with an [AnimatedList].
///
@@ -124,11 +125,8 @@ typedef RemovedItemBuilder<T> = Widget Function(T item, BuildContext context, An
/// mutate the list must make the same changes to the animated list in terms
/// of [AnimatedListState.insertItem] and [AnimatedListState.removeItem].
class ListModel<E> {
ListModel({
required this.listKey,
required this.removedItemBuilder,
Iterable<E>? initialItems,
}) : _items = List<E>.from(initialItems ?? <E>[]);
ListModel({required this.listKey, required this.removedItemBuilder, Iterable<E>? initialItems})
: _items = List<E>.from(initialItems ?? <E>[]);
final GlobalKey<AnimatedListState> listKey;
final RemovedItemBuilder<E> removedItemBuilder;
@@ -144,12 +142,9 @@ class ListModel<E> {
E removeAt(int index) {
final E removedItem = _items.removeAt(index);
if (removedItem != null) {
_animatedList!.removeItem(
index,
(BuildContext context, Animation<double> animation) {
return removedItemBuilder(removedItem, context, animation);
},
);
_animatedList!.removeItem(index, (BuildContext context, Animation<double> animation) {
return removedItemBuilder(removedItem, context, animation);
});
}
return removedItem;
}
@@ -198,9 +193,7 @@ class CardItem extends StatelessWidget {
height: 80.0,
child: Card(
color: Colors.primaries[item % Colors.primaries.length],
child: Center(
child: Text('Item $item', style: textStyle),
),
child: Center(child: Text('Item $item', style: textStyle)),
),
),
),

View File

@@ -50,10 +50,7 @@ class _AnimatedListSeparatedSampleState extends State<AnimatedListSeparatedSampl
// Used to build separators for items that haven't been removed.
Widget _buildSeparator(BuildContext context, int index, Animation<double> animation) {
return ItemSeparator(
animation: animation,
item: _list[index],
);
return ItemSeparator(animation: animation, item: _list[index]);
}
/// The builder function used to build items that have been removed.
@@ -84,10 +81,7 @@ class _AnimatedListSeparatedSampleState extends State<AnimatedListSeparatedSampl
Widget _buildRemovedSeparator(BuildContext context, int index, Animation<double> animation) {
return SizeTransition(
sizeFactor: animation,
child: ItemSeparator(
animation: animation,
item: null,
)
child: ItemSeparator(animation: animation, item: null),
);
}
@@ -142,7 +136,8 @@ class _AnimatedListSeparatedSampleState extends State<AnimatedListSeparatedSampl
}
}
typedef RemovedItemBuilder<T> = Widget Function(T item, BuildContext context, Animation<double> animation);
typedef RemovedItemBuilder<T> =
Widget Function(T item, BuildContext context, Animation<double> animation);
/// Keeps a Dart [List] in sync with an [AnimatedList.separated].
///
@@ -154,11 +149,8 @@ typedef RemovedItemBuilder<T> = Widget Function(T item, BuildContext context, An
/// mutate the list must make the same changes to the animated list in terms
/// of [AnimatedListState.insertItem] and [AnimatedListState.removeItem].
class ListModel<E> {
ListModel({
required this.listKey,
required this.removedItemBuilder,
Iterable<E>? initialItems,
}) : _items = List<E>.from(initialItems ?? <E>[]);
ListModel({required this.listKey, required this.removedItemBuilder, Iterable<E>? initialItems})
: _items = List<E>.from(initialItems ?? <E>[]);
final GlobalKey<AnimatedListState> listKey;
final RemovedItemBuilder<E> removedItemBuilder;
@@ -174,12 +166,9 @@ class ListModel<E> {
E removeAt(int index) {
final E removedItem = _items.removeAt(index);
if (removedItem != null) {
_animatedList!.removeItem(
index,
(BuildContext context, Animation<double> animation) {
return removedItemBuilder(removedItem, context, animation);
},
);
_animatedList!.removeItem(index, (BuildContext context, Animation<double> animation) {
return removedItemBuilder(removedItem, context, animation);
});
}
return removedItem;
}
@@ -228,9 +217,7 @@ class CardItem extends StatelessWidget {
height: 80.0,
child: Card(
color: Colors.primaries[item % Colors.primaries.length],
child: Center(
child: Text('Item $item', style: textStyle),
),
child: Center(child: Text('Item $item', style: textStyle)),
),
),
),
@@ -247,11 +234,8 @@ class CardItem extends StatelessWidget {
/// This widget's height is based on the [animation] parameter, it
/// varies from 0 to 40 as the animation varies from 0.0 to 1.0.
class ItemSeparator extends StatelessWidget {
const ItemSeparator({
super.key,
required this.animation,
required this.item,
}) : assert(item == null || item >= 0);
const ItemSeparator({super.key, required this.animation, required this.item})
: assert(item == null || item >= 0);
final Animation<double> animation;
final int? item;
@@ -268,7 +252,10 @@ class ItemSeparator extends StatelessWidget {
child: Card(
color: item == null ? Colors.grey : Colors.primaries[item! % Colors.primaries.length],
child: Center(
child: Text(item == null ? 'Removing separator' : 'Separator $item', style: textStyle),
child: Text(
item == null ? 'Removing separator' : 'Separator $item',
style: textStyle,
),
),
),
),

View File

@@ -18,7 +18,8 @@ class SliverAnimatedListSample extends StatefulWidget {
class _SliverAnimatedListSampleState extends State<SliverAnimatedListSample> {
final GlobalKey<SliverAnimatedListState> _listKey = GlobalKey<SliverAnimatedListState>();
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
final GlobalKey<ScaffoldMessengerState> _scaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();
final GlobalKey<ScaffoldMessengerState> _scaffoldMessengerKey =
GlobalKey<ScaffoldMessengerState>();
late ListModel<int> _list;
int? _selectedItem;
late int _nextItem; // The next item inserted when the user presses the '+' button.
@@ -56,10 +57,7 @@ class _SliverAnimatedListSampleState extends State<SliverAnimatedListSample> {
/// widget will be used by the [AnimatedListState.removeItem] method's
/// [AnimatedRemovedItemBuilder] parameter.
Widget _buildRemovedItem(int item, BuildContext context, Animation<double> animation) {
return CardItem(
animation: animation,
item: item,
);
return CardItem(animation: animation, item: item);
}
// Insert the "next item" into the list model.
@@ -76,12 +74,11 @@ class _SliverAnimatedListSampleState extends State<SliverAnimatedListSample> {
_selectedItem = null;
});
} else {
_scaffoldMessengerKey.currentState!.showSnackBar(const SnackBar(
content: Text(
'Select an item to remove from the list.',
style: TextStyle(fontSize: 20),
_scaffoldMessengerKey.currentState!.showSnackBar(
const SnackBar(
content: Text('Select an item to remove from the list.', style: TextStyle(fontSize: 20)),
),
));
);
}
}
@@ -94,10 +91,7 @@ class _SliverAnimatedListSampleState extends State<SliverAnimatedListSample> {
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
title: const Text(
'SliverAnimatedList',
style: TextStyle(fontSize: 30),
),
title: const Text('SliverAnimatedList', style: TextStyle(fontSize: 30)),
expandedHeight: 60,
centerTitle: true,
backgroundColor: Colors.amber[900],
@@ -128,7 +122,8 @@ class _SliverAnimatedListSampleState extends State<SliverAnimatedListSample> {
}
}
typedef RemovedItemBuilder<E> = Widget Function(E item, BuildContext context, Animation<double> animation);
typedef RemovedItemBuilder<E> =
Widget Function(E item, BuildContext context, Animation<double> animation);
// Keeps a Dart [List] in sync with an [AnimatedList].
//
@@ -140,11 +135,8 @@ typedef RemovedItemBuilder<E> = Widget Function(E item, BuildContext context, An
// mutate the list must make the same changes to the animated list in terms
// of [AnimatedListState.insertItem] and [AnimatedList.removeItem].
class ListModel<E> {
ListModel({
required this.listKey,
required this.removedItemBuilder,
Iterable<E>? initialItems,
}) : _items = List<E>.from(initialItems ?? <E>[]);
ListModel({required this.listKey, required this.removedItemBuilder, Iterable<E>? initialItems})
: _items = List<E>.from(initialItems ?? <E>[]);
final GlobalKey<SliverAnimatedListState> listKey;
final RemovedItemBuilder<E> removedItemBuilder;
@@ -162,7 +154,8 @@ class ListModel<E> {
if (removedItem != null) {
_animatedList.removeItem(
index,
(BuildContext context, Animation<double> animation) => removedItemBuilder(removedItem, context, animation),
(BuildContext context, Animation<double> animation) =>
removedItemBuilder(removedItem, context, animation),
);
}
return removedItem;
@@ -198,11 +191,7 @@ class CardItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(
left: 2.0,
right: 2.0,
top: 2.0,
),
padding: const EdgeInsets.only(left: 2.0, right: 2.0, top: 2.0),
child: SizeTransition(
sizeFactor: animation,
child: GestureDetector(
@@ -212,10 +201,7 @@ class CardItem extends StatelessWidget {
child: Card(
color: selected ? Colors.black12 : Colors.primaries[item % Colors.primaries.length],
child: Center(
child: Text(
'Item $item',
style: Theme.of(context).textTheme.headlineMedium,
),
child: Text('Item $item', style: Theme.of(context).textTheme.headlineMedium),
),
),
),

View File

@@ -19,23 +19,14 @@ class AnimatedSizeExampleApp extends StatelessWidget {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('AnimatedSize Sample')),
body: const Center(
child: AnimatedSizeExample(
duration: duration,
curve: curve,
),
),
body: const Center(child: AnimatedSizeExample(duration: duration, curve: curve)),
),
);
}
}
class AnimatedSizeExample extends StatefulWidget {
const AnimatedSizeExample({
required this.duration,
required this.curve,
super.key,
});
const AnimatedSizeExample({required this.duration, required this.curve, super.key});
final Duration duration;
@@ -63,9 +54,7 @@ class _AnimatedSizeExampleState extends State<AnimatedSizeExample> {
curve: widget.curve,
child: SizedBox.square(
dimension: _isSelected ? 250.0 : 100.0,
child: const Center(
child: FlutterLogo(size: 75.0),
),
child: const Center(child: FlutterLogo(size: 75.0)),
),
),
),

View File

@@ -13,9 +13,7 @@ class AnimatedSwitcherExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: AnimatedSwitcherExample(),
);
return const MaterialApp(home: AnimatedSwitcherExample());
}
}
@@ -23,8 +21,7 @@ class AnimatedSwitcherExample extends StatefulWidget {
const AnimatedSwitcherExample({super.key});
@override
State<AnimatedSwitcherExample> createState() =>
_AnimatedSwitcherExampleState();
State<AnimatedSwitcherExample> createState() => _AnimatedSwitcherExampleState();
}
class _AnimatedSwitcherExampleState extends State<AnimatedSwitcherExample> {

View File

@@ -17,11 +17,16 @@ class WidgetsAppExampleApp extends StatelessWidget {
title: 'Example',
color: const Color(0xFF000000),
home: const Center(child: Text('Hello World')),
pageRouteBuilder: <T>(RouteSettings settings, WidgetBuilder builder) => PageRouteBuilder<T>(
settings: settings,
pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) =>
builder(context),
),
pageRouteBuilder:
<T>(RouteSettings settings, WidgetBuilder builder) => PageRouteBuilder<T>(
settings: settings,
pageBuilder:
(
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
) => builder(context),
),
);
}
}

View File

@@ -16,9 +16,7 @@ class AppLifecycleListenerExample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(body: AppLifecycleDisplay()),
);
return const MaterialApp(home: Scaffold(body: AppLifecycleDisplay()));
}
}

View File

@@ -18,9 +18,7 @@ class AppLifecycleListenerExample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(body: ApplicationExitControl()),
);
return const MaterialApp(home: Scaffold(body: ApplicationExitControl()));
}
}
@@ -39,9 +37,7 @@ class _ApplicationExitControlState extends State<ApplicationExitControl> {
@override
void initState() {
super.initState();
_listener = AppLifecycleListener(
onExitRequested: _handleExitRequest,
);
_listener = AppLifecycleListener(onExitRequested: _handleExitRequest);
}
@override
@@ -94,10 +90,7 @@ class _ApplicationExitControlState extends State<ApplicationExitControl> {
onChanged: _radioChanged,
),
const SizedBox(height: 30),
ElevatedButton(
onPressed: _quit,
child: const Text('Quit'),
),
ElevatedButton(onPressed: _quit, child: const Text('Quit')),
const SizedBox(height: 30),
Text('Exit Request: $_lastExitResponse'),
],

View File

@@ -13,9 +13,7 @@ class FutureBuilderExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: FutureBuilderExample(),
);
return const MaterialApp(home: FutureBuilderExample());
}
}
@@ -43,11 +41,7 @@ class _FutureBuilderExampleState extends State<FutureBuilderExample> {
List<Widget> children;
if (snapshot.hasData) {
children = <Widget>[
const Icon(
Icons.check_circle_outline,
color: Colors.green,
size: 60,
),
const Icon(Icons.check_circle_outline, color: Colors.green, size: 60),
Padding(
padding: const EdgeInsets.only(top: 16),
child: Text('Result: ${snapshot.data}'),
@@ -55,11 +49,7 @@ class _FutureBuilderExampleState extends State<FutureBuilderExample> {
];
} else if (snapshot.hasError) {
children = <Widget>[
const Icon(
Icons.error_outline,
color: Colors.red,
size: 60,
),
const Icon(Icons.error_outline, color: Colors.red, size: 60),
Padding(
padding: const EdgeInsets.only(top: 16),
child: Text('Error: ${snapshot.error}'),
@@ -67,22 +57,12 @@ class _FutureBuilderExampleState extends State<FutureBuilderExample> {
];
} else {
children = const <Widget>[
SizedBox(
width: 60,
height: 60,
child: CircularProgressIndicator(),
),
Padding(
padding: EdgeInsets.only(top: 16),
child: Text('Awaiting result...'),
),
SizedBox(width: 60, height: 60, child: CircularProgressIndicator()),
Padding(padding: EdgeInsets.only(top: 16), child: Text('Awaiting result...')),
];
}
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: children,
),
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: children),
);
},
),

View File

@@ -17,17 +17,12 @@ class StreamBuilderExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: StreamBuilderExample(delay: delay),
);
return const MaterialApp(home: StreamBuilderExample(delay: delay));
}
}
class StreamBuilderExample extends StatefulWidget {
const StreamBuilderExample({
required this.delay,
super.key,
});
const StreamBuilderExample({required this.delay, super.key});
final Duration delay;
@@ -77,10 +72,7 @@ class _StreamBuilderExampleState extends State<StreamBuilderExample> {
}
class BidsStatus extends StatelessWidget {
const BidsStatus({
required this.bids,
super.key,
});
const BidsStatus({required this.bids, super.key});
final Stream<int>? bids;
@@ -92,11 +84,7 @@ class BidsStatus extends StatelessWidget {
List<Widget> children;
if (snapshot.hasError) {
children = <Widget>[
const Icon(
Icons.error_outline,
color: Colors.red,
size: 60,
),
const Icon(Icons.error_outline, color: Colors.red, size: 60),
Padding(
padding: const EdgeInsets.only(top: 16),
child: Text('Error: ${snapshot.error}'),
@@ -114,63 +102,31 @@ class BidsStatus extends StatelessWidget {
switch (snapshot.connectionState) {
case ConnectionState.none:
children = const <Widget>[
Icon(
Icons.info,
color: Colors.blue,
size: 60,
),
Padding(
padding: EdgeInsets.only(top: 16),
child: Text('Select a lot'),
),
Icon(Icons.info, color: Colors.blue, size: 60),
Padding(padding: EdgeInsets.only(top: 16), child: Text('Select a lot')),
];
case ConnectionState.waiting:
children = const <Widget>[
SizedBox(
width: 60,
height: 60,
child: CircularProgressIndicator(),
),
Padding(
padding: EdgeInsets.only(top: 16),
child: Text('Awaiting bids...'),
),
SizedBox(width: 60, height: 60, child: CircularProgressIndicator()),
Padding(padding: EdgeInsets.only(top: 16), child: Text('Awaiting bids...')),
];
case ConnectionState.active:
children = <Widget>[
const Icon(
Icons.check_circle_outline,
color: Colors.green,
size: 60,
),
Padding(
padding: const EdgeInsets.only(top: 16),
child: Text('\$${snapshot.data}'),
),
const Icon(Icons.check_circle_outline, color: Colors.green, size: 60),
Padding(padding: const EdgeInsets.only(top: 16), child: Text('\$${snapshot.data}')),
];
case ConnectionState.done:
children = <Widget>[
const Icon(
Icons.info,
color: Colors.blue,
size: 60,
),
const Icon(Icons.info, color: Colors.blue, size: 60),
Padding(
padding: const EdgeInsets.only(top: 16),
child: Text(
snapshot.hasData
? '\$${snapshot.data} (closed)'
: '(closed)',
),
child: Text(snapshot.hasData ? '\$${snapshot.data} (closed)' : '(closed)'),
),
];
}
}
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: children,
);
return Column(mainAxisAlignment: MainAxisAlignment.center, children: children);
},
);
}

View File

@@ -15,12 +15,8 @@ class AutocompleteExampleApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('RawAutocomplete Basic'),
),
body: const Center(
child: AutocompleteBasicExample(),
),
appBar: AppBar(title: const Text('RawAutocomplete Basic')),
body: const Center(child: AutocompleteBasicExample()),
),
);
}
@@ -29,11 +25,7 @@ class AutocompleteExampleApp extends StatelessWidget {
class AutocompleteBasicExample extends StatelessWidget {
const AutocompleteBasicExample({super.key});
static const List<String> _options = <String>[
'aardvark',
'bobcat',
'chameleon',
];
static const List<String> _options = <String>['aardvark', 'bobcat', 'chameleon'];
@override
Widget build(BuildContext context) {
@@ -77,9 +69,7 @@ class AutocompleteBasicExample extends StatelessWidget {
onTap: () {
onSelected(option);
},
child: ListTile(
title: Text(option),
),
child: ListTile(title: Text(option)),
);
},
),

View File

@@ -15,12 +15,8 @@ class AutocompleteExampleApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('RawAutocomplete Custom Type'),
),
body: const Center(
child: AutocompleteCustomTypeExample(),
),
appBar: AppBar(title: const Text('RawAutocomplete Custom Type')),
body: const Center(child: AutocompleteCustomTypeExample()),
),
);
}
@@ -29,10 +25,7 @@ class AutocompleteExampleApp extends StatelessWidget {
// An example of a type that someone might want to autocomplete a list of.
@immutable
class User {
const User({
required this.email,
required this.name,
});
const User({required this.email, required this.name});
final String email;
final String name;
@@ -90,7 +83,11 @@ class AutocompleteCustomTypeExample extends StatelessWidget {
},
);
},
optionsViewBuilder: (BuildContext context, AutocompleteOnSelected<User> onSelected, Iterable<User> options) {
optionsViewBuilder: (
BuildContext context,
AutocompleteOnSelected<User> onSelected,
Iterable<User> options,
) {
return Align(
alignment: Alignment.topLeft,
child: Material(
@@ -106,9 +103,7 @@ class AutocompleteCustomTypeExample extends StatelessWidget {
onTap: () {
onSelected(option);
},
child: ListTile(
title: Text(_displayStringForOption(option)),
),
child: ListTile(title: Text(_displayStringForOption(option))),
);
},
),

View File

@@ -15,12 +15,8 @@ class AutocompleteExampleApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('RawAutocomplete Form'),
),
body: const Center(
child: AutocompleteFormExample(),
),
appBar: AppBar(title: const Text('RawAutocomplete Form')),
body: const Center(child: AutocompleteFormExample()),
),
);
}
@@ -39,11 +35,7 @@ class AutocompleteFormExampleState extends State<AutocompleteFormExample> {
String? _dropdownValue;
String? _autocompleteSelection;
static const List<String> _options = <String>[
'aardvark',
'bobcat',
'chameleon',
];
static const List<String> _options = <String>['aardvark', 'bobcat', 'chameleon'];
@override
Widget build(BuildContext context) {
@@ -62,12 +54,12 @@ class AutocompleteFormExampleState extends State<AutocompleteFormExample> {
_dropdownValue = newValue;
});
},
items: <String>['One', 'Two', 'Free', 'Four'].map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
items:
<String>['One', 'Two', 'Free', 'Four'].map<DropdownMenuItem<String>>((
String value,
) {
return DropdownMenuItem<String>(value: value, child: Text(value));
}).toList(),
validator: (String? value) {
if (value == null) {
return 'Must make a selection.';
@@ -77,9 +69,7 @@ class AutocompleteFormExampleState extends State<AutocompleteFormExample> {
),
TextFormField(
controller: _textEditingController,
decoration: const InputDecoration(
hintText: 'This is a regular TextFormField',
),
decoration: const InputDecoration(hintText: 'This is a regular TextFormField'),
validator: (String? value) {
if (value == null || value.isEmpty) {
return "Can't be empty.";
@@ -106,9 +96,7 @@ class AutocompleteFormExampleState extends State<AutocompleteFormExample> {
) {
return TextFormField(
controller: textEditingController,
decoration: const InputDecoration(
hintText: 'This is a RawAutocomplete!',
),
decoration: const InputDecoration(hintText: 'This is a RawAutocomplete!'),
focusNode: focusNode,
onFieldSubmitted: (String value) {
onFieldSubmitted();
@@ -141,9 +129,7 @@ class AutocompleteFormExampleState extends State<AutocompleteFormExample> {
onTap: () {
onSelected(option);
},
child: ListTile(
title: Text(option),
),
child: ListTile(title: Text(option)),
);
},
),

View File

@@ -13,17 +13,11 @@ class AutocompleteExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: RawAutocompleteSplit(),
);
return const MaterialApp(home: RawAutocompleteSplit());
}
}
const List<String> _options = <String>[
'aardvark',
'bobcat',
'chameleon',
];
const List<String> _options = <String>['aardvark', 'bobcat', 'chameleon'];
class RawAutocompleteSplit extends StatefulWidget {
const RawAutocompleteSplit({super.key});
@@ -45,9 +39,7 @@ class RawAutocompleteSplitState extends State<RawAutocompleteSplit> {
title: TextFormField(
controller: _textEditingController,
focusNode: _focusNode,
decoration: const InputDecoration(
hintText: 'Split RawAutocomplete App',
),
decoration: const InputDecoration(hintText: 'Split RawAutocomplete App'),
onFieldSubmitted: (String value) {
RawAutocomplete.onFieldSubmitted<String>(_autocompleteKey);
},
@@ -72,16 +64,17 @@ class RawAutocompleteSplitState extends State<RawAutocompleteSplit> {
return Material(
elevation: 4.0,
child: ListView(
children: options
.map((String option) => GestureDetector(
onTap: () {
onSelected(option);
},
child: ListTile(
title: Text(option),
children:
options
.map(
(String option) => GestureDetector(
onTap: () {
onSelected(option);
},
child: ListTile(title: Text(option)),
),
))
.toList(),
)
.toList(),
),
);
},

View File

@@ -80,15 +80,11 @@ class _AutofillGroupExampleState extends State<AutofillGroupExample> {
children: <Widget>[
TextField(
controller: billingAddress1,
autofillHints: const <String>[
AutofillHints.streetAddressLine1,
],
autofillHints: const <String>[AutofillHints.streetAddressLine1],
),
TextField(
controller: billingAddress2,
autofillHints: const <String>[
AutofillHints.streetAddressLine2,
],
autofillHints: const <String>[AutofillHints.streetAddressLine2],
),
],
),
@@ -105,9 +101,7 @@ class _AutofillGroupExampleState extends State<AutofillGroupExample> {
),
TextField(
controller: creditCardSecurityCode,
autofillHints: const <String>[
AutofillHints.creditCardSecurityCode,
],
autofillHints: const <String>[AutofillHints.creditCardSecurityCode],
),
],
),

View File

@@ -16,9 +16,7 @@ class AbsorbPointerApp extends StatelessWidget {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('AbsorbPointer Sample')),
body: const Center(
child: AbsorbPointerExample(),
),
body: const Center(child: AbsorbPointerExample()),
),
);
}
@@ -32,22 +30,13 @@ class AbsorbPointerExample extends StatelessWidget {
return Stack(
alignment: AlignmentDirectional.center,
children: <Widget>[
SizedBox(
width: 200.0,
height: 100.0,
child: ElevatedButton(
onPressed: () {},
child: null,
),
),
SizedBox(width: 200.0, height: 100.0, child: ElevatedButton(onPressed: () {}, child: null)),
SizedBox(
width: 100.0,
height: 200.0,
child: AbsorbPointer(
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue.shade200,
),
style: ElevatedButton.styleFrom(backgroundColor: Colors.blue.shade200),
onPressed: () {},
child: null,
),

View File

@@ -32,12 +32,7 @@ class AspectRatioExample extends StatelessWidget {
alignment: Alignment.center,
width: double.infinity,
height: 100.0,
child: AspectRatio(
aspectRatio: 16 / 9,
child: Container(
color: Colors.green,
),
),
child: AspectRatio(aspectRatio: 16 / 9, child: Container(color: Colors.green)),
);
}
}

View File

@@ -34,11 +34,7 @@ class AspectRatioExample extends StatelessWidget {
height: 100.0,
child: AspectRatio(
aspectRatio: 2.0,
child: Container(
width: 100.0,
height: 50.0,
color: Colors.green,
),
child: Container(width: 100.0, height: 50.0, color: Colors.green),
),
);
}

View File

@@ -34,11 +34,7 @@ class AspectRatioExample extends StatelessWidget {
height: 100.0,
child: AspectRatio(
aspectRatio: 0.5,
child: Container(
width: 100.0,
height: 50.0,
color: Colors.green,
),
child: Container(width: 100.0, height: 50.0, color: Colors.green),
),
);
}

View File

@@ -35,10 +35,7 @@ class ClipRRectExample extends StatelessWidget {
children: <Widget>[
Container(
alignment: Alignment.center,
constraints: const BoxConstraints(
maxWidth: 300,
maxHeight: 100,
),
constraints: const BoxConstraints(maxWidth: 300, maxHeight: 100),
color: Colors.blue,
child: const Text('No ClipRRect', style: style),
),
@@ -46,10 +43,7 @@ class ClipRRectExample extends StatelessWidget {
borderRadius: BorderRadius.circular(30.0),
child: Container(
alignment: Alignment.center,
constraints: const BoxConstraints(
maxWidth: 300,
maxHeight: 100,
),
constraints: const BoxConstraints(maxWidth: 300, maxHeight: 100),
color: Colors.green,
child: const Text('ClipRRect', style: style),
),
@@ -63,10 +57,7 @@ class ClipRRectExample extends StatelessWidget {
),
child: Container(
alignment: Alignment.center,
constraints: const BoxConstraints(
maxWidth: 300,
maxHeight: 100,
),
constraints: const BoxConstraints(maxWidth: 300, maxHeight: 100),
color: Colors.purple,
child: const Text('ClipRRect', style: style),
),

View File

@@ -32,10 +32,7 @@ class ClipRRectExample extends StatelessWidget {
constraints: const BoxConstraints.expand(),
// Add a FittedBox to make ClipRRect sized accordingly to the image it contains
child: FittedBox(
child: ClipRRect(
borderRadius: BorderRadius.circular(40.0),
child: const _FakedImage(),
),
child: ClipRRect(borderRadius: BorderRadius.circular(40.0), child: const _FakedImage()),
),
);
}

View File

@@ -18,9 +18,7 @@ class CustomMultiChildLayoutApp extends StatelessWidget {
// TRY THIS: Try changing the direction here and hot-reloading to
// see the layout change.
textDirection: TextDirection.ltr,
child: Scaffold(
body: CustomMultiChildLayoutExample(),
),
child: Scaffold(body: CustomMultiChildLayoutExample()),
),
);
}

View File

@@ -15,9 +15,7 @@ class ExpandedApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Expanded Column Sample'),
),
appBar: AppBar(title: const Text('Expanded Column Sample')),
body: const ExpandedExample(),
),
);
@@ -32,22 +30,9 @@ class ExpandedExample extends StatelessWidget {
return Center(
child: Column(
children: <Widget>[
Container(
color: Colors.blue,
height: 100,
width: 100,
),
Expanded(
child: Container(
color: Colors.amber,
width: 100,
),
),
Container(
color: Colors.blue,
height: 100,
width: 100,
),
Container(color: Colors.blue, height: 100, width: 100),
Expanded(child: Container(color: Colors.amber, width: 100)),
Container(color: Colors.blue, height: 100, width: 100),
],
),
);

View File

@@ -15,9 +15,7 @@ class ExpandedApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Expanded Row Sample'),
),
appBar: AppBar(title: const Text('Expanded Row Sample')),
body: const ExpandedExample(),
),
);
@@ -32,24 +30,9 @@ class ExpandedExample extends StatelessWidget {
return Center(
child: Row(
children: <Widget>[
Expanded(
flex: 2,
child: Container(
color: Colors.amber,
height: 100,
),
),
Container(
color: Colors.blue,
height: 100,
width: 50,
),
Expanded(
child: Container(
color: Colors.amber,
height: 100,
),
),
Expanded(flex: 2, child: Container(color: Colors.amber, height: 100)),
Container(color: Colors.blue, height: 100, width: 50),
Expanded(child: Container(color: Colors.amber, height: 100)),
],
),
);

View File

@@ -16,9 +16,7 @@ class FittedBoxApp extends StatelessWidget {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('FittedBox Sample')),
body: const Center(
child: FittedBoxExample(),
),
body: const Center(child: FittedBoxExample()),
),
);
}

View File

@@ -14,12 +14,7 @@ class FlowApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Flow Example'),
),
body: const FlowMenu(),
),
home: Scaffold(appBar: AppBar(title: const Text('Flow Example')), body: const FlowMenu()),
);
}
}
@@ -51,10 +46,7 @@ class _FlowMenuState extends State<FlowMenu> with SingleTickerProviderStateMixin
@override
void initState() {
super.initState();
menuAnimation = AnimationController(
duration: const Duration(milliseconds: 250),
vsync: this,
);
menuAnimation = AnimationController(duration: const Duration(milliseconds: 250), vsync: this);
}
Widget flowMenuItem(IconData icon) {
@@ -68,13 +60,11 @@ class _FlowMenuState extends State<FlowMenu> with SingleTickerProviderStateMixin
constraints: BoxConstraints.tight(Size(buttonDiameter, buttonDiameter)),
onPressed: () {
_updateMenu(icon);
menuAnimation.status == AnimationStatus.completed ? menuAnimation.reverse() : menuAnimation.forward();
menuAnimation.status == AnimationStatus.completed
? menuAnimation.reverse()
: menuAnimation.forward();
},
child: Icon(
icon,
color: Colors.white,
size: 45.0,
),
child: Icon(icon, color: Colors.white, size: 45.0),
),
);
}
@@ -103,14 +93,7 @@ class FlowMenuDelegate extends FlowDelegate {
double dx = 0.0;
for (int i = 0; i < context.childCount; ++i) {
dx = context.getChildSize(i)!.width * i;
context.paintChild(
i,
transform: Matrix4.translationValues(
dx * menuAnimation.value,
0,
0,
),
);
context.paintChild(i, transform: Matrix4.translationValues(dx * menuAnimation.value, 0, 0));
}
}
}

View File

@@ -33,12 +33,7 @@ class FractionallySizedBoxExample extends StatelessWidget {
heightFactor: 0.5,
alignment: FractionalOffset.center,
child: DecoratedBox(
decoration: BoxDecoration(
border: Border.all(
color: Colors.blue,
width: 4,
),
),
decoration: BoxDecoration(border: Border.all(color: Colors.blue, width: 4)),
),
),
);

View File

@@ -15,10 +15,7 @@ class IgnorePointerApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
centerTitle: true,
title: const Text('IgnorePointer Sample'),
),
appBar: AppBar(centerTitle: true, title: const Text('IgnorePointer Sample')),
body: const Center(child: IgnorePointerExample()),
),
);
@@ -49,9 +46,7 @@ class _IgnorePointerExampleState extends State<IgnorePointerExample> {
IgnorePointer(
ignoring: ignoring,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.all(24.0),
),
style: ElevatedButton.styleFrom(padding: const EdgeInsets.all(24.0)),
onPressed: () {},
child: const Text('Click me!'),
),
@@ -60,9 +55,7 @@ class _IgnorePointerExampleState extends State<IgnorePointerExample> {
onPressed: () {
setIgnoring(!ignoring);
},
child: Text(
ignoring ? 'Set ignoring to false' : 'Set ignoring to true',
),
child: Text(ignoring ? 'Set ignoring to false' : 'Set ignoring to true'),
),
],
);

View File

@@ -77,7 +77,7 @@ class _IndexedStackExampleState extends State<IndexedStackExample> {
IndexedStack(
index: index,
children: <Widget>[for (final String name in names) PersonTracker(name: name)],
)
),
],
),
GestureDetector(
@@ -93,7 +93,7 @@ class _IndexedStackExampleState extends State<IndexedStackExample> {
child: const Icon(Icons.chevron_right, key: Key('gesture2')),
),
],
)
),
],
);
}
@@ -131,7 +131,7 @@ class _PersonTrackerState extends State<PersonTracker> {
});
},
label: const Text('Increment'),
)
),
],
),
);

View File

@@ -16,9 +16,7 @@ class ListenerApp extends StatelessWidget {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Listener Sample')),
body: const Center(
child: ListenerExample(),
),
body: const Center(child: ListenerExample()),
),
);
}
@@ -76,9 +74,7 @@ class _ListenerExampleState extends State<ListenerExample> {
'$_downCounter presses\n$_upCounter releases',
style: Theme.of(context).textTheme.headlineMedium,
),
Text(
'The cursor is here: (${x.toStringAsFixed(2)}, ${y.toStringAsFixed(2)})',
),
Text('The cursor is here: (${x.toStringAsFixed(2)}, ${y.toStringAsFixed(2)})'),
],
),
),

View File

@@ -16,9 +16,7 @@ class MouseRegionApp extends StatelessWidget {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('MouseRegion Sample')),
body: const Center(
child: MouseRegionExample(),
),
body: const Center(child: MouseRegionExample()),
),
);
}
@@ -74,9 +72,7 @@ class _MouseRegionExampleState extends State<MouseRegionExample> {
'$_enterCounter Entries\n$_exitCounter Exits',
style: Theme.of(context).textTheme.headlineMedium,
),
Text(
'The cursor is here: (${x.toStringAsFixed(2)}, ${y.toStringAsFixed(2)})',
),
Text('The cursor is here: (${x.toStringAsFixed(2)}, ${y.toStringAsFixed(2)})'),
],
),
),

View File

@@ -16,9 +16,7 @@ class MouseRegionApp extends StatelessWidget {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('MouseRegion.onExit Sample')),
body: const Center(
child: MouseRegionExample(),
),
body: const Center(child: MouseRegionExample()),
),
);
}

View File

@@ -16,9 +16,7 @@ class MouseRegionApp extends StatelessWidget {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('MouseRegion.onExit Sample')),
body: const Center(
child: MouseRegionExample(),
),
body: const Center(child: MouseRegionExample()),
),
);
}
@@ -60,24 +58,25 @@ class _MyTimedButton extends State<MyTimedButton> {
width: 100,
height: 100,
child: MouseRegion(
child: regionIsHidden
? null
: MouseRegion(
onEnter: (_) {
widget.onEnterButton();
setState(() {
hovered = true;
});
startCountdown();
},
onExit: (_) {
setState(() {
hovered = false;
});
widget.onExitButton();
},
child: Container(color: Colors.red),
),
child:
regionIsHidden
? null
: MouseRegion(
onEnter: (_) {
widget.onEnterButton();
setState(() {
hovered = true;
});
startCountdown();
},
onExit: (_) {
setState(() {
hovered = false;
});
widget.onExitButton();
},
child: Container(color: Colors.red),
),
),
);
}

View File

@@ -16,9 +16,7 @@ class OffstageApp extends StatelessWidget {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Offstage Sample')),
body: const Center(
child: OffstageExample(),
),
body: const Center(child: OffstageExample()),
),
);
}
@@ -45,13 +43,7 @@ class _OffstageExampleState extends State<OffstageExample> {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Offstage(
offstage: _offstage,
child: FlutterLogo(
key: _key,
size: 150.0,
),
),
Offstage(offstage: _offstage, child: FlutterLogo(key: _key, size: 150.0)),
Text('Flutter logo is offstage: $_offstage'),
ElevatedButton(
child: const Text('Toggle Offstage Value'),
@@ -63,14 +55,13 @@ class _OffstageExampleState extends State<OffstageExample> {
),
if (_offstage)
ElevatedButton(
child: const Text('Get Flutter Logo size'),
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Flutter Logo size is ${_getFlutterLogoSize()}'),
),
);
}),
child: const Text('Get Flutter Logo size'),
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Flutter Logo size is ${_getFlutterLogoSize()}')),
);
},
),
],
);
}

View File

@@ -16,9 +16,7 @@ class OverflowBoxApp extends StatelessWidget {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('OverflowBox Sample')),
body: const Center(
child: OverflowBoxExample(),
),
body: const Center(child: OverflowBoxExample()),
),
);
}

View File

@@ -15,9 +15,7 @@ class PhysicalShapeApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('PhysicalShape Sample'),
),
appBar: AppBar(title: const Text('PhysicalShape Sample')),
body: const Center(child: PhysicalShapeExample()),
),
);
@@ -32,22 +30,14 @@ class PhysicalShapeExample extends StatelessWidget {
return PhysicalShape(
elevation: 5.0,
clipper: ShapeBorderClipper(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0)),
),
color: Colors.orange,
child: const SizedBox(
height: 200.0,
width: 200.0,
child: Center(
child: Text(
'Hello, World!',
style: TextStyle(
color: Colors.white,
fontSize: 20.0,
),
),
child: Text('Hello, World!', style: TextStyle(color: Colors.white, fontSize: 20.0)),
),
),
);

View File

@@ -29,7 +29,8 @@ class WidgetBindingsObserverSample extends StatefulWidget {
State<WidgetBindingsObserverSample> createState() => _WidgetBindingsObserverSampleState();
}
class _WidgetBindingsObserverSampleState extends State<WidgetBindingsObserverSample> with WidgetsBindingObserver {
class _WidgetBindingsObserverSampleState extends State<WidgetBindingsObserverSample>
with WidgetsBindingObserver {
final List<AppLifecycleState> _stateHistoryList = <AppLifecycleState>[];
@override

View File

@@ -31,19 +31,13 @@ class ColorFilteredExample extends StatelessWidget {
child: Column(
children: <Widget>[
ColorFiltered(
colorFilter: const ColorFilter.mode(
Colors.red,
BlendMode.modulate,
),
colorFilter: const ColorFilter.mode(Colors.red, BlendMode.modulate),
child: Image.network(
'https://flutter.github.io/assets-for-api-docs/assets/widgets/owl-2.jpg',
),
),
ColorFiltered(
colorFilter: const ColorFilter.mode(
Colors.grey,
BlendMode.saturation,
),
colorFilter: const ColorFilter.mode(Colors.grey, BlendMode.saturation),
child: Image.network(
'https://flutter.github.io/assets-for-api-docs/assets/widgets/owl.jpg',
),

View File

@@ -39,20 +39,14 @@ class _DismissibleExampleState extends State<DismissibleExample> {
padding: const EdgeInsets.symmetric(vertical: 16),
itemBuilder: (BuildContext context, int index) {
return Dismissible(
background: Container(
color: Colors.green,
),
background: Container(color: Colors.green),
key: ValueKey<int>(items[index]),
onDismissed: (DismissDirection direction) {
setState(() {
items.removeAt(index);
});
},
child: ListTile(
title: Text(
'Item ${items[index]}',
),
),
child: ListTile(title: Text('Item ${items[index]}')),
);
},
);

View File

@@ -50,32 +50,22 @@ class _DraggableExampleState extends State<DraggableExample> {
height: 100.0,
width: 100.0,
color: Colors.pinkAccent,
child: const Center(
child: Text('Child When Dragging'),
),
child: const Center(child: Text('Child When Dragging')),
),
child: Container(
height: 100.0,
width: 100.0,
color: Colors.lightGreenAccent,
child: const Center(
child: Text('Draggable'),
),
child: const Center(child: Text('Draggable')),
),
),
DragTarget<int>(
builder: (
BuildContext context,
List<dynamic> accepted,
List<dynamic> rejected,
) {
builder: (BuildContext context, List<dynamic> accepted, List<dynamic> rejected) {
return Container(
height: 100.0,
width: 100.0,
color: Colors.cyan,
child: Center(
child: Text('Value is updated to: $acceptedData'),
),
child: Center(child: Text('Value is updated to: $acceptedData')),
);
},
onAcceptWithDetails: (DragTargetDetails<int> details) {

View File

@@ -15,13 +15,9 @@ class DraggableScrollableSheetExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue.shade100),
),
theme: ThemeData(colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue.shade100)),
home: Scaffold(
appBar: AppBar(
title: const Text('DraggableScrollableSheet Sample'),
),
appBar: AppBar(title: const Text('DraggableScrollableSheet Sample')),
body: const DraggableScrollableSheetExample(),
),
);
@@ -70,10 +66,7 @@ class _DraggableScrollableSheetExampleState extends State<DraggableScrollableShe
itemCount: 25,
itemBuilder: (BuildContext context, int index) {
return ListTile(
title: Text(
'Item $index',
style: TextStyle(color: colorScheme.surface),
),
title: Text('Item $index', style: TextStyle(color: colorScheme.surface)),
);
},
),
@@ -85,20 +78,18 @@ class _DraggableScrollableSheetExampleState extends State<DraggableScrollableShe
);
}
bool get _isOnDesktopAndWeb => kIsWeb || switch (defaultTargetPlatform) {
TargetPlatform.macOS || TargetPlatform.linux || TargetPlatform.windows => true,
TargetPlatform.android || TargetPlatform.iOS || TargetPlatform.fuchsia => false,
};
bool get _isOnDesktopAndWeb =>
kIsWeb ||
switch (defaultTargetPlatform) {
TargetPlatform.macOS || TargetPlatform.linux || TargetPlatform.windows => true,
TargetPlatform.android || TargetPlatform.iOS || TargetPlatform.fuchsia => false,
};
}
/// A draggable widget that accepts vertical drag gestures
/// and this is only visible on desktop and web platforms.
class Grabber extends StatelessWidget {
const Grabber({
super.key,
required this.onVerticalDragUpdate,
required this.isOnDesktopAndWeb,
});
const Grabber({super.key, required this.onVerticalDragUpdate, required this.isOnDesktopAndWeb});
final ValueChanged<DragUpdateDetails> onVerticalDragUpdate;
final bool isOnDesktopAndWeb;

View File

@@ -13,9 +13,7 @@ class OnChangedExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: OnChangedExample(),
);
return const MaterialApp(home: OnChangedExample());
}
}

View File

@@ -15,9 +15,7 @@ class KeyboardInsertedContentApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: KeyboardInsertedContentDemo(),
);
return const MaterialApp(home: KeyboardInsertedContentDemo());
}
}

View File

@@ -13,9 +13,7 @@ class TextEditingControllerExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: TextEditingControllerExample(),
);
return const MaterialApp(home: TextEditingControllerExample());
}
}

View File

@@ -15,9 +15,7 @@ class TextEditingControllerExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: TextEditingControllerExample(),
);
return const MaterialApp(home: TextEditingControllerExample());
}
}
@@ -32,10 +30,7 @@ class _TextEditingControllerExampleState extends State<TextEditingControllerExam
// Create a controller whose initial selection is empty (collapsed) and positioned
// before the text (offset is 0).
final TextEditingController _controller = TextEditingController.fromValue(
const TextEditingValue(
text: 'Flutter',
selection: TextSelection.collapsed(offset: 0),
),
const TextEditingValue(text: 'Flutter', selection: TextSelection.collapsed(offset: 0)),
);
@override

View File

@@ -58,15 +58,21 @@ class _ColorfulButtonState extends State<ColorfulButton> {
switch (event.logicalKey) {
case LogicalKeyboardKey.keyR:
debugPrint('Changing color to red.');
setState(() { _color = Colors.red; });
setState(() {
_color = Colors.red;
});
return KeyEventResult.handled;
case LogicalKeyboardKey.keyG:
debugPrint('Changing color to green.');
setState(() { _color = Colors.green; });
setState(() {
_color = Colors.green;
});
return KeyEventResult.handled;
case LogicalKeyboardKey.keyB:
debugPrint('Changing color to blue.');
setState(() { _color = Colors.blue; });
setState(() {
_color = Colors.blue;
});
return KeyEventResult.handled;
}
}
@@ -111,9 +117,6 @@ class FocusNodeExample extends StatelessWidget {
@override
Widget build(BuildContext context) {
final TextTheme textTheme = Theme.of(context).textTheme;
return DefaultTextStyle(
style: textTheme.headlineMedium!,
child: const ColorfulButton(),
);
return DefaultTextStyle(style: textTheme.headlineMedium!, child: const ColorfulButton());
}
}

View File

@@ -13,9 +13,7 @@ class UnfocusExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: UnfocusExample(),
);
return const MaterialApp(home: UnfocusExample());
}
}
@@ -43,9 +41,7 @@ class _UnfocusExampleState extends State<UnfocusExample> {
width: 200,
child: Padding(
padding: EdgeInsets.all(8.0),
child: TextField(
decoration: InputDecoration(border: OutlineInputBorder()),
),
child: TextField(decoration: InputDecoration(border: OutlineInputBorder())),
),
);
}),

View File

@@ -15,10 +15,7 @@ class FocusExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Focus Sample')),
body: const FocusExample(),
),
home: Scaffold(appBar: AppBar(title: const Text('Focus Sample')), body: const FocusExample()),
);
}
}
@@ -39,15 +36,21 @@ class _FocusExampleState extends State<FocusExample> {
switch (event.logicalKey) {
case LogicalKeyboardKey.keyR:
debugPrint('Changing color to red.');
setState(() { _color = Colors.red; });
setState(() {
_color = Colors.red;
});
return KeyEventResult.handled;
case LogicalKeyboardKey.keyG:
debugPrint('Changing color to green.');
setState(() { _color = Colors.green; });
setState(() {
_color = Colors.green;
});
return KeyEventResult.handled;
case LogicalKeyboardKey.keyB:
debugPrint('Changing color to blue.');
setState(() { _color = Colors.blue; });
setState(() {
_color = Colors.blue;
});
return KeyEventResult.handled;
}
}

View File

@@ -13,18 +13,12 @@ class FocusExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: FocusExample(),
);
return const MaterialApp(home: FocusExample());
}
}
class FocusableText extends StatelessWidget {
const FocusableText(
this.data, {
super.key,
required this.autofocus,
});
const FocusableText(this.data, {super.key, required this.autofocus});
/// The string to display as the text for this widget.
final String data;
@@ -36,21 +30,23 @@ class FocusableText extends StatelessWidget {
Widget build(BuildContext context) {
return Focus(
autofocus: autofocus,
child: Builder(builder: (BuildContext context) {
// The contents of this Builder are being made focusable. It is inside
// of a Builder because the builder provides the correct context
// variable for Focus.of() to be able to find the Focus widget that is
// the Builder's parent. Without the builder, the context variable used
// would be the one given the FocusableText build function, and that
// would start looking for a Focus widget ancestor of the FocusableText
// instead of finding the one inside of its build function.
return Container(
padding: const EdgeInsets.all(8.0),
// Change the color based on whether or not this Container has focus.
color: Focus.of(context).hasPrimaryFocus ? Colors.red : Colors.white,
child: Text(data),
);
}),
child: Builder(
builder: (BuildContext context) {
// The contents of this Builder are being made focusable. It is inside
// of a Builder because the builder provides the correct context
// variable for Focus.of() to be able to find the Focus widget that is
// the Builder's parent. Without the builder, the context variable used
// would be the one given the FocusableText build function, and that
// would start looking for a Focus widget ancestor of the FocusableText
// instead of finding the one inside of its build function.
return Container(
padding: const EdgeInsets.all(8.0),
// Change the color based on whether or not this Container has focus.
color: Focus.of(context).hasPrimaryFocus ? Colors.red : Colors.white,
child: Text(data),
);
},
),
);
}
}
@@ -62,10 +58,9 @@ class FocusExample extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
body: ListView.builder(
itemBuilder: (BuildContext context, int index) => FocusableText(
'Item $index',
autofocus: index == 0,
),
itemBuilder:
(BuildContext context, int index) =>
FocusableText('Item $index', autofocus: index == 0),
itemCount: 50,
),
);

View File

@@ -13,9 +13,7 @@ class FocusExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: FocusExample(),
);
return const MaterialApp(home: FocusExample());
}
}
@@ -51,24 +49,22 @@ class _FocusExampleState extends State<FocusExample> {
// node is not yet part of the focus tree.
childFocusNodes.add(FocusNode(debugLabel: 'Child ${children.length}')..requestFocus());
children.add(Padding(
padding: const EdgeInsets.all(2.0),
child: ActionChip(
focusNode: childFocusNodes.last,
label: Text('CHILD ${children.length}'),
onPressed: () {},
children.add(
Padding(
padding: const EdgeInsets.all(2.0),
child: ActionChip(
focusNode: childFocusNodes.last,
label: Text('CHILD ${children.length}'),
onPressed: () {},
),
),
));
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Wrap(
children: children,
),
),
body: Center(child: Wrap(children: children)),
floatingActionButton: FloatingActionButton(
onPressed: () {
setState(() {

View File

@@ -13,9 +13,7 @@ class FocusScopeExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: FocusScopeExample(),
);
return const MaterialApp(home: FocusScopeExample());
}
}
@@ -45,9 +43,7 @@ class Pane extends StatelessWidget {
child: Stack(
fit: StackFit.expand,
children: <Widget>[
Center(
child: child,
),
Center(child: child),
Align(
alignment: Alignment.topLeft,
child: IconButton(

View File

@@ -13,9 +13,7 @@ class FocusTraversalGroupExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: FocusTraversalGroupExample(),
);
return const MaterialApp(home: FocusTraversalGroupExample());
}
}
@@ -45,10 +43,7 @@ class _OrderedButtonState<T> extends State<OrderedButton<T>> {
@override
void initState() {
super.initState();
focusNode = FocusNode(
debugLabel: widget.name,
canRequestFocus: widget.canRequestFocus,
);
focusNode = FocusNode(debugLabel: widget.name, canRequestFocus: widget.canRequestFocus);
}
@override
@@ -72,7 +67,7 @@ class _OrderedButtonState<T> extends State<OrderedButton<T>> {
@override
Widget build(BuildContext context) {
final FocusOrder order = switch (widget.order) {
final num number => NumericFocusOrder(number.toDouble()),
final num number => NumericFocusOrder(number.toDouble()),
final Object? object => LexicalFocusOrder(object.toString()),
};
@@ -144,10 +139,7 @@ class FocusTraversalGroupExample extends StatelessWidget {
children: List<Widget>.generate(3, (int index) {
// Order as "C" "B", "A".
final String order = String.fromCharCode('A'.codeUnitAt(0) + (2 - index));
return OrderedButton<String>(
name: 'String: $order',
order: order,
);
return OrderedButton<String>(name: 'String: $order', order: order);
}),
),
),
@@ -162,10 +154,7 @@ class FocusTraversalGroupExample extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: List<Widget>.generate(3, (int index) {
return OrderedButton<num>(
name: 'ignored num: ${3 - index}',
order: 3 - index,
);
return OrderedButton<num>(name: 'ignored num: ${3 - index}', order: 3 - index);
}),
),
),

View File

@@ -16,21 +16,14 @@ class OrderedTraversalPolicyExampleApp extends StatelessWidget {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('OrderedTraversalPolicy Sample')),
body: const Center(
child: OrderedTraversalPolicyExample(),
),
body: const Center(child: OrderedTraversalPolicyExample()),
),
);
}
}
class DemoButton extends StatelessWidget {
const DemoButton({
super.key,
required this.name,
this.autofocus = false,
required this.order,
});
const DemoButton({super.key, required this.name, this.autofocus = false, required this.order});
final String name;
final bool autofocus;
@@ -66,9 +59,7 @@ class OrderedTraversalPolicyExample extends StatelessWidget {
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
DemoButton(name: 'Six', order: 6),
],
children: <Widget>[DemoButton(name: 'Six', order: 6)],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,

View File

@@ -14,10 +14,7 @@ class FormExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Form Sample')),
body: const FormExample(),
),
home: Scaffold(appBar: AppBar(title: const Text('Form Sample')), body: const FormExample()),
);
}
}
@@ -40,9 +37,7 @@ class _FormExampleState extends State<FormExample> {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
TextFormField(
decoration: const InputDecoration(
hintText: 'Enter your email',
),
decoration: const InputDecoration(hintText: 'Enter your email'),
validator: (String? value) {
if (value == null || value.isEmpty) {
return 'Please enter some text';

View File

@@ -11,20 +11,14 @@ import 'package:flutter/services.dart';
void main() => runApp(const FormApp());
class FormApp extends StatelessWidget {
const FormApp({
super.key,
});
const FormApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Confirmation Dialog Example'),
),
body: Center(
child: _SaveableForm(),
),
appBar: AppBar(title: const Text('Confirmation Dialog Example')),
body: Center(child: _SaveableForm()),
),
);
}
@@ -141,10 +135,7 @@ class _SaveableFormState extends State<_SaveableForm> {
child: Row(
children: <Widget>[
const Text('Save'),
if (_controller.text.isNotEmpty)
Icon(
_isDirty ? Icons.warning : Icons.check,
),
if (_controller.text.isNotEmpty) Icon(_isDirty ? Icons.warning : Icons.check),
],
),
),

View File

@@ -8,15 +8,11 @@ import 'package:flutter/rendering.dart';
/// Flutter code sample for [BuildOwner].
void main() {
runApp(
const BuildOwnerExample(),
);
runApp(const BuildOwnerExample());
}
class BuildOwnerExample extends StatefulWidget {
const BuildOwnerExample({
super.key,
});
const BuildOwnerExample({super.key});
@override
State<BuildOwnerExample> createState() => _BuildOwnerExampleState();
@@ -38,11 +34,7 @@ class _BuildOwnerExampleState extends State<BuildOwnerExample> {
title: 'BuildOwner Sample',
color: const Color(0xff000000),
builder: (BuildContext context, Widget? child) {
return Scaffold(
body: Center(
child: Text(size.toString()),
),
);
return Scaffold(body: Center(child: Text(size.toString())));
},
);
}

View File

@@ -49,12 +49,13 @@ class _ErrorWidgetExampleAppState extends State<ErrorWidgetExampleApp> {
appBar: AppBar(title: const Text('ErrorWidget Sample')),
body: Center(
child: TextButton(
onPressed: () {
setState(() {
throwError = true;
});
},
child: const Text('Error Prone')),
onPressed: () {
setState(() {
throwError = true;
});
},
child: const Text('Error Prone'),
),
),
),
);

View File

@@ -13,9 +13,7 @@ class GestureDetectorExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: GestureDetectorExample(),
);
return const MaterialApp(home: GestureDetectorExample());
}
}

View File

@@ -13,9 +13,7 @@ class GestureDetectorExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: GestureDetectorExample(),
);
return const MaterialApp(home: GestureDetectorExample());
}
}

View File

@@ -65,7 +65,8 @@ class _NestedGestureDetectorsExampleState extends State<NestedGestureDetectorsEx
// parent-child hit testing. A tap on 'Yellow' is also in
// 'Green' bounds. Both enter the gesture arena, 'Yellow' wins
// because it is in front.
behavior: _isYellowTranslucent ? HitTestBehavior.translucent : HitTestBehavior.opaque,
behavior:
_isYellowTranslucent ? HitTestBehavior.translucent : HitTestBehavior.opaque,
onTap: () {
debugPrint('Yellow onTap');
setState(() {

View File

@@ -30,9 +30,7 @@ class DragBoundaryExampleAppState extends State<DragBoundaryExampleApp> {
builder: (BuildContext context) {
return Stack(
children: <Widget>[
Container(
color: Colors.green,
),
Container(color: Colors.green),
Positioned(
top: _currentPosition.dy,
left: _currentPosition.dx,
@@ -43,9 +41,10 @@ class DragBoundaryExampleAppState extends State<DragBoundaryExampleApp> {
},
onPanUpdate: (DragUpdateDetails details) {
_currentPosition = details.localPosition - _initialPosition;
final Rect withinBoundary = DragBoundary.forRectOf(context, useGlobalPosition: false).nearestPositionWithinBoundary(
_currentPosition & _boxSize,
);
final Rect withinBoundary = DragBoundary.forRectOf(
context,
useGlobalPosition: false,
).nearestPositionWithinBoundary(_currentPosition & _boxSize);
setState(() {
_currentPosition = withinBoundary.topLeft;
});

View File

@@ -11,15 +11,7 @@ import 'package:flutter/services.dart';
/// Flutter code sample for [KeyEventManager.keyMessageHandler].
void main() {
runApp(
const MaterialApp(
home: Scaffold(
body: Center(
child: FallbackDemo(),
),
),
),
);
runApp(const MaterialApp(home: Scaffold(body: Center(child: FallbackDemo()))));
}
class FallbackDemo extends StatefulWidget {
@@ -56,8 +48,10 @@ class FallbackDemoState extends State<FallbackDemo> {
constraints: const BoxConstraints(maxWidth: 500, maxHeight: 400),
child: Column(
children: <Widget>[
const Text('This area handles key presses that are unhandled by any shortcuts, by '
'displaying them below. Try text shortcuts such as Ctrl-A!'),
const Text(
'This area handles key presses that are unhandled by any shortcuts, by '
'displaying them below. Try text shortcuts such as Ctrl-A!',
),
Text(_capture == null ? '' : '$_capture is not handled by shortcuts.'),
const TextField(decoration: InputDecoration(label: Text('Text field 1'))),
Shortcuts(
@@ -106,14 +100,17 @@ class FallbackKeyEventRegistrar {
static FallbackKeyEventRegistrar get instance {
if (!_initialized) {
// Get the global handler.
final KeyMessageHandler? existing = ServicesBinding.instance.keyEventManager.keyMessageHandler;
final KeyMessageHandler? existing =
ServicesBinding.instance.keyEventManager.keyMessageHandler;
// The handler is guaranteed non-null since
// `FallbackKeyEventRegistrar.instance` is only called during
// `Focus.onFocusChange`, at which time `ServicesBinding.instance` must
// have been called somewhere.
assert(existing != null);
// Assign the global handler with a patched handler.
ServicesBinding.instance.keyEventManager.keyMessageHandler = _instance._buildHandler(existing!);
ServicesBinding.instance.keyEventManager.keyMessageHandler = _instance._buildHandler(
existing!,
);
_initialized = true;
}
return _instance;
@@ -161,11 +158,7 @@ class FallbackKeyEventRegistrar {
/// [FallbackKeyEventRegistrar]. The inner this widget is, the later its node
/// will be added to the registrar's list when focused on.
class FallbackFocus extends StatelessWidget {
const FallbackFocus({
super.key,
required this.node,
required this.child,
});
const FallbackFocus({super.key, required this.node, required this.child});
final Widget child;
final FallbackFocusNode node;
@@ -181,9 +174,6 @@ class FallbackFocus extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Focus(
onFocusChange: _onFocusChange,
child: child,
);
return Focus(onFocusChange: _onFocusChange, child: child);
}
}

View File

@@ -13,9 +13,7 @@ class HeroApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: HeroExample(),
);
return const MaterialApp(home: HeroExample());
}
}
@@ -31,14 +29,9 @@ class HeroExample extends StatelessWidget {
children: <Widget>[
const SizedBox(height: 20.0),
ListTile(
leading: const Hero(
tag: 'hero-rectangle',
child: BoxWidget(size: Size(50.0, 50.0)),
),
leading: const Hero(tag: 'hero-rectangle', child: BoxWidget(size: Size(50.0, 50.0))),
onTap: () => _gotoDetailsPage(context),
title: const Text(
'Tap on the icon to view hero animation transition.',
),
title: const Text('Tap on the icon to view hero animation transition.'),
),
],
),
@@ -46,19 +39,17 @@ class HeroExample extends StatelessWidget {
}
void _gotoDetailsPage(BuildContext context) {
Navigator.of(context).push(MaterialPageRoute<void>(
builder: (BuildContext context) => Scaffold(
appBar: AppBar(
title: const Text('Second Page'),
),
body: const Center(
child: Hero(
tag: 'hero-rectangle',
child: BoxWidget(size: Size(200.0, 200.0)),
),
),
Navigator.of(context).push(
MaterialPageRoute<void>(
builder:
(BuildContext context) => Scaffold(
appBar: AppBar(title: const Text('Second Page')),
body: const Center(
child: Hero(tag: 'hero-rectangle', child: BoxWidget(size: Size(200.0, 200.0))),
),
),
),
));
);
}
}
@@ -69,10 +60,6 @@ class BoxWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
width: size.width,
height: size.height,
color: Colors.blue,
);
return Container(width: size.width, height: size.height, color: Colors.blue);
}
}

View File

@@ -18,9 +18,7 @@ class HeroApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: HeroExample(),
);
return const MaterialApp(home: HeroExample());
}
}
@@ -72,56 +70,49 @@ class HeroExample extends StatelessWidget {
}
void _gotoDetailsPage(BuildContext context) {
Navigator.of(context).push(MaterialPageRoute<void>(
builder: (BuildContext context) => Scaffold(
appBar: AppBar(
title: const Text('Second Page'),
),
body: Align(
alignment: Alignment.bottomRight,
child: Stack(
children: <Widget>[
Hero(
tag: 'hero-custom-tween',
createRectTween: (Rect? begin, Rect? end) {
return MaterialRectCenterArcTween(begin: begin, end: end);
},
child: BoxWidget(
size: const Size(400.0, 400.0),
color: Colors.blue[700]!.withOpacity(0.5),
Navigator.of(context).push(
MaterialPageRoute<void>(
builder:
(BuildContext context) => Scaffold(
appBar: AppBar(title: const Text('Second Page')),
body: Align(
alignment: Alignment.bottomRight,
child: Stack(
children: <Widget>[
Hero(
tag: 'hero-custom-tween',
createRectTween: (Rect? begin, Rect? end) {
return MaterialRectCenterArcTween(begin: begin, end: end);
},
child: BoxWidget(
size: const Size(400.0, 400.0),
color: Colors.blue[700]!.withOpacity(0.5),
),
),
Hero(
tag: 'hero-default-tween',
child: BoxWidget(
size: const Size(400.0, 400.0),
color: Colors.red[700]!.withOpacity(0.5),
),
),
],
),
),
Hero(
tag: 'hero-default-tween',
child: BoxWidget(
size: const Size(400.0, 400.0),
color: Colors.red[700]!.withOpacity(0.5),
),
),
],
),
),
),
),
));
);
}
}
class BoxWidget extends StatelessWidget {
const BoxWidget({
super.key,
required this.size,
required this.color,
});
const BoxWidget({super.key, required this.size, required this.color});
final Size size;
final Color color;
@override
Widget build(BuildContext context) {
return Container(
width: size.width,
height: size.height,
color: color,
);
return Container(width: size.width, height: size.height, color: color);
}
}

View File

@@ -13,13 +13,7 @@ class ErrorBuilderExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
body: Center(
child: ErrorBuilderExample(),
),
),
);
return const MaterialApp(home: Scaffold(body: Center(child: ErrorBuilderExample())));
}
}

View File

@@ -13,9 +13,7 @@ class FrameBuilderExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: FrameBuilderExample(),
);
return const MaterialApp(home: FrameBuilderExample());
}
}
@@ -33,7 +31,12 @@ class FrameBuilderExample extends StatelessWidget {
),
child: Image.network(
'https://flutter.github.io/assets-for-api-docs/assets/widgets/puffin.jpg',
frameBuilder: (BuildContext context, Widget child, int? frame, bool wasSynchronouslyLoaded) {
frameBuilder: (
BuildContext context,
Widget child,
int? frame,
bool wasSynchronouslyLoaded,
) {
if (wasSynchronouslyLoaded) {
return child;
}

View File

@@ -13,9 +13,7 @@ class LoadingBuilderExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: LoadingBuilderExample(),
);
return const MaterialApp(home: LoadingBuilderExample());
}
}
@@ -38,9 +36,10 @@ class LoadingBuilderExample extends StatelessWidget {
}
return Center(
child: CircularProgressIndicator(
value: loadingProgress.expectedTotalBytes != null
? loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes!
: null,
value:
loadingProgress.expectedTotalBytes != null
? loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes!
: null,
),
);
},

View File

@@ -19,21 +19,14 @@ class AnimatedAlignExampleApp extends StatelessWidget {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('AnimatedAlign Sample')),
body: const AnimatedAlignExample(
duration: duration,
curve: curve,
),
body: const AnimatedAlignExample(duration: duration, curve: curve),
),
);
}
}
class AnimatedAlignExample extends StatefulWidget {
const AnimatedAlignExample({
required this.duration,
required this.curve,
super.key,
});
const AnimatedAlignExample({required this.duration, required this.curve, super.key});
final Duration duration;

View File

@@ -18,13 +18,8 @@ class AnimatedFractionallySizedBoxExampleApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('AnimatedFractionallySizedBox Sample'),
),
body: const AnimatedFractionallySizedBoxExample(
duration: duration,
curve: curve,
),
appBar: AppBar(title: const Text('AnimatedFractionallySizedBox Sample')),
body: const AnimatedFractionallySizedBoxExample(duration: duration, curve: curve),
),
);
}
@@ -46,8 +41,7 @@ class AnimatedFractionallySizedBoxExample extends StatefulWidget {
_AnimatedFractionallySizedBoxExampleState();
}
class _AnimatedFractionallySizedBoxExampleState
extends State<AnimatedFractionallySizedBoxExample> {
class _AnimatedFractionallySizedBoxExampleState extends State<AnimatedFractionallySizedBoxExample> {
bool selected = false;
@override
@@ -70,10 +64,7 @@ class _AnimatedFractionallySizedBoxExampleState
alignment: selected ? Alignment.topLeft : Alignment.bottomRight,
duration: widget.duration,
curve: widget.curve,
child: const ColoredBox(
color: Colors.blue,
child: FlutterLogo(size: 75),
),
child: const ColoredBox(color: Colors.blue, child: FlutterLogo(size: 75)),
),
),
),

View File

@@ -54,10 +54,11 @@ class _AnimatedPaddingExampleState extends State<AnimatedPaddingExample> {
),
Text('Padding: $padValue'),
ElevatedButton(
child: const Text('Change padding'),
onPressed: () {
_updatePadding(padValue == 0.0 ? 100.0 : 0.0);
}),
child: const Text('Change padding'),
onPressed: () {
_updatePadding(padValue == 0.0 ? 100.0 : 0.0);
},
),
],
);
}

View File

@@ -19,31 +19,21 @@ class AnimatedPositionedExampleApp extends StatelessWidget {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('AnimatedPositioned Sample')),
body: const Center(
child: AnimatedPositionedExample(
duration: duration,
curve: curve,
),
),
body: const Center(child: AnimatedPositionedExample(duration: duration, curve: curve)),
),
);
}
}
class AnimatedPositionedExample extends StatefulWidget {
const AnimatedPositionedExample({
required this.duration,
required this.curve,
super.key,
});
const AnimatedPositionedExample({required this.duration, required this.curve, super.key});
final Duration duration;
final Curve curve;
@override
State<AnimatedPositionedExample> createState() =>
_AnimatedPositionedExampleState();
State<AnimatedPositionedExample> createState() => _AnimatedPositionedExampleState();
}
class _AnimatedPositionedExampleState extends State<AnimatedPositionedExample> {
@@ -68,10 +58,7 @@ class _AnimatedPositionedExampleState extends State<AnimatedPositionedExample> {
selected = !selected;
});
},
child: const ColoredBox(
color: Colors.blue,
child: Center(child: Text('Tap me')),
),
child: const ColoredBox(color: Colors.blue, child: Center(child: Text('Tap me'))),
),
),
],

View File

@@ -13,10 +13,7 @@ class AnimatedSlideApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(useMaterial3: true),
home: const AnimatedSlideExample(),
);
return MaterialApp(theme: ThemeData(useMaterial3: true), home: const AnimatedSlideExample());
}
}

View File

@@ -19,67 +19,54 @@ class SliverAnimatedOpacityExampleApp extends StatelessWidget {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('SliverAnimatedOpacity Sample')),
body: const Center(
child: SliverAnimatedOpacityExample(
duration: duration,
curve: curve,
),
),
body: const Center(child: SliverAnimatedOpacityExample(duration: duration, curve: curve)),
),
);
}
}
class SliverAnimatedOpacityExample extends StatefulWidget {
const SliverAnimatedOpacityExample({
required this.duration,
required this.curve,
super.key,
});
const SliverAnimatedOpacityExample({required this.duration, required this.curve, super.key});
final Duration duration;
final Curve curve;
@override
State<SliverAnimatedOpacityExample> createState() =>
_SliverAnimatedOpacityExampleState();
State<SliverAnimatedOpacityExample> createState() => _SliverAnimatedOpacityExampleState();
}
class _SliverAnimatedOpacityExampleState
extends State<SliverAnimatedOpacityExample>
class _SliverAnimatedOpacityExampleState extends State<SliverAnimatedOpacityExample>
with SingleTickerProviderStateMixin {
bool _visible = true;
@override
Widget build(BuildContext context) {
return CustomScrollView(slivers: <Widget>[
SliverAnimatedOpacity(
opacity: _visible ? 1.0 : 0.0,
duration: widget.duration,
curve: widget.curve,
sliver: SliverFixedExtentList(
itemExtent: 100.0,
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return Container(
color: index.isEven ? Colors.indigo[200] : Colors.orange[200],
);
},
childCount: 5,
return CustomScrollView(
slivers: <Widget>[
SliverAnimatedOpacity(
opacity: _visible ? 1.0 : 0.0,
duration: widget.duration,
curve: widget.curve,
sliver: SliverFixedExtentList(
itemExtent: 100.0,
delegate: SliverChildBuilderDelegate((BuildContext context, int index) {
return Container(color: index.isEven ? Colors.indigo[200] : Colors.orange[200]);
}, childCount: 5),
),
),
),
SliverToBoxAdapter(
SliverToBoxAdapter(
child: FloatingActionButton(
onPressed: () {
setState(() {
_visible = !_visible;
});
},
tooltip: 'Toggle opacity',
child: const Icon(Icons.flip),
)),
]);
onPressed: () {
setState(() {
_visible = !_visible;
});
},
tooltip: 'Toggle opacity',
child: const Icon(Icons.flip),
),
),
],
);
}
}

View File

@@ -15,25 +15,21 @@ class InheritedModelApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: InheritedModelExample(),
);
return const MaterialApp(home: InheritedModelExample());
}
}
class LogoModel extends InheritedModel<LogoAspect> {
const LogoModel({
super.key,
this.backgroundColor,
this.large,
required super.child,
});
const LogoModel({super.key, this.backgroundColor, this.large, required super.child});
final Color? backgroundColor;
final bool? large;
static Color? backgroundColorOf(BuildContext context) {
return InheritedModel.inheritFrom<LogoModel>(context, aspect: LogoAspect.backgroundColor)?.backgroundColor;
return InheritedModel.inheritFrom<LogoModel>(
context,
aspect: LogoAspect.backgroundColor,
)?.backgroundColor;
}
static bool sizeOf(BuildContext context) {
@@ -47,7 +43,8 @@ class LogoModel extends InheritedModel<LogoAspect> {
@override
bool updateShouldNotifyDependent(LogoModel oldWidget, Set<LogoAspect> dependencies) {
if (backgroundColor != oldWidget.backgroundColor && dependencies.contains(LogoAspect.backgroundColor)) {
if (backgroundColor != oldWidget.backgroundColor &&
dependencies.contains(LogoAspect.backgroundColor)) {
return true;
}
if (large != oldWidget.large && dependencies.contains(LogoAspect.large)) {
@@ -79,9 +76,7 @@ class _InheritedModelExampleState extends State<InheritedModelExample> {
child: LogoModel(
backgroundColor: color,
large: large,
child: const BackgroundWidget(
child: LogoWidget(),
),
child: const BackgroundWidget(child: LogoWidget()),
),
),
Row(
@@ -120,7 +115,7 @@ class _InheritedModelExampleState extends State<InheritedModelExample> {
child: const Text('Resize Logo'),
),
],
)
),
],
),
);

View File

@@ -15,18 +15,12 @@ class InheritedNotifierExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: InheritedNotifierExample(),
);
return const MaterialApp(home: InheritedNotifierExample());
}
}
class SpinModel extends InheritedNotifier<AnimationController> {
const SpinModel({
super.key,
super.notifier,
required super.child,
});
const SpinModel({super.key, super.notifier, required super.child});
static double of(BuildContext context) {
return context.dependOnInheritedWidgetOfExactType<SpinModel>()!.notifier!.value;
@@ -44,9 +38,7 @@ class Spinner extends StatelessWidget {
width: 100,
height: 100,
color: Colors.green,
child: const Center(
child: Text('Whee!'),
),
child: const Center(child: Text('Whee!')),
),
);
}
@@ -61,16 +53,14 @@ class InheritedNotifierExample extends StatefulWidget {
/// [AnimationController]s can be created with `vsync: this` because of
/// [TickerProviderStateMixin].
class _InheritedNotifierExampleState extends State<InheritedNotifierExample> with TickerProviderStateMixin {
class _InheritedNotifierExampleState extends State<InheritedNotifierExample>
with TickerProviderStateMixin {
late AnimationController _controller;
@override
void initState() {
super.initState();
_controller = AnimationController(
duration: const Duration(seconds: 10),
vsync: this,
)..repeat();
_controller = AnimationController(duration: const Duration(seconds: 10), vsync: this)..repeat();
}
@override
@@ -85,11 +75,7 @@ class _InheritedNotifierExampleState extends State<InheritedNotifierExample> wit
notifier: _controller,
child: const Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Spinner(),
Spinner(),
Spinner(),
],
children: <Widget>[Spinner(), Spinner(), Spinner()],
),
);
}

View File

@@ -16,9 +16,7 @@ class IVBuilderExampleApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('IV Builder Example'),
),
appBar: AppBar(title: const Text('IV Builder Example')),
body: const _IVBuilderExample(),
),
);
@@ -43,11 +41,7 @@ class _IVBuilderExampleState extends State<_IVBuilderExample> {
double xMax = quad.point0.x;
double yMin = quad.point0.y;
double yMax = quad.point0.y;
for (final Vector3 point in <Vector3>[
quad.point1,
quad.point2,
quad.point3,
]) {
for (final Vector3 point in <Vector3>[quad.point1, quad.point2, quad.point3]) {
if (point.x < xMin) {
xMin = point.x;
} else if (point.x > xMax) {
@@ -81,9 +75,7 @@ class _IVBuilderExampleState extends State<_IVBuilderExample> {
height: _cellHeight,
width: _cellWidth,
color: row % 2 + column % 2 == 1 ? Colors.white : Colors.grey.withOpacity(0.1),
child: Align(
child: Text('$row x $column'),
),
child: Align(child: Text('$row x $column')),
);
},
);

View File

@@ -36,7 +36,8 @@ class ConstrainedExample extends StatelessWidget {
scaleEnabled: false,
child: Table(
columnWidths: <int, TableColumnWidth>{
for (int column = 0; column < columnCount; column += 1) column: const FixedColumnWidth(200.0),
for (int column = 0; column < columnCount; column += 1)
column: const FixedColumnWidth(200.0),
},
children: <TableRow>[
for (int row = 0; row < rowCount; row += 1)
@@ -46,10 +47,7 @@ class ConstrainedExample extends StatelessWidget {
Container(
height: 26,
color: row % 2 + column % 2 == 1 ? Colors.white : Colors.grey.withOpacity(0.1),
child: Align(
alignment: Alignment.centerLeft,
child: Text('$row x $column'),
),
child: Align(alignment: Alignment.centerLeft, child: Text('$row x $column')),
),
],
),

View File

@@ -13,9 +13,7 @@ class TransformationControllerExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: TransformationControllerExample(),
);
return const MaterialApp(home: TransformationControllerExample());
}
}
@@ -53,7 +51,7 @@ class _TransformationControllerExampleState extends State<TransformationControll
_controllerReset.forward();
}
// Stop a running reset to home transform animation.
// Stop a running reset to home transform animation.
void _animateResetStop() {
_controllerReset.stop();
_animationReset?.removeListener(_onAnimateReset);
@@ -89,10 +87,7 @@ class _TransformationControllerExampleState extends State<TransformationControll
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Theme.of(context).colorScheme.primary,
appBar: AppBar(
automaticallyImplyLeading: false,
title: const Text('Controller demo'),
),
appBar: AppBar(automaticallyImplyLeading: false, title: const Text('Controller demo')),
body: Center(
child: InteractiveViewer(
boundaryMargin: const EdgeInsets.all(double.infinity),

View File

@@ -13,9 +13,7 @@ class LayoutBuilderExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: LayoutBuilderExample(),
);
return const MaterialApp(home: LayoutBuilderExample());
}
}
@@ -39,13 +37,7 @@ class LayoutBuilderExample extends StatelessWidget {
}
Widget _buildNormalContainer() {
return Center(
child: Container(
height: 100.0,
width: 100.0,
color: Colors.red,
),
);
return Center(child: Container(height: 100.0, width: 100.0, color: Colors.red));
}
Widget _buildWideContainers() {
@@ -53,16 +45,8 @@ class LayoutBuilderExample extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Container(
height: 100.0,
width: 100.0,
color: Colors.red,
),
Container(
height: 100.0,
width: 100.0,
color: Colors.yellow,
),
Container(height: 100.0, width: 100.0, color: Colors.red),
Container(height: 100.0, width: 100.0, color: Colors.yellow),
],
),
);

View File

@@ -34,9 +34,7 @@ class _CupertinoMagnifierExampleState extends State<CupertinoMagnifierExample> {
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(
middle: Text('CupertinoMagnifier Sample'),
),
navigationBar: const CupertinoNavigationBar(middle: Text('CupertinoMagnifier Sample')),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
@@ -66,7 +64,7 @@ class _CupertinoMagnifierExampleState extends State<CupertinoMagnifierExample> {
borderRadius: BorderRadius.all(Radius.circular(magnifierRadius)),
additionalFocalPointOffset: Offset(0, -magnifierRadius),
),
)
),
],
),
),

View File

@@ -21,13 +21,10 @@ class CupertinoTextMagnifierApp extends StatelessWidget {
}
class CupertinoTextMagnifierExampleApp extends StatefulWidget {
const CupertinoTextMagnifierExampleApp({
super.key,
});
const CupertinoTextMagnifierExampleApp({super.key});
@override
State<CupertinoTextMagnifierExampleApp> createState() =>
_CupertinoTextMagnifierExampleAppState();
State<CupertinoTextMagnifierExampleApp> createState() => _CupertinoTextMagnifierExampleAppState();
}
class _CupertinoTextMagnifierExampleAppState extends State<CupertinoTextMagnifierExampleApp> {
@@ -36,9 +33,7 @@ class _CupertinoTextMagnifierExampleAppState extends State<CupertinoTextMagnifie
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(
middle: Text('CupertinoTextMagnifier Sample'),
),
navigationBar: const CupertinoNavigationBar(middle: Text('CupertinoTextMagnifier Sample')),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 48.0),
child: Center(

View File

@@ -30,16 +30,14 @@ class _MagnifierExampleAppState extends State<MagnifierExampleApp> {
child: Stack(
children: <Widget>[
GestureDetector(
onPanUpdate: (DragUpdateDetails details) => setState(
() {
dragGesturePosition = details.localPosition;
},
),
onPanDown: (DragDownDetails details) => setState(
() {
dragGesturePosition = details.localPosition;
},
),
onPanUpdate:
(DragUpdateDetails details) => setState(() {
dragGesturePosition = details.localPosition;
}),
onPanDown:
(DragDownDetails details) => setState(() {
dragGesturePosition = details.localPosition;
}),
child: const FlutterLogo(size: 200),
),
Positioned(
@@ -47,14 +45,12 @@ class _MagnifierExampleAppState extends State<MagnifierExampleApp> {
top: dragGesturePosition.dy - magnifierRadius,
child: const RawMagnifier(
decoration: MagnifierDecoration(
shape: CircleBorder(
side: BorderSide(color: Colors.pink, width: 3),
),
shape: CircleBorder(side: BorderSide(color: Colors.pink, width: 3)),
),
size: Size(magnifierRadius * 2, magnifierRadius * 2),
magnificationScale: 2,
),
)
),
],
),
),

View File

@@ -13,9 +13,7 @@ class SystemGestureInsetsExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: SystemGestureInsetsExample(),
);
return const MaterialApp(home: SystemGestureInsetsExample());
}
}

View File

@@ -64,10 +64,7 @@ class CollectPersonalInfoPage extends StatelessWidget {
}
class ChooseCredentialsPage extends StatelessWidget {
const ChooseCredentialsPage({
super.key,
required this.onSignupComplete,
});
const ChooseCredentialsPage({super.key, required this.onSignupComplete});
final VoidCallback onSignupComplete;
@@ -106,7 +103,8 @@ class SignUpPage extends StatelessWidget {
case 'signup/choose_credentials':
// Assume ChooseCredentialsPage collects new credentials and then
// invokes 'onSignupComplete()'.
builder = (BuildContext _) => ChooseCredentialsPage(
builder =
(BuildContext _) => ChooseCredentialsPage(
onSignupComplete: () {
// Referencing Navigator.of(context) from here refers to the
// top level Navigator because SignUpPage is above the

View File

@@ -15,10 +15,7 @@ class RestorablePushExampleApp extends StatelessWidget {
Widget build(BuildContext context) {
return const RootRestorationScope(
restorationId: 'app',
child: MaterialApp(
restorationScopeId: 'app',
home: RestorablePushExample(),
),
child: MaterialApp(restorationScopeId: 'app', home: RestorablePushExample()),
);
}
}
@@ -42,9 +39,7 @@ class _RestorablePushExampleState extends State<RestorablePushExample> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Sample Code'),
),
appBar: AppBar(title: const Text('Sample Code')),
floatingActionButton: FloatingActionButton(
onPressed: () => Navigator.restorablePush(context, _myRouteBuilder),
tooltip: 'Increment Counter',

View File

@@ -15,10 +15,7 @@ class RestorablePushAndRemoveUntilExampleApp extends StatelessWidget {
Widget build(BuildContext context) {
return const RootRestorationScope(
restorationId: 'app',
child: MaterialApp(
restorationScopeId: 'app',
home: RestorablePushAndRemoveUntilExample(),
),
child: MaterialApp(restorationScopeId: 'app', home: RestorablePushAndRemoveUntilExample()),
);
}
}
@@ -27,7 +24,8 @@ class RestorablePushAndRemoveUntilExample extends StatefulWidget {
const RestorablePushAndRemoveUntilExample({super.key});
@override
State<RestorablePushAndRemoveUntilExample> createState() => _RestorablePushAndRemoveUntilExampleState();
State<RestorablePushAndRemoveUntilExample> createState() =>
_RestorablePushAndRemoveUntilExampleState();
}
@pragma('vm:entry-point')
@@ -42,15 +40,14 @@ class _RestorablePushAndRemoveUntilExampleState extends State<RestorablePushAndR
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Sample Code'),
),
appBar: AppBar(title: const Text('Sample Code')),
floatingActionButton: FloatingActionButton(
onPressed: () => Navigator.restorablePushAndRemoveUntil(
context,
_myRouteBuilder,
ModalRoute.withName('/'),
),
onPressed:
() => Navigator.restorablePushAndRemoveUntil(
context,
_myRouteBuilder,
ModalRoute.withName('/'),
),
tooltip: 'Increment Counter',
child: const Icon(Icons.add),
),

View File

@@ -15,19 +15,13 @@ class RestorablePushReplacementExampleApp extends StatelessWidget {
Widget build(BuildContext context) {
return const RootRestorationScope(
restorationId: 'app',
child: MaterialApp(
restorationScopeId: 'app',
home: RestorablePushReplacementExample(),
),
child: MaterialApp(restorationScopeId: 'app', home: RestorablePushReplacementExample()),
);
}
}
class RestorablePushReplacementExample extends StatefulWidget {
const RestorablePushReplacementExample({
this.wasPushed = false,
super.key,
});
const RestorablePushReplacementExample({this.wasPushed = false, super.key});
final bool wasPushed;
@@ -40,22 +34,19 @@ class _RestorablePushReplacementExampleState extends State<RestorablePushReplace
@pragma('vm:entry-point')
static Route<void> _myRouteBuilder(BuildContext context, Object? arguments) {
return MaterialPageRoute<void>(
builder: (BuildContext context) => const RestorablePushReplacementExample(
wasPushed: true,
),
builder: (BuildContext context) => const RestorablePushReplacementExample(wasPushed: true),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Sample Code'),
),
appBar: AppBar(title: const Text('Sample Code')),
body: Center(
child: widget.wasPushed
? const Text('This is a new route.')
: const Text('This is the initial route.'),
child:
widget.wasPushed
? const Text('This is a new route.')
: const Text('This is the initial route.'),
),
floatingActionButton: FloatingActionButton(
onPressed: () => Navigator.restorablePushReplacement(context, _myRouteBuilder),

View File

@@ -15,10 +15,7 @@ class RestorablePushExampleApp extends StatelessWidget {
Widget build(BuildContext context) {
return const RootRestorationScope(
restorationId: 'app',
child: MaterialApp(
restorationScopeId: 'app',
home: RestorablePushExample(),
),
child: MaterialApp(restorationScopeId: 'app', home: RestorablePushExample()),
);
}
}
@@ -42,9 +39,7 @@ class _RestorablePushExampleState extends State<RestorablePushExample> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Sample Code'),
),
appBar: AppBar(title: const Text('Sample Code')),
floatingActionButton: FloatingActionButton(
onPressed: () => Navigator.of(context).restorablePush(_myRouteBuilder),
tooltip: 'Increment Counter',

View File

@@ -15,10 +15,7 @@ class RestorablePushAndRemoveUntilExampleApp extends StatelessWidget {
Widget build(BuildContext context) {
return const RootRestorationScope(
restorationId: 'app',
child: MaterialApp(
restorationScopeId: 'app',
home: RestorablePushAndRemoveUntilExample(),
),
child: MaterialApp(restorationScopeId: 'app', home: RestorablePushAndRemoveUntilExample()),
);
}
}
@@ -27,7 +24,8 @@ class RestorablePushAndRemoveUntilExample extends StatefulWidget {
const RestorablePushAndRemoveUntilExample({super.key});
@override
State<RestorablePushAndRemoveUntilExample> createState() => _RestorablePushAndRemoveUntilExampleState();
State<RestorablePushAndRemoveUntilExample> createState() =>
_RestorablePushAndRemoveUntilExampleState();
}
@pragma('vm:entry-point')
@@ -42,14 +40,12 @@ class _RestorablePushAndRemoveUntilExampleState extends State<RestorablePushAndR
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Sample Code'),
),
appBar: AppBar(title: const Text('Sample Code')),
floatingActionButton: FloatingActionButton(
onPressed: () => Navigator.of(context).restorablePushAndRemoveUntil(
_myRouteBuilder,
ModalRoute.withName('/'),
),
onPressed:
() => Navigator.of(
context,
).restorablePushAndRemoveUntil(_myRouteBuilder, ModalRoute.withName('/')),
tooltip: 'Increment Counter',
child: const Icon(Icons.add),
),

View File

@@ -15,19 +15,13 @@ class RestorablePushReplacementExampleApp extends StatelessWidget {
Widget build(BuildContext context) {
return const RootRestorationScope(
restorationId: 'app',
child: MaterialApp(
restorationScopeId: 'app',
home: RestorablePushReplacementExample(),
),
child: MaterialApp(restorationScopeId: 'app', home: RestorablePushReplacementExample()),
);
}
}
class RestorablePushReplacementExample extends StatefulWidget {
const RestorablePushReplacementExample({
this.wasPushed = false,
super.key,
});
const RestorablePushReplacementExample({this.wasPushed = false, super.key});
final bool wasPushed;
@@ -40,27 +34,22 @@ class _RestorablePushReplacementExampleState extends State<RestorablePushReplace
@pragma('vm:entry-point')
static Route<void> _myRouteBuilder(BuildContext context, Object? arguments) {
return MaterialPageRoute<void>(
builder: (BuildContext context) => const RestorablePushReplacementExample(
wasPushed: true,
),
builder: (BuildContext context) => const RestorablePushReplacementExample(wasPushed: true),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Sample Code'),
),
appBar: AppBar(title: const Text('Sample Code')),
body: Center(
child: widget.wasPushed
? const Text('This is a new route.')
: const Text('This is the initial route.'),
child:
widget.wasPushed
? const Text('This is a new route.')
: const Text('This is the initial route.'),
),
floatingActionButton: FloatingActionButton(
onPressed: () => Navigator.of(context).restorablePushReplacement(
_myRouteBuilder,
),
onPressed: () => Navigator.of(context).restorablePushReplacement(_myRouteBuilder),
tooltip: 'Increment Counter',
child: const Icon(Icons.add),
),

View File

@@ -41,20 +41,20 @@ class _MyHomeState extends State<MyHome> with RestorationMixin {
@override
void initState() {
super.initState();
_counterRoute = RestorableRouteFuture<int>(onPresent: (NavigatorState navigator, Object? arguments) {
// Defines what route should be shown (and how it should be added
// to the navigator) when `RestorableRouteFuture.present` is called.
return navigator.restorablePush(
_counterRouteBuilder,
arguments: arguments,
);
}, onComplete: (int count) {
// Defines what should happen with the return value when the route
// completes.
setState(() {
_lastCount.value = count;
});
});
_counterRoute = RestorableRouteFuture<int>(
onPresent: (NavigatorState navigator, Object? arguments) {
// Defines what route should be shown (and how it should be added
// to the navigator) when `RestorableRouteFuture.present` is called.
return navigator.restorablePush(_counterRouteBuilder, arguments: arguments);
},
onComplete: (int count) {
// Defines what should happen with the return value when the route
// completes.
setState(() {
_lastCount.value = count;
});
},
);
}
@override
@@ -76,9 +76,7 @@ class _MyHomeState extends State<MyHome> with RestorationMixin {
@pragma('vm:entry-point')
static Route<int> _counterRouteBuilder(BuildContext context, Object? arguments) {
return MaterialPageRoute<int>(
builder: (BuildContext context) => MyCounter(
title: arguments!.toString(),
),
builder: (BuildContext context) => MyCounter(title: arguments!.toString()),
);
}
@@ -141,9 +139,7 @@ class _MyCounterState extends State<MyCounter> with RestorationMixin {
},
),
),
body: Center(
child: Text('Count: ${_count.value}'),
),
body: Center(child: Text('Count: ${_count.value}')),
floatingActionButton: FloatingActionButton(
child: const Icon(Icons.add),
onPressed: () {

View File

@@ -21,25 +21,19 @@ class NavigatorPopHandlerApp extends StatelessWidget {
onGenerateRoute: (RouteSettings settings) {
return switch (settings.name) {
'/' => MaterialPageRoute<void>(
settings: const RouteSettings(
name: '/',
),
settings: const RouteSettings(name: '/'),
builder: (BuildContext context) {
return _HomePage();
},
),
'/nested_navigators' => MaterialPageRoute<void>(
settings: const RouteSettings(
name: '/nested_navigators',
),
settings: const RouteSettings(name: '/nested_navigators'),
builder: (BuildContext context) {
return const _NestedNavigatorsPage();
},
),
_ => MaterialPageRoute<void>(
settings: const RouteSettings(
name: 'unknown_page',
),
settings: const RouteSettings(name: 'unknown_page'),
builder: (BuildContext context) {
return const _UnknownPage();
},
@@ -54,9 +48,7 @@ class _HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Nested Navigators Example'),
),
appBar: AppBar(title: const Text('Nested Navigators Example')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
@@ -66,7 +58,9 @@ class _HomePage extends StatelessWidget {
const SizedBox(height: 20.0),
ListTile(
title: const Text('Nested Navigator route'),
subtitle: const Text('This route has another Navigator widget in addition to the one inside MaterialApp above.'),
subtitle: const Text(
'This route has another Navigator widget in addition to the one inside MaterialApp above.',
),
onTap: () {
Navigator.of(context).restorablePushNamed('/nested_navigators');
},
@@ -102,25 +96,20 @@ class _NestedNavigatorsPageState extends State<_NestedNavigatorsPage> {
final BuildContext rootContext = context;
return switch (settings.name) {
'nested_navigators/one' => MaterialPageRoute<void>(
settings: const RouteSettings(
name: 'nested_navigators/one',
),
builder: (BuildContext context) => _NestedNavigatorsPageOne(
onBack: () {
Navigator.of(rootContext).pop();
},
),
settings: const RouteSettings(name: 'nested_navigators/one'),
builder:
(BuildContext context) => _NestedNavigatorsPageOne(
onBack: () {
Navigator.of(rootContext).pop();
},
),
),
'nested_navigators/one/another_one' => MaterialPageRoute<void>(
settings: const RouteSettings(
name: 'nested_navigators/one',
),
settings: const RouteSettings(name: 'nested_navigators/one'),
builder: (BuildContext context) => const _NestedNavigatorsPageTwo(),
),
_ => MaterialPageRoute<void>(
settings: const RouteSettings(
name: 'unknown_page',
),
settings: const RouteSettings(name: 'unknown_page'),
builder: (BuildContext context) {
return const _UnknownPage();
},
@@ -133,9 +122,7 @@ class _NestedNavigatorsPageState extends State<_NestedNavigatorsPage> {
}
class _NestedNavigatorsPageOne extends StatelessWidget {
const _NestedNavigatorsPageOne({
required this.onBack,
});
const _NestedNavigatorsPageOne({required this.onBack});
final VoidCallback onBack;
@@ -203,12 +190,7 @@ class _UnknownPage extends StatelessWidget {
return Scaffold(
backgroundColor: Colors.grey.withBlue(180),
body: const Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('404'),
],
),
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[Text('404')]),
),
);
}

View File

@@ -7,11 +7,7 @@
import 'package:flutter/material.dart';
// There are three possible tabs.
enum _Tab {
home,
one,
two,
}
enum _Tab { home, one, two }
// Each tab has two possible pages.
enum _TabPage {
@@ -42,17 +38,13 @@ class NavigatorPopHandlerApp extends StatelessWidget {
onGenerateRoute: (RouteSettings settings) {
return switch (settings.name) {
'/' => MaterialPageRoute<void>(
settings: const RouteSettings(
name: '/',
),
settings: const RouteSettings(name: '/'),
builder: (BuildContext context) {
return const _BottomNavPage();
},
),
_ => MaterialPageRoute<void>(
settings: const RouteSettings(
name: 'unknown_page',
),
settings: const RouteSettings(name: 'unknown_page'),
builder: (BuildContext context) {
return const _UnknownPage();
},
@@ -84,20 +76,11 @@ class _BottomNavPageState extends State<_BottomNavPage> with RestorationMixin {
BottomNavigationBarItem _itemForPage(_Tab page) {
switch (page) {
case _Tab.home:
return const BottomNavigationBarItem(
icon: Icon(Icons.home),
label: 'Go to Home',
);
return const BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Go to Home');
case _Tab.one:
return const BottomNavigationBarItem(
icon: Icon(Icons.one_k),
label: 'Go to One',
);
return const BottomNavigationBarItem(icon: Icon(Icons.one_k), label: 'Go to One');
case _Tab.two:
return const BottomNavigationBarItem(
icon: Icon(Icons.two_k),
label: 'Go to Two',
);
return const BottomNavigationBarItem(icon: Icon(Icons.two_k), label: 'Go to Two');
}
}
@@ -175,9 +158,7 @@ class _BottomNavPageState extends State<_BottomNavPage> with RestorationMixin {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: _getPage(_restorableTab.value),
),
body: Center(child: _getPage(_restorableTab.value)),
bottomNavigationBar: BottomNavigationBar(
items: _Tab.values.map(_itemForPage).toList(),
currentIndex: _Tab.values.indexOf(_restorableTab.value),
@@ -223,64 +204,58 @@ class _BottomNavTabState extends State<_BottomNavTab> {
if (tabPage == null) {
return;
}
final List<_TabPage> nextPages = <_TabPage>[
...widget.pages,
]..remove(tabPage);
final List<_TabPage> nextPages = <_TabPage>[...widget.pages]..remove(tabPage);
if (nextPages.length < widget.pages.length) {
widget.onChangePages(nextPages);
}
},
pages: widget.pages.map((_TabPage page) {
switch (page) {
case _TabPage.home:
return MaterialPage<void>(
restorationId: _TabPage.home.toString(),
name: 'home',
child: _LinksPage(
title: 'Bottom nav - tab ${widget.title} - route $page',
backgroundColor: widget.color,
buttons: <Widget>[
TextButton(
onPressed: () {
assert(!widget.pages.contains(_TabPage.one));
widget.onChangePages(<_TabPage>[
...widget.pages,
_TabPage.one,
]);
},
child: const Text('Go to another route in this nested Navigator'),
pages:
widget.pages.map((_TabPage page) {
switch (page) {
case _TabPage.home:
return MaterialPage<void>(
restorationId: _TabPage.home.toString(),
name: 'home',
child: _LinksPage(
title: 'Bottom nav - tab ${widget.title} - route $page',
backgroundColor: widget.color,
buttons: <Widget>[
TextButton(
onPressed: () {
assert(!widget.pages.contains(_TabPage.one));
widget.onChangePages(<_TabPage>[...widget.pages, _TabPage.one]);
},
child: const Text('Go to another route in this nested Navigator'),
),
],
),
],
),
);
case _TabPage.one:
return MaterialPage<void>(
restorationId: _TabPage.one.toString(),
name: 'one',
child: _LinksPage(
backgroundColor: widget.color,
title: 'Bottom nav - tab ${widget.title} - route $page',
buttons: <Widget>[
TextButton(
onPressed: () {
widget.onChangePages(<_TabPage>[
...widget.pages,
]..removeLast());
},
child: const Text('Go back'),
);
case _TabPage.one:
return MaterialPage<void>(
restorationId: _TabPage.one.toString(),
name: 'one',
child: _LinksPage(
backgroundColor: widget.color,
title: 'Bottom nav - tab ${widget.title} - route $page',
buttons: <Widget>[
TextButton(
onPressed: () {
widget.onChangePages(<_TabPage>[...widget.pages]..removeLast());
},
child: const Text('Go back'),
),
],
),
],
),
);
}
}).toList(),
);
}
}).toList(),
),
);
}
}
class _LinksPage extends StatelessWidget {
const _LinksPage ({
const _LinksPage({
required this.backgroundColor,
this.buttons = const <Widget>[],
required this.title,
@@ -297,10 +272,7 @@ class _LinksPage extends StatelessWidget {
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(title),
...buttons,
],
children: <Widget>[Text(title), ...buttons],
),
),
);
@@ -315,12 +287,7 @@ class _UnknownPage extends StatelessWidget {
return Scaffold(
backgroundColor: Colors.grey.withBlue(180),
body: const Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('404'),
],
),
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[Text('404')]),
),
);
}
@@ -377,8 +344,6 @@ class _RestorableTabPageList extends RestorableValue<List<_TabPage>> {
@override
Object toPrimitives() {
return value
.map((_TabPage tabPage) => tabPage.name)
.join(',');
return value.map((_TabPage tabPage) => tabPage.name).join(',');
}
}

View File

@@ -13,9 +13,7 @@ class NestedScrollViewExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: NestedScrollViewExample(),
);
return const MaterialApp(home: NestedScrollViewExample());
}
}
@@ -64,65 +62,64 @@ class NestedScrollViewExample extends StatelessWidget {
},
body: TabBarView(
// These are the contents of the tab views, below the tabs.
children: tabs.map((String name) {
return SafeArea(
top: false,
bottom: false,
child: Builder(
// This Builder is needed to provide a BuildContext that is
// "inside" the NestedScrollView, so that
// sliverOverlapAbsorberHandleFor() can find the
// NestedScrollView.
builder: (BuildContext context) {
return CustomScrollView(
// The "controller" and "primary" members should be left
// unset, so that the NestedScrollView can control this
// inner scroll view.
// If the "controller" property is set, then this scroll
// view will not be associated with the NestedScrollView.
// The PageStorageKey should be unique to this ScrollView;
// it allows the list to remember its scroll position when
// the tab view is not on the screen.
key: PageStorageKey<String>(name),
slivers: <Widget>[
SliverOverlapInjector(
// This is the flip side of the SliverOverlapAbsorber
// above.
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
),
SliverPadding(
padding: const EdgeInsets.all(8.0),
// In this example, the inner scroll view has
// fixed-height list items, hence the use of
// SliverFixedExtentList. However, one could use any
// sliver widget here, e.g. SliverList or SliverGrid.
sliver: SliverFixedExtentList(
// The items in this example are fixed to 48 pixels
// high. This matches the Material Design spec for
// ListTile widgets.
itemExtent: 48.0,
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
// This builder is called for each child.
// In this example, we just number each list item.
return ListTile(
title: Text('Item $index'),
);
},
// The childCount of the SliverChildBuilderDelegate
// specifies how many children this inner list
// has. In this example, each tab has a list of
// exactly 30 items, but this is arbitrary.
childCount: 30,
children:
tabs.map((String name) {
return SafeArea(
top: false,
bottom: false,
child: Builder(
// This Builder is needed to provide a BuildContext that is
// "inside" the NestedScrollView, so that
// sliverOverlapAbsorberHandleFor() can find the
// NestedScrollView.
builder: (BuildContext context) {
return CustomScrollView(
// The "controller" and "primary" members should be left
// unset, so that the NestedScrollView can control this
// inner scroll view.
// If the "controller" property is set, then this scroll
// view will not be associated with the NestedScrollView.
// The PageStorageKey should be unique to this ScrollView;
// it allows the list to remember its scroll position when
// the tab view is not on the screen.
key: PageStorageKey<String>(name),
slivers: <Widget>[
SliverOverlapInjector(
// This is the flip side of the SliverOverlapAbsorber
// above.
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
),
),
),
],
);
},
),
);
}).toList(),
SliverPadding(
padding: const EdgeInsets.all(8.0),
// In this example, the inner scroll view has
// fixed-height list items, hence the use of
// SliverFixedExtentList. However, one could use any
// sliver widget here, e.g. SliverList or SliverGrid.
sliver: SliverFixedExtentList(
// The items in this example are fixed to 48 pixels
// high. This matches the Material Design spec for
// ListTile widgets.
itemExtent: 48.0,
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
// This builder is called for each child.
// In this example, we just number each list item.
return ListTile(title: Text('Item $index'));
},
// The childCount of the SliverChildBuilderDelegate
// specifies how many children this inner list
// has. In this example, each tab has a list of
// exactly 30 items, but this is arbitrary.
childCount: 30,
),
),
),
],
);
},
),
);
}).toList(),
),
),
),

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