@@ -2,11 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Action.Action.overridable].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
/// Flutter code sample for [Action.Action.overridable].
|
||||
|
||||
void main() {
|
||||
runApp(
|
||||
const MaterialApp(
|
||||
@@ -18,12 +18,13 @@ void main() {
|
||||
}
|
||||
|
||||
const CopyTextIntent copyTextIntent = CopyTextIntent._();
|
||||
|
||||
class CopyTextIntent extends Intent {
|
||||
const CopyTextIntent._();
|
||||
}
|
||||
|
||||
class CopyableText extends StatelessWidget {
|
||||
const CopyableText({ super.key, required this.text });
|
||||
const CopyableText({super.key, required this.text});
|
||||
|
||||
final String text;
|
||||
|
||||
@@ -33,9 +34,11 @@ class CopyableText extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final Action<CopyTextIntent> defaultCopyAction = CallbackAction<CopyTextIntent>(onInvoke: _copy);
|
||||
return Shortcuts(
|
||||
shortcuts: const <ShortcutActivator, Intent> { SingleActivator(LogicalKeyboardKey.keyC, control: true) : copyTextIntent },
|
||||
shortcuts: const <ShortcutActivator, Intent>{
|
||||
SingleActivator(LogicalKeyboardKey.keyC, control: true): copyTextIntent
|
||||
},
|
||||
child: Actions(
|
||||
actions: <Type, Action<Intent>> {
|
||||
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),
|
||||
@@ -53,7 +56,7 @@ class CopyableText extends StatelessWidget {
|
||||
}
|
||||
|
||||
class VerificationCodeGenerator extends StatelessWidget {
|
||||
const VerificationCodeGenerator({ super.key });
|
||||
const VerificationCodeGenerator({super.key});
|
||||
|
||||
void _copy(CopyTextIntent intent) {
|
||||
debugPrint('Content copied');
|
||||
@@ -63,7 +66,7 @@ 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>[
|
||||
@@ -73,9 +76,9 @@ class VerificationCodeGenerator extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
CopyableText(text: '111'),
|
||||
SizedBox(width: 5,),
|
||||
SizedBox(width: 5),
|
||||
CopyableText(text: '222'),
|
||||
SizedBox(width: 5,),
|
||||
SizedBox(width: 5),
|
||||
CopyableText(text: '333'),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -2,25 +2,22 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [ActionListener].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [ActionListener].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const ActionListenerExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class ActionListenerExampleApp extends StatelessWidget {
|
||||
const ActionListenerExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
appBar: AppBar(title: const Text('ActionListener Sample')),
|
||||
body: const Center(
|
||||
child: MyStatefulWidget(),
|
||||
child: ActionListenerExample(),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -75,8 +72,7 @@ class _ActionListenerExampleState extends State<ActionListenerExample> {
|
||||
},
|
||||
action: _myAction,
|
||||
child: ElevatedButton(
|
||||
onPressed: () => const ActionDispatcher()
|
||||
.invokeAction(_myAction, const MyIntent()),
|
||||
onPressed: () => const ActionDispatcher().invokeAction(_myAction, const MyIntent()),
|
||||
child: const Text('Call Action Listener'),
|
||||
),
|
||||
),
|
||||
@@ -109,17 +105,3 @@ class MyAction extends Action<MyIntent> {
|
||||
class MyIntent extends Intent {
|
||||
const MyIntent();
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const ActionListenerExample();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,25 +2,22 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Actions].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [Actions].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const ActionsExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class ActionsExampleApp extends StatelessWidget {
|
||||
const ActionsExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
appBar: AppBar(title: const Text('Actions Sample')),
|
||||
body: const Center(
|
||||
child: MyStatefulWidget(),
|
||||
child: ActionsExample(),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -116,14 +113,14 @@ class _SaveButtonState extends State<SaveButton> {
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class ActionsExample extends StatefulWidget {
|
||||
const ActionsExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<ActionsExample> createState() => _ActionsExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _ActionsExampleState extends State<ActionsExample> {
|
||||
Model model = Model();
|
||||
int count = 0;
|
||||
|
||||
@@ -154,8 +151,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
builder: (BuildContext context, Widget? child) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text('${model.data.value}',
|
||||
style: Theme.of(context).textTheme.headlineMedium),
|
||||
child: Text('${model.data.value}', style: Theme.of(context).textTheme.headlineMedium),
|
||||
);
|
||||
}),
|
||||
IconButton(
|
||||
|
||||
@@ -2,23 +2,20 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [FocusableActionDetector].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [FocusableActionDetector].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const FocusableActionDetectorExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class FocusableActionDetectorExampleApp extends StatelessWidget {
|
||||
const FocusableActionDetectorExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
home: FocusableActionDetectorExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -42,8 +39,7 @@ class _FadButtonState extends State<FadButton> {
|
||||
bool _hovering = false;
|
||||
bool _on = false;
|
||||
late final Map<Type, Action<Intent>> _actionMap;
|
||||
final Map<ShortcutActivator, Intent> _shortcutMap =
|
||||
const <ShortcutActivator, Intent>{
|
||||
final Map<ShortcutActivator, Intent> _shortcutMap = const <ShortcutActivator, Intent>{
|
||||
SingleActivator(LogicalKeyboardKey.keyX): ActivateIntent(),
|
||||
};
|
||||
|
||||
@@ -115,14 +111,14 @@ class _FadButtonState extends State<FadButton> {
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class FocusableActionDetectorExample extends StatefulWidget {
|
||||
const FocusableActionDetectorExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<FocusableActionDetectorExample> createState() => _FocusableActionDetectorExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _FocusableActionDetectorExampleState extends State<FocusableActionDetectorExample> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -135,8 +131,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child:
|
||||
TextButton(onPressed: () {}, child: const Text('Press Me')),
|
||||
child: TextButton(onPressed: () {}, child: const Text('Press Me')),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [AnimatedGrid].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [AnimatedGrid].
|
||||
|
||||
void main() {
|
||||
runApp(const AnimatedGridSample());
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [SliverAnimatedGrid].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [SliverAnimatedGrid].
|
||||
|
||||
void main() => runApp(const SliverAnimatedGridSample());
|
||||
|
||||
class SliverAnimatedGridSample extends StatefulWidget {
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [AnimatedList].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [AnimatedList].
|
||||
|
||||
void main() {
|
||||
runApp(const AnimatedListSample());
|
||||
}
|
||||
@@ -21,8 +21,7 @@ class _AnimatedListSampleState extends State<AnimatedListSample> {
|
||||
final GlobalKey<AnimatedListState> _listKey = GlobalKey<AnimatedListState>();
|
||||
late ListModel<int> _list;
|
||||
int? _selectedItem;
|
||||
late int
|
||||
_nextItem; // The next item inserted when the user presses the '+' button.
|
||||
late int _nextItem; // The next item inserted when the user presses the '+' button.
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -36,8 +35,7 @@ class _AnimatedListSampleState extends State<AnimatedListSample> {
|
||||
}
|
||||
|
||||
// Used to build list items that haven't been removed.
|
||||
Widget _buildItem(
|
||||
BuildContext context, int index, Animation<double> animation) {
|
||||
Widget _buildItem(BuildContext context, int index, Animation<double> animation) {
|
||||
return CardItem(
|
||||
animation: animation,
|
||||
item: _list[index],
|
||||
@@ -57,8 +55,7 @@ class _AnimatedListSampleState extends State<AnimatedListSample> {
|
||||
/// completed (even though it's gone as far as this ListModel is concerned).
|
||||
/// The widget will be used by the [AnimatedListState.removeItem] method's
|
||||
/// [AnimatedRemovedItemBuilder] parameter.
|
||||
Widget _buildRemovedItem(
|
||||
int item, BuildContext context, Animation<double> animation) {
|
||||
Widget _buildRemovedItem(int item, BuildContext context, Animation<double> animation) {
|
||||
return CardItem(
|
||||
animation: animation,
|
||||
item: item,
|
||||
@@ -68,8 +65,7 @@ class _AnimatedListSampleState extends State<AnimatedListSample> {
|
||||
|
||||
// Insert the "next item" into the list model.
|
||||
void _insert() {
|
||||
final int index =
|
||||
_selectedItem == null ? _list.length : _list.indexOf(_selectedItem!);
|
||||
final int index = _selectedItem == null ? _list.length : _list.indexOf(_selectedItem!);
|
||||
_list.insert(index, _nextItem++);
|
||||
}
|
||||
|
||||
@@ -115,8 +111,7 @@ 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].
|
||||
///
|
||||
@@ -178,7 +173,7 @@ class CardItem extends StatelessWidget {
|
||||
this.selected = false,
|
||||
required this.animation,
|
||||
required this.item,
|
||||
}) : assert(item >= 0);
|
||||
}) : assert(item >= 0);
|
||||
|
||||
final Animation<double> animation;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
@@ -2,30 +2,26 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [SliverAnimatedList].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [SliverAnimatedList].
|
||||
|
||||
void main() => runApp(const SliverAnimatedListSample());
|
||||
|
||||
class SliverAnimatedListSample extends StatefulWidget {
|
||||
const SliverAnimatedListSample({super.key});
|
||||
|
||||
@override
|
||||
State<SliverAnimatedListSample> createState() =>
|
||||
_SliverAnimatedListSampleState();
|
||||
State<SliverAnimatedListSample> createState() => _SliverAnimatedListSampleState();
|
||||
}
|
||||
|
||||
class _SliverAnimatedListSampleState extends State<SliverAnimatedListSample> {
|
||||
final GlobalKey<SliverAnimatedListState> _listKey =
|
||||
GlobalKey<SliverAnimatedListState>();
|
||||
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.
|
||||
late int _nextItem; // The next item inserted when the user presses the '+' button.
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -39,8 +35,7 @@ class _SliverAnimatedListSampleState extends State<SliverAnimatedListSample> {
|
||||
}
|
||||
|
||||
// Used to build list items that haven't been removed.
|
||||
Widget _buildItem(
|
||||
BuildContext context, int index, Animation<double> animation) {
|
||||
Widget _buildItem(BuildContext context, int index, Animation<double> animation) {
|
||||
return CardItem(
|
||||
animation: animation,
|
||||
item: _list[index],
|
||||
@@ -60,8 +55,7 @@ class _SliverAnimatedListSampleState extends State<SliverAnimatedListSample> {
|
||||
/// completed (even though it's gone as far this ListModel is concerned). The
|
||||
/// widget will be used by the [AnimatedListState.removeItem] method's
|
||||
/// [AnimatedRemovedItemBuilder] parameter.
|
||||
Widget _buildRemovedItem(
|
||||
int item, BuildContext context, Animation<double> animation) {
|
||||
Widget _buildRemovedItem(int item, BuildContext context, Animation<double> animation) {
|
||||
return CardItem(
|
||||
animation: animation,
|
||||
item: item,
|
||||
@@ -70,8 +64,7 @@ class _SliverAnimatedListSampleState extends State<SliverAnimatedListSample> {
|
||||
|
||||
// Insert the "next item" into the list model.
|
||||
void _insert() {
|
||||
final int index =
|
||||
_selectedItem == null ? _list.length : _list.indexOf(_selectedItem!);
|
||||
final int index = _selectedItem == null ? _list.length : _list.indexOf(_selectedItem!);
|
||||
_list.insert(index, _nextItem++);
|
||||
}
|
||||
|
||||
@@ -135,8 +128,7 @@ 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].
|
||||
//
|
||||
@@ -170,8 +162,7 @@ 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;
|
||||
@@ -219,9 +210,7 @@ class CardItem extends StatelessWidget {
|
||||
child: SizedBox(
|
||||
height: 80.0,
|
||||
child: Card(
|
||||
color: selected
|
||||
? Colors.black12
|
||||
: Colors.primaries[item % Colors.primaries.length],
|
||||
color: selected ? Colors.black12 : Colors.primaries[item % Colors.primaries.length],
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Item $item',
|
||||
|
||||
@@ -2,39 +2,36 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [AnimatedSize].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [AnimatedSize].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const AnimatedSizeExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class AnimatedSizeExampleApp extends StatelessWidget {
|
||||
const AnimatedSizeExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
appBar: AppBar(title: const Text('AnimatedSize Sample')),
|
||||
body: const Center(
|
||||
child: MyStatefulWidget(),
|
||||
child: AnimatedSizeExample(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class AnimatedSizeExample extends StatefulWidget {
|
||||
const AnimatedSizeExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<AnimatedSizeExample> createState() => _AnimatedSizeExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _AnimatedSizeExampleState extends State<AnimatedSizeExample> {
|
||||
double _size = 50.0;
|
||||
bool _large = false;
|
||||
|
||||
|
||||
@@ -2,34 +2,31 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [AnimatedSwitcher].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [AnimatedSwitcher].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const AnimatedSwitcherExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class AnimatedSwitcherExampleApp extends StatelessWidget {
|
||||
const AnimatedSwitcherExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
home: AnimatedSwitcherExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class AnimatedSwitcherExample extends StatefulWidget {
|
||||
const AnimatedSwitcherExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<AnimatedSwitcherExample> createState() => _AnimatedSwitcherExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _AnimatedSwitcherExampleState extends State<AnimatedSwitcherExample> {
|
||||
int _count = 0;
|
||||
|
||||
@override
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [WidgetsApp].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [WidgetsApp].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const WidgetsAppExampleApp());
|
||||
|
||||
class WidgetsAppExampleApp extends StatelessWidget {
|
||||
const WidgetsAppExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -19,7 +19,8 @@ class MyApp extends StatelessWidget {
|
||||
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),
|
||||
pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) =>
|
||||
builder(context),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,34 +2,31 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [FutureBuilder].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [FutureBuilder].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const FutureBuilderExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class FutureBuilderExampleApp extends StatelessWidget {
|
||||
const FutureBuilderExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
home: FutureBuilderExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class FutureBuilderExample extends StatefulWidget {
|
||||
const FutureBuilderExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<FutureBuilderExample> createState() => _FutureBuilderExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _FutureBuilderExampleState extends State<FutureBuilderExample> {
|
||||
final Future<String> _calculation = Future<String>.delayed(
|
||||
const Duration(seconds: 2),
|
||||
() => 'Data Loaded',
|
||||
|
||||
@@ -2,36 +2,33 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [StreamBuilder].
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [StreamBuilder].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const StreamBuilderExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class StreamBuilderExampleApp extends StatelessWidget {
|
||||
const StreamBuilderExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
home: StreamBuilderExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class StreamBuilderExample extends StatefulWidget {
|
||||
const StreamBuilderExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<StreamBuilderExample> createState() => _StreamBuilderExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _StreamBuilderExampleState extends State<StreamBuilderExample> {
|
||||
final Stream<int> _bids = (() {
|
||||
late final StreamController<int> controller;
|
||||
controller = StreamController<int>(
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [RawAutocomplete].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [RawAutocomplete].
|
||||
|
||||
void main() => runApp(const AutocompleteExampleApp());
|
||||
|
||||
class AutocompleteExampleApp extends StatelessWidget {
|
||||
@@ -43,10 +43,12 @@ class AutocompleteBasicExample extends StatelessWidget {
|
||||
return option.contains(textEditingValue.text.toLowerCase());
|
||||
});
|
||||
},
|
||||
fieldViewBuilder: (BuildContext context,
|
||||
TextEditingController textEditingController,
|
||||
FocusNode focusNode,
|
||||
VoidCallback onFieldSubmitted) {
|
||||
fieldViewBuilder: (
|
||||
BuildContext context,
|
||||
TextEditingController textEditingController,
|
||||
FocusNode focusNode,
|
||||
VoidCallback onFieldSubmitted,
|
||||
) {
|
||||
return TextFormField(
|
||||
controller: textEditingController,
|
||||
focusNode: focusNode,
|
||||
@@ -55,8 +57,11 @@ class AutocompleteBasicExample extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
},
|
||||
optionsViewBuilder: (BuildContext context,
|
||||
AutocompleteOnSelected<String> onSelected, Iterable<String> options) {
|
||||
optionsViewBuilder: (
|
||||
BuildContext context,
|
||||
AutocompleteOnSelected<String> onSelected,
|
||||
Iterable<String> options,
|
||||
) {
|
||||
return Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Material(
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [RawAutocomplete].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [RawAutocomplete].
|
||||
|
||||
void main() => runApp(const AutocompleteExampleApp());
|
||||
|
||||
class AutocompleteExampleApp extends StatelessWidget {
|
||||
@@ -72,16 +72,16 @@ class AutocompleteCustomTypeExample extends StatelessWidget {
|
||||
return _userOptions.where((User option) {
|
||||
// Search based on User.toString, which includes both name and
|
||||
// email, even though the display string is just the name.
|
||||
return option
|
||||
.toString()
|
||||
.contains(textEditingValue.text.toLowerCase());
|
||||
return option.toString().contains(textEditingValue.text.toLowerCase());
|
||||
});
|
||||
},
|
||||
displayStringForOption: _displayStringForOption,
|
||||
fieldViewBuilder: (BuildContext context,
|
||||
TextEditingController textEditingController,
|
||||
FocusNode focusNode,
|
||||
VoidCallback onFieldSubmitted) {
|
||||
fieldViewBuilder: (
|
||||
BuildContext context,
|
||||
TextEditingController textEditingController,
|
||||
FocusNode focusNode,
|
||||
VoidCallback onFieldSubmitted,
|
||||
) {
|
||||
return TextFormField(
|
||||
controller: textEditingController,
|
||||
focusNode: focusNode,
|
||||
@@ -90,8 +90,7 @@ 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(
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [RawAutocomplete].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [RawAutocomplete].
|
||||
|
||||
void main() => runApp(const AutocompleteExampleApp());
|
||||
|
||||
class AutocompleteExampleApp extends StatelessWidget {
|
||||
@@ -62,8 +62,7 @@ class AutocompleteFormExampleState extends State<AutocompleteFormExample> {
|
||||
_dropdownValue = newValue;
|
||||
});
|
||||
},
|
||||
items: <String>['One', 'Two', 'Free', 'Four']
|
||||
.map<DropdownMenuItem<String>>((String value) {
|
||||
items: <String>['One', 'Two', 'Free', 'Four'].map<DropdownMenuItem<String>>((String value) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: Text(value),
|
||||
@@ -99,10 +98,12 @@ class AutocompleteFormExampleState extends State<AutocompleteFormExample> {
|
||||
_autocompleteSelection = selection;
|
||||
});
|
||||
},
|
||||
fieldViewBuilder: (BuildContext context,
|
||||
TextEditingController textEditingController,
|
||||
FocusNode focusNode,
|
||||
VoidCallback onFieldSubmitted) {
|
||||
fieldViewBuilder: (
|
||||
BuildContext context,
|
||||
TextEditingController textEditingController,
|
||||
FocusNode focusNode,
|
||||
VoidCallback onFieldSubmitted,
|
||||
) {
|
||||
return TextFormField(
|
||||
controller: textEditingController,
|
||||
decoration: const InputDecoration(
|
||||
@@ -120,9 +121,11 @@ class AutocompleteFormExampleState extends State<AutocompleteFormExample> {
|
||||
},
|
||||
);
|
||||
},
|
||||
optionsViewBuilder: (BuildContext context,
|
||||
AutocompleteOnSelected<String> onSelected,
|
||||
Iterable<String> options) {
|
||||
optionsViewBuilder: (
|
||||
BuildContext context,
|
||||
AutocompleteOnSelected<String> onSelected,
|
||||
Iterable<String> options,
|
||||
) {
|
||||
return Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Material(
|
||||
@@ -164,8 +167,7 @@ class AutocompleteFormExampleState extends State<AutocompleteFormExample> {
|
||||
child: ListBody(
|
||||
children: <Widget>[
|
||||
Text('DropdownButtonFormField: "$_dropdownValue"'),
|
||||
Text(
|
||||
'TextFormField: "${_textEditingController.text}"'),
|
||||
Text('TextFormField: "${_textEditingController.text}"'),
|
||||
Text('RawAutocomplete: "$_autocompleteSelection"'),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [RawAutocomplete.focusNode].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [RawAutocomplete.focusNode].
|
||||
|
||||
void main() => runApp(const AutocompleteExampleApp());
|
||||
|
||||
class AutocompleteExampleApp extends StatelessWidget {
|
||||
@@ -64,9 +64,11 @@ class RawAutocompleteSplitState extends State<RawAutocompleteSplit> {
|
||||
return option.contains(textEditingValue.text.toLowerCase());
|
||||
}).toList();
|
||||
},
|
||||
optionsViewBuilder: (BuildContext context,
|
||||
AutocompleteOnSelected<String> onSelected,
|
||||
Iterable<String> options) {
|
||||
optionsViewBuilder: (
|
||||
BuildContext context,
|
||||
AutocompleteOnSelected<String> onSelected,
|
||||
Iterable<String> options,
|
||||
) {
|
||||
return Material(
|
||||
elevation: 4.0,
|
||||
child: ListView(
|
||||
|
||||
@@ -2,37 +2,34 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [AutofillGroup].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [AutofillGroup].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const AutofillGroupExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class AutofillGroupExampleApp extends StatelessWidget {
|
||||
const AutofillGroupExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
body: const MyStatefulWidget(),
|
||||
appBar: AppBar(title: const Text('AutofillGroup Sample')),
|
||||
body: const AutofillGroupExample(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class AutofillGroupExample extends StatefulWidget {
|
||||
const AutofillGroupExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<AutofillGroupExample> createState() => _AutofillGroupExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _AutofillGroupExampleState extends State<AutofillGroupExample> {
|
||||
bool isSameAddress = true;
|
||||
final TextEditingController shippingAddress1 = TextEditingController();
|
||||
final TextEditingController shippingAddress2 = TextEditingController();
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [AbsorbPointer].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [AbsorbPointer].
|
||||
|
||||
void main() => runApp(const AbsorbPointerApp());
|
||||
|
||||
class AbsorbPointerApp extends StatelessWidget {
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [AspectRatio].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [AspectRatio].
|
||||
|
||||
void main() => runApp(const AspectRatioApp());
|
||||
|
||||
class AspectRatioApp extends StatelessWidget {
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [AspectRatio].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [AspectRatio].
|
||||
|
||||
void main() => runApp(const AspectRatioApp());
|
||||
|
||||
class AspectRatioApp extends StatelessWidget {
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [AspectRatio].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [AspectRatio].
|
||||
|
||||
void main() => runApp(const AspectRatioApp());
|
||||
|
||||
class AspectRatioApp extends StatelessWidget {
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [ClipRRect].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [ClipRRect].
|
||||
|
||||
void main() => runApp(const ClipRRectApp());
|
||||
|
||||
class ClipRRectApp extends StatelessWidget {
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [ClipRRect].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [ClipRRect].
|
||||
|
||||
void main() => runApp(const ClipRRectApp());
|
||||
|
||||
class ClipRRectApp extends StatelessWidget {
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [CustomMultiChildLayout].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [CustomMultiChildLayout].
|
||||
|
||||
void main() => runApp(const ExampleApp());
|
||||
|
||||
class ExampleApp extends StatelessWidget {
|
||||
@@ -78,8 +78,7 @@ class _CascadeLayoutDelegate extends MultiChildLayoutDelegate {
|
||||
// automatically cause a relayout, like any other widget.
|
||||
@override
|
||||
bool shouldRelayout(_CascadeLayoutDelegate oldDelegate) {
|
||||
return oldDelegate.textDirection != textDirection
|
||||
|| oldDelegate.overlap != overlap;
|
||||
return oldDelegate.textDirection != textDirection || oldDelegate.overlap != overlap;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Expanded].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [Expanded].
|
||||
|
||||
void main() => runApp(const ExpandedApp());
|
||||
|
||||
class ExpandedApp extends StatelessWidget {
|
||||
@@ -19,7 +19,7 @@ class ExpandedApp extends StatelessWidget {
|
||||
title: const Text('Expanded Column Sample'),
|
||||
),
|
||||
body: const ExpandedExample(),
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Expanded].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [Expanded].
|
||||
|
||||
void main() => runApp(const ExpandedApp());
|
||||
|
||||
class ExpandedApp extends StatelessWidget {
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Flow].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [Flow].
|
||||
|
||||
void main() => runApp(const FlowApp());
|
||||
|
||||
class FlowApp extends StatelessWidget {
|
||||
@@ -31,8 +31,7 @@ class FlowMenu extends StatefulWidget {
|
||||
State<FlowMenu> createState() => _FlowMenuState();
|
||||
}
|
||||
|
||||
class _FlowMenuState extends State<FlowMenu>
|
||||
with SingleTickerProviderStateMixin {
|
||||
class _FlowMenuState extends State<FlowMenu> with SingleTickerProviderStateMixin {
|
||||
late AnimationController menuAnimation;
|
||||
IconData lastTapped = Icons.notifications;
|
||||
final List<IconData> menuItems = <IconData>[
|
||||
@@ -59,8 +58,7 @@ class _FlowMenuState extends State<FlowMenu>
|
||||
}
|
||||
|
||||
Widget flowMenuItem(IconData icon) {
|
||||
final double buttonDiameter =
|
||||
MediaQuery.of(context).size.width / menuItems.length;
|
||||
final double buttonDiameter = MediaQuery.of(context).size.width / menuItems.length;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: RawMaterialButton(
|
||||
@@ -70,9 +68,7 @@ class _FlowMenuState extends State<FlowMenu>
|
||||
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,
|
||||
@@ -87,15 +83,13 @@ class _FlowMenuState extends State<FlowMenu>
|
||||
Widget build(BuildContext context) {
|
||||
return Flow(
|
||||
delegate: FlowMenuDelegate(menuAnimation: menuAnimation),
|
||||
children:
|
||||
menuItems.map<Widget>((IconData icon) => flowMenuItem(icon)).toList(),
|
||||
children: menuItems.map<Widget>((IconData icon) => flowMenuItem(icon)).toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FlowMenuDelegate extends FlowDelegate {
|
||||
FlowMenuDelegate({required this.menuAnimation})
|
||||
: super(repaint: menuAnimation);
|
||||
FlowMenuDelegate({required this.menuAnimation}) : super(repaint: menuAnimation);
|
||||
|
||||
final Animation<double> menuAnimation;
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [FractionallySizedBox].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [FractionallySizedBox].
|
||||
|
||||
void main() => runApp(const FractionallySizedBoxApp());
|
||||
|
||||
class FractionallySizedBoxApp extends StatelessWidget {
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [IgnorePointer].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [IgnorePointer].
|
||||
|
||||
void main() => runApp(const IgnorePointerApp());
|
||||
|
||||
class IgnorePointerApp extends StatelessWidget {
|
||||
@@ -13,7 +13,7 @@ class IgnorePointerApp extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [IndexedStack].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [IndexedStack].
|
||||
|
||||
void main() => runApp(const IndexedStackApp());
|
||||
|
||||
class IndexedStackApp extends StatelessWidget {
|
||||
@@ -76,9 +76,7 @@ class _IndexedStackExampleState extends State<IndexedStackExample> {
|
||||
children: <Widget>[
|
||||
IndexedStack(
|
||||
index: index,
|
||||
children: <Widget>[
|
||||
for (String name in names) PersonTracker(name: name)
|
||||
],
|
||||
children: <Widget>[for (String name in names) PersonTracker(name: name)],
|
||||
)
|
||||
],
|
||||
),
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Listener].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [Listener].
|
||||
|
||||
void main() => runApp(const ListenerApp());
|
||||
|
||||
class ListenerApp extends StatelessWidget {
|
||||
@@ -71,8 +71,7 @@ class _ListenerExampleState extends State<ListenerExample> {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
const Text(
|
||||
'You have pressed or released in this area this many times:'),
|
||||
const Text('You have pressed or released in this area this many times:'),
|
||||
Text(
|
||||
'$_downCounter presses\n$_upCounter releases',
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [MouseRegion].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [MouseRegion].
|
||||
|
||||
void main() => runApp(const MouseRegionApp());
|
||||
|
||||
class MouseRegionApp extends StatelessWidget {
|
||||
@@ -69,8 +69,7 @@ class _MouseRegionExampleState extends State<MouseRegionExample> {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
const Text(
|
||||
'You have entered or exited this box this many times:'),
|
||||
const Text('You have entered or exited this box this many times:'),
|
||||
Text(
|
||||
'$_enterCounter Entries\n$_exitCounter Exits',
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [MouseRegion.onExit].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [MouseRegion.onExit].
|
||||
|
||||
void main() => runApp(const MouseRegionApp());
|
||||
|
||||
class MouseRegionApp extends StatelessWidget {
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [MouseRegion.onExit].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [MouseRegion.onExit].
|
||||
|
||||
void main() => runApp(const MouseRegionApp());
|
||||
|
||||
class MouseRegionApp extends StatelessWidget {
|
||||
@@ -26,8 +26,7 @@ class MouseRegionApp extends StatelessWidget {
|
||||
|
||||
// A region that hides its content one second after being hovered.
|
||||
class MyTimedButton extends StatefulWidget {
|
||||
const MyTimedButton(
|
||||
{super.key, required this.onEnterButton, required this.onExitButton});
|
||||
const MyTimedButton({super.key, required this.onEnterButton, required this.onExitButton});
|
||||
|
||||
final VoidCallback onEnterButton;
|
||||
final VoidCallback onExitButton;
|
||||
@@ -62,23 +61,23 @@ class _MyTimedButton extends State<MyTimedButton> {
|
||||
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),
|
||||
),
|
||||
? null
|
||||
: MouseRegion(
|
||||
onEnter: (_) {
|
||||
widget.onEnterButton();
|
||||
setState(() {
|
||||
hovered = true;
|
||||
});
|
||||
startCountdown();
|
||||
},
|
||||
onExit: (_) {
|
||||
setState(() {
|
||||
hovered = false;
|
||||
});
|
||||
widget.onExitButton();
|
||||
},
|
||||
child: Container(color: Colors.red),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Offstage].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [Offstage].
|
||||
|
||||
void main() => runApp(const OffstageApp());
|
||||
|
||||
class OffstageApp extends StatelessWidget {
|
||||
@@ -36,8 +36,7 @@ class _OffstageExampleState extends State<OffstageExample> {
|
||||
bool _offstage = true;
|
||||
|
||||
Size _getFlutterLogoSize() {
|
||||
final RenderBox renderLogo =
|
||||
_key.currentContext!.findRenderObject()! as RenderBox;
|
||||
final RenderBox renderLogo = _key.currentContext!.findRenderObject()! as RenderBox;
|
||||
return renderLogo.size;
|
||||
}
|
||||
|
||||
@@ -68,8 +67,7 @@ class _OffstageExampleState extends State<OffstageExample> {
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content:
|
||||
Text('Flutter Logo size is ${_getFlutterLogoSize()}'),
|
||||
content: Text('Flutter Logo size is ${_getFlutterLogoSize()}'),
|
||||
),
|
||||
);
|
||||
}),
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [OverflowBox].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [OverflowBox].
|
||||
|
||||
void main() => runApp(const OverflowBoxApp());
|
||||
|
||||
class OverflowBoxApp extends StatelessWidget {
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [PhysicalShape].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [PhysicalShape].
|
||||
|
||||
void main() => runApp(const PhysicalShapeApp());
|
||||
|
||||
class PhysicalShapeApp extends StatelessWidget {
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [WidgetBindingsObserver].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [WidgetBindingsObserver].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const WidgetBindingObserverExampleApp());
|
||||
|
||||
class WidgetBindingObserverExampleApp extends StatelessWidget {
|
||||
const WidgetBindingObserverExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -30,20 +30,22 @@ class WidgetBindingsObserverSample extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _WidgetBindingsObserverSampleState extends State<WidgetBindingsObserverSample> with WidgetsBindingObserver {
|
||||
final List<AppLifecycleState> _stateHistoryList = <AppLifecycleState>[];
|
||||
final List<AppLifecycleState> _stateHistoryList = <AppLifecycleState>[];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
if(WidgetsBinding.instance.lifecycleState != null) {
|
||||
if (WidgetsBinding.instance.lifecycleState != null) {
|
||||
_stateHistoryList.add(WidgetsBinding.instance.lifecycleState!);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||
setState(() { _stateHistoryList.add(state); });
|
||||
setState(() {
|
||||
_stateHistoryList.add(state);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -59,9 +61,9 @@ class _WidgetBindingsObserverSampleState extends State<WidgetBindingsObserverSam
|
||||
key: const ValueKey<String>('stateHistoryList'),
|
||||
itemCount: _stateHistoryList.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Text('state is: ${_stateHistoryList[index]}');
|
||||
},
|
||||
);
|
||||
return Text('state is: ${_stateHistoryList[index]}');
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return const Center(child: Text('There are no AppLifecycleStates to show.'));
|
||||
|
||||
@@ -2,31 +2,28 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [ColorFiltered].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [ColorFiltered].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const ColorFilteredExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class ColorFilteredExampleApp extends StatelessWidget {
|
||||
const ColorFilteredExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
body: const MyStatelessWidget(),
|
||||
appBar: AppBar(title: const Text('ColorFiltered Sample')),
|
||||
body: const ColorFilteredExample(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatelessWidget extends StatelessWidget {
|
||||
const MyStatelessWidget({super.key});
|
||||
class ColorFilteredExample extends StatelessWidget {
|
||||
const ColorFilteredExample({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -2,37 +2,34 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Dismissible].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [Dismissible].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const DismissibleExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class DismissibleExampleApp extends StatelessWidget {
|
||||
const DismissibleExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
body: const MyStatefulWidget(),
|
||||
appBar: AppBar(title: const Text('Dismissible Sample')),
|
||||
body: const DismissibleExample(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class DismissibleExample extends StatefulWidget {
|
||||
const DismissibleExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<DismissibleExample> createState() => _DismissibleExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _DismissibleExampleState extends State<DismissibleExample> {
|
||||
List<int> items = List<int>.generate(100, (int index) => index);
|
||||
|
||||
@override
|
||||
|
||||
@@ -2,37 +2,34 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Draggable].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [Draggable].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const DraggableExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class DraggableExampleApp extends StatelessWidget {
|
||||
const DraggableExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
body: const MyStatefulWidget(),
|
||||
appBar: AppBar(title: const Text('Draggable Sample')),
|
||||
body: const DraggableExample(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class DraggableExample extends StatefulWidget {
|
||||
const DraggableExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<DraggableExample> createState() => _DraggableExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _DraggableExampleState extends State<DraggableExample> {
|
||||
int acceptedData = 0;
|
||||
|
||||
@override
|
||||
|
||||
@@ -2,34 +2,31 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [EditableText.onChanged].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [EditableText.onChanged].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const OnChangedExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class OnChangedExampleApp extends StatelessWidget {
|
||||
const OnChangedExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
home: OnChangedExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class OnChangedExample extends StatefulWidget {
|
||||
const OnChangedExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<OnChangedExample> createState() => _OnChangedExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _OnChangedExampleState extends State<OnChangedExample> {
|
||||
final TextEditingController _controller = TextEditingController();
|
||||
|
||||
@override
|
||||
|
||||
@@ -2,23 +2,20 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for EditableText.onContentInserted
|
||||
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [EditableText.onContentInserted].
|
||||
|
||||
void main() => runApp(const KeyboardInsertedContentApp());
|
||||
|
||||
class KeyboardInsertedContentApp extends StatelessWidget {
|
||||
const KeyboardInsertedContentApp({super.key});
|
||||
|
||||
static const String _title = 'Keyboard Inserted Content Sample';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: KeyboardInsertedContentDemo(),
|
||||
);
|
||||
}
|
||||
@@ -62,10 +59,8 @@ class _KeyboardInsertedContentDemoState extends State<KeyboardInsertedContentDem
|
||||
},
|
||||
),
|
||||
),
|
||||
if (bytes != null)
|
||||
const Text("Here's the most recently inserted content:"),
|
||||
if (bytes != null)
|
||||
Image.memory(bytes!),
|
||||
if (bytes != null) const Text("Here's the most recently inserted content:"),
|
||||
if (bytes != null) Image.memory(bytes!),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -2,34 +2,31 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [TextEditingController].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [TextEditingController].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const TextEditingControllerExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class TextEditingControllerExampleApp extends StatelessWidget {
|
||||
const TextEditingControllerExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
home: TextEditingControllerExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class TextEditingControllerExample extends StatefulWidget {
|
||||
const TextEditingControllerExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<TextEditingControllerExample> createState() => _TextEditingControllerExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _TextEditingControllerExampleState extends State<TextEditingControllerExample> {
|
||||
final TextEditingController _controller = TextEditingController();
|
||||
|
||||
@override
|
||||
@@ -39,8 +36,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
final String text = _controller.text.toLowerCase();
|
||||
_controller.value = _controller.value.copyWith(
|
||||
text: text,
|
||||
selection:
|
||||
TextSelection(baseOffset: text.length, extentOffset: text.length),
|
||||
selection: TextSelection(baseOffset: text.length, extentOffset: text.length),
|
||||
composing: TextRange.empty,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -2,25 +2,22 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [FocusNode].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [FocusNode].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const FocusNodeExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class FocusNodeExampleApp extends StatelessWidget {
|
||||
const FocusNodeExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
body: const MyStatelessWidget(),
|
||||
appBar: AppBar(title: const Text('FocusNode Sample')),
|
||||
body: const FocusNodeExample(),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -106,16 +103,15 @@ class _ColorfulButtonState extends State<ColorfulButton> {
|
||||
height: 100,
|
||||
color: _focused ? _color : Colors.white,
|
||||
alignment: Alignment.center,
|
||||
child:
|
||||
Text(_focused ? "I'm in color! Press R,G,B!" : 'Press to focus'),
|
||||
child: Text(_focused ? "I'm in color! Press R,G,B!" : 'Press to focus'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatelessWidget extends StatelessWidget {
|
||||
const MyStatelessWidget({super.key});
|
||||
class FocusNodeExample extends StatelessWidget {
|
||||
const FocusNodeExample({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -2,35 +2,31 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [FocusNode.unfocus].
|
||||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [FocusNode.unfocus].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const UnfocusExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class UnfocusExampleApp extends StatelessWidget {
|
||||
const UnfocusExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
home: UnfocusExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class UnfocusExample extends StatefulWidget {
|
||||
const UnfocusExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<UnfocusExample> createState() => _UnfocusExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _UnfocusExampleState extends State<UnfocusExample> {
|
||||
UnfocusDisposition disposition = UnfocusDisposition.scope;
|
||||
|
||||
@override
|
||||
@@ -57,8 +53,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: <Widget>[
|
||||
...List<Widget>.generate(UnfocusDisposition.values.length,
|
||||
(int index) {
|
||||
...List<Widget>.generate(UnfocusDisposition.values.length, (int index) {
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
|
||||
@@ -2,38 +2,35 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Focus].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [Focus].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const FocusExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class FocusExampleApp extends StatelessWidget {
|
||||
const FocusExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
body: const MyStatefulWidget(),
|
||||
appBar: AppBar(title: const Text('Focus Sample')),
|
||||
body: const FocusExample(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class FocusExample extends StatefulWidget {
|
||||
const FocusExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<FocusExample> createState() => _FocusExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _FocusExampleState extends State<FocusExample> {
|
||||
Color _color = Colors.white;
|
||||
|
||||
KeyEventResult _handleKeyPress(FocusNode node, RawKeyEvent event) {
|
||||
@@ -91,9 +88,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
height: 100,
|
||||
alignment: Alignment.center,
|
||||
color: hasFocus ? _color : Colors.white,
|
||||
child: Text(hasFocus
|
||||
? "I'm in color! Press R,G,B!"
|
||||
: 'Press to focus'),
|
||||
child: Text(hasFocus ? "I'm in color! Press R,G,B!" : 'Press to focus'),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -2,22 +2,19 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Focus].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [Focus].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const FocusExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class FocusExampleApp extends StatelessWidget {
|
||||
const FocusExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatelessWidget(),
|
||||
home: FocusExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -58,8 +55,8 @@ class FocusableText extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatelessWidget extends StatelessWidget {
|
||||
const MyStatelessWidget({super.key});
|
||||
class FocusExample extends StatelessWidget {
|
||||
const FocusExample({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -2,34 +2,31 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Focus].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [Focus].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const FocusExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class FocusExampleApp extends StatelessWidget {
|
||||
const FocusExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
home: FocusExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class FocusExample extends StatefulWidget {
|
||||
const FocusExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<FocusExample> createState() => _FocusExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _FocusExampleState extends State<FocusExample> {
|
||||
int focusedChild = 0;
|
||||
List<Widget> children = <Widget>[];
|
||||
List<FocusNode> childFocusNodes = <FocusNode>[];
|
||||
@@ -52,8 +49,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
void _addChild() {
|
||||
// Calling requestFocus here creates a deferred request for focus, since the
|
||||
// node is not yet part of the focus tree.
|
||||
childFocusNodes
|
||||
.add(FocusNode(debugLabel: 'Child ${children.length}')..requestFocus());
|
||||
childFocusNodes.add(FocusNode(debugLabel: 'Child ${children.length}')..requestFocus());
|
||||
|
||||
children.add(Padding(
|
||||
padding: const EdgeInsets.all(2.0),
|
||||
|
||||
@@ -2,22 +2,19 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [FocusScope].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [FocusScope].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const FocusScopeExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class FocusScopeExampleApp extends StatelessWidget {
|
||||
const FocusScopeExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
home: FocusScopeExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -66,14 +63,14 @@ class Pane extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class FocusScopeExample extends StatefulWidget {
|
||||
const FocusScopeExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<FocusScopeExample> createState() => _FocusScopeExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _FocusScopeExampleState extends State<FocusScopeExample> {
|
||||
bool backdropIsVisible = false;
|
||||
FocusNode backdropNode = FocusNode(debugLabel: 'Close Backdrop Button');
|
||||
FocusNode foregroundNode = FocusNode(debugLabel: 'Option Button');
|
||||
@@ -119,8 +116,9 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
child: const Text('ANOTHER BUTTON TO FOCUS'),
|
||||
),
|
||||
DefaultTextStyle(
|
||||
style: Theme.of(context).textTheme.displayMedium!,
|
||||
child: const Text('BACKDROP')),
|
||||
style: Theme.of(context).textTheme.displayMedium!,
|
||||
child: const Text('BACKDROP'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -144,12 +142,11 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
// TRY THIS: Try changing this to Colors.green.withOpacity(0.8) to see for
|
||||
// yourself that the hidden components do/don't get focus.
|
||||
backgroundColor: Colors.green,
|
||||
onPressed: backdropIsVisible
|
||||
? null
|
||||
: () => setState(() => backdropIsVisible = true),
|
||||
onPressed: backdropIsVisible ? null : () => setState(() => backdropIsVisible = true),
|
||||
child: DefaultTextStyle(
|
||||
style: Theme.of(context).textTheme.displayMedium!,
|
||||
child: const Text('FOREGROUND')),
|
||||
style: Theme.of(context).textTheme.displayMedium!,
|
||||
child: const Text('FOREGROUND'),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -2,22 +2,19 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [FocusTraversalGroup].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [FocusTraversalGroup].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const FocusTraversalGroupExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class FocusTraversalGroupExampleApp extends StatelessWidget {
|
||||
const FocusTraversalGroupExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatelessWidget(),
|
||||
home: FocusTraversalGroupExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -92,8 +89,7 @@ class _OrderedButtonState<T> extends State<OrderedButton<T>> {
|
||||
}
|
||||
|
||||
Color? foregroundColor(Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.focused) ||
|
||||
states.contains(MaterialState.hovered)) {
|
||||
if (states.contains(MaterialState.focused) || states.contains(MaterialState.hovered)) {
|
||||
return Colors.white;
|
||||
}
|
||||
return null; // defer to the default foregroundColor
|
||||
@@ -107,10 +103,8 @@ class _OrderedButtonState<T> extends State<OrderedButton<T>> {
|
||||
focusNode: focusNode,
|
||||
autofocus: widget.autofocus,
|
||||
style: ButtonStyle(
|
||||
overlayColor:
|
||||
MaterialStateProperty.resolveWith<Color?>(overlayColor),
|
||||
foregroundColor:
|
||||
MaterialStateProperty.resolveWith<Color?>(foregroundColor),
|
||||
overlayColor: MaterialStateProperty.resolveWith<Color?>(overlayColor),
|
||||
foregroundColor: MaterialStateProperty.resolveWith<Color?>(foregroundColor),
|
||||
),
|
||||
onPressed: () => _handleOnPressed(),
|
||||
child: Text(widget.name),
|
||||
@@ -120,8 +114,8 @@ class _OrderedButtonState<T> extends State<OrderedButton<T>> {
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatelessWidget extends StatelessWidget {
|
||||
const MyStatelessWidget({super.key});
|
||||
class FocusTraversalGroupExample extends StatelessWidget {
|
||||
const FocusTraversalGroupExample({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -153,8 +147,7 @@ class MyStatelessWidget extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: List<Widget>.generate(3, (int index) {
|
||||
// Order as "C" "B", "A".
|
||||
final String order =
|
||||
String.fromCharCode('A'.codeUnitAt(0) + (2 - index));
|
||||
final String order = String.fromCharCode('A'.codeUnitAt(0) + (2 - index));
|
||||
return OrderedButton<String>(
|
||||
name: 'String: $order',
|
||||
order: order,
|
||||
|
||||
@@ -2,25 +2,22 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [OrderedTraversalPolicy].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [OrderedTraversalPolicy].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const OrderedTraversalPolicyExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class OrderedTraversalPolicyExampleApp extends StatelessWidget {
|
||||
const OrderedTraversalPolicyExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
appBar: AppBar(title: const Text('OrderedTraversalPolicy Sample')),
|
||||
body: const Center(
|
||||
child: MyStatelessWidget(),
|
||||
child: OrderedTraversalPolicyExample(),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -57,8 +54,8 @@ class DemoButton extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatelessWidget extends StatelessWidget {
|
||||
const MyStatelessWidget({super.key});
|
||||
class OrderedTraversalPolicyExample extends StatelessWidget {
|
||||
const OrderedTraversalPolicyExample({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -2,37 +2,34 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Form].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [Form].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const FormExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class FormExampleApp extends StatelessWidget {
|
||||
const FormExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
body: const MyStatefulWidget(),
|
||||
appBar: AppBar(title: const Text('Form Sample')),
|
||||
body: const FormExample(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class FormExample extends StatefulWidget {
|
||||
const FormExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<FormExample> createState() => _FormExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _FormExampleState extends State<FormExample> {
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [BuildOwner].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
/// Flutter code sample for [BuildOwner].
|
||||
|
||||
void main() {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
final Size size = measureWidget(const SizedBox(width: 640, height: 480));
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [ErrorWidget].
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [ErrorWidget].
|
||||
|
||||
void main() {
|
||||
// Set the ErrorWidget's builder before the app is started.
|
||||
ErrorWidget.builder = (FlutterErrorDetails details) {
|
||||
@@ -28,19 +28,17 @@ void main() {
|
||||
};
|
||||
|
||||
// Start the app.
|
||||
runApp(const MyApp());
|
||||
runApp(const ErrorWidgetExampleApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatefulWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
static const String _title = 'ErrorWidget Sample';
|
||||
class ErrorWidgetExampleApp extends StatefulWidget {
|
||||
const ErrorWidgetExampleApp({super.key});
|
||||
|
||||
@override
|
||||
State<MyApp> createState() => _MyAppState();
|
||||
State<ErrorWidgetExampleApp> createState() => _ErrorWidgetExampleAppState();
|
||||
}
|
||||
|
||||
class _MyAppState extends State<MyApp> {
|
||||
class _ErrorWidgetExampleAppState extends State<ErrorWidgetExampleApp> {
|
||||
bool throwError = false;
|
||||
|
||||
@override
|
||||
@@ -55,13 +53,14 @@ class _MyAppState extends State<MyApp> {
|
||||
);
|
||||
} else {
|
||||
return MaterialApp(
|
||||
title: MyApp._title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(MyApp._title)),
|
||||
appBar: AppBar(title: const Text('ErrorWidget Sample')),
|
||||
body: Center(
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
setState(() { throwError = true; });
|
||||
setState(() {
|
||||
throwError = true;
|
||||
});
|
||||
},
|
||||
child: const Text('Error Prone')),
|
||||
),
|
||||
|
||||
@@ -2,34 +2,31 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [GestureDetector].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [GestureDetector].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const GestureDetectorExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class GestureDetectorExampleApp extends StatelessWidget {
|
||||
const GestureDetectorExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
home: GestureDetectorExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class GestureDetectorExample extends StatefulWidget {
|
||||
const GestureDetectorExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<GestureDetectorExample> createState() => _GestureDetectorExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _GestureDetectorExampleState extends State<GestureDetectorExample> {
|
||||
bool _lightIsOn = false;
|
||||
|
||||
@override
|
||||
|
||||
@@ -2,34 +2,31 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [GestureDetector].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [GestureDetector].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const GestureDetectorExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class GestureDetectorExampleApp extends StatelessWidget {
|
||||
const GestureDetectorExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
home: GestureDetectorExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class GestureDetectorExample extends StatefulWidget {
|
||||
const GestureDetectorExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<GestureDetectorExample> createState() => _GestureDetectorExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _GestureDetectorExampleState extends State<GestureDetectorExample> {
|
||||
Color _color = Colors.white;
|
||||
|
||||
@override
|
||||
@@ -41,9 +38,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_color == Colors.yellow
|
||||
? _color = Colors.white
|
||||
: _color = Colors.yellow;
|
||||
_color == Colors.yellow ? _color = Colors.white : _color = Colors.yellow;
|
||||
});
|
||||
},
|
||||
),
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [GestureDetector].
|
||||
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [GestureDetector].
|
||||
|
||||
void main() {
|
||||
debugPrintGestureArenaDiagnostics = true;
|
||||
runApp(const NestedGestureDetectorsApp());
|
||||
@@ -35,8 +35,7 @@ class NestedGestureDetectorsExample extends StatefulWidget {
|
||||
State<NestedGestureDetectorsExample> createState() => _NestedGestureDetectorsExampleState();
|
||||
}
|
||||
|
||||
class _NestedGestureDetectorsExampleState
|
||||
extends State<NestedGestureDetectorsExample> {
|
||||
class _NestedGestureDetectorsExampleState extends State<NestedGestureDetectorsExample> {
|
||||
bool _isYellowTranslucent = false;
|
||||
_OnTapWinner _winner = _OnTapWinner.none;
|
||||
final Border highlightBorder = Border.all(color: Colors.red, width: 5);
|
||||
@@ -66,9 +65,7 @@ class _NestedGestureDetectorsExampleState
|
||||
// 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(() {
|
||||
|
||||
@@ -2,20 +2,22 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [KeyEventManager.keyMessageHandler].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
void main() => runApp(
|
||||
const MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: FallbackDemo(),
|
||||
)
|
||||
/// Flutter code sample for [KeyEventManager.keyMessageHandler].
|
||||
|
||||
void main() {
|
||||
runApp(
|
||||
const MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: FallbackDemo(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
class FallbackDemo extends StatefulWidget {
|
||||
const FallbackDemo({super.key});
|
||||
@@ -38,7 +40,7 @@ class FallbackDemoState extends State<FallbackDemo> {
|
||||
// to type text, because these key events will no longer be sent to the
|
||||
// text input system.
|
||||
return false;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
@override
|
||||
@@ -52,7 +54,7 @@ class FallbackDemoState extends State<FallbackDemo> {
|
||||
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!'),
|
||||
'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(
|
||||
@@ -67,7 +69,7 @@ class FallbackDemoState extends State<FallbackDemo> {
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -113,6 +115,7 @@ class FallbackKeyEventRegistrar {
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
||||
static bool _initialized = false;
|
||||
static final FallbackKeyEventRegistrar _instance = FallbackKeyEventRegistrar._();
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Hero].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [Hero].
|
||||
|
||||
void main() => runApp(const HeroApp());
|
||||
|
||||
class HeroApp extends StatelessWidget {
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Hero].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
|
||||
/// Flutter code sample for [Hero].
|
||||
|
||||
void main() {
|
||||
// Slow down time to see Hero flight animation.
|
||||
timeDilation = 15.0;
|
||||
@@ -38,7 +38,7 @@ class HeroExample extends StatelessWidget {
|
||||
tag: 'hero-default-tween',
|
||||
child: BoxWidget(
|
||||
size: const Size(50.0, 50.0),
|
||||
color:Colors.red[700]!.withOpacity(0.5),
|
||||
color: Colors.red[700]!.withOpacity(0.5),
|
||||
),
|
||||
),
|
||||
title: const Text(
|
||||
@@ -54,7 +54,7 @@ class HeroExample extends StatelessWidget {
|
||||
},
|
||||
child: BoxWidget(
|
||||
size: const Size(50.0, 50.0),
|
||||
color:Colors.blue[700]!.withOpacity(0.5),
|
||||
color: Colors.blue[700]!.withOpacity(0.5),
|
||||
),
|
||||
),
|
||||
title: const Text(
|
||||
|
||||
@@ -2,32 +2,29 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Image.errorBuilder].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [Image.errorBuilder].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const ErrorBuilderExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class ErrorBuilderExampleApp extends StatelessWidget {
|
||||
const ErrorBuilderExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: MyStatelessWidget(),
|
||||
child: ErrorBuilderExample(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatelessWidget extends StatelessWidget {
|
||||
const MyStatelessWidget({super.key});
|
||||
class ErrorBuilderExample extends StatelessWidget {
|
||||
const ErrorBuilderExample({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -39,8 +36,7 @@ class MyStatelessWidget extends StatelessWidget {
|
||||
),
|
||||
child: Image.network(
|
||||
'https://example.does.not.exist/image.jpg',
|
||||
errorBuilder:
|
||||
(BuildContext context, Object exception, StackTrace? stackTrace) {
|
||||
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
|
||||
// Appropriate logging or analytics, e.g.
|
||||
// myAnalytics.recordError(
|
||||
// 'An error occurred loading "https://example.does.not.exist/image.jpg"',
|
||||
|
||||
@@ -2,28 +2,25 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Image.frameBuilder].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [Image.frameBuilder].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const FrameBuilderExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class FrameBuilderExampleApp extends StatelessWidget {
|
||||
const FrameBuilderExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatelessWidget(),
|
||||
home: FrameBuilderExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatelessWidget extends StatelessWidget {
|
||||
const MyStatelessWidget({super.key});
|
||||
class FrameBuilderExample extends StatelessWidget {
|
||||
const FrameBuilderExample({super.key});
|
||||
|
||||
@override
|
||||
@override
|
||||
@@ -36,8 +33,7 @@ class MyStatelessWidget 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;
|
||||
}
|
||||
|
||||
@@ -2,28 +2,25 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Image.loadingBuilder].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [Image.loadingBuilder].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const LoadingBuilderExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class LoadingBuilderExampleApp extends StatelessWidget {
|
||||
const LoadingBuilderExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatelessWidget(),
|
||||
home: LoadingBuilderExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatelessWidget extends StatelessWidget {
|
||||
const MyStatelessWidget({super.key});
|
||||
class LoadingBuilderExample extends StatelessWidget {
|
||||
const LoadingBuilderExample({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -35,16 +32,14 @@ class MyStatelessWidget extends StatelessWidget {
|
||||
),
|
||||
child: Image.network(
|
||||
'https://flutter.github.io/assets-for-api-docs/assets/widgets/falcon.jpg',
|
||||
loadingBuilder: (BuildContext context, Widget child,
|
||||
ImageChunkEvent? loadingProgress) {
|
||||
loadingBuilder: (BuildContext context, Widget child, ImageChunkEvent? loadingProgress) {
|
||||
if (loadingProgress == null) {
|
||||
return child;
|
||||
}
|
||||
return Center(
|
||||
child: CircularProgressIndicator(
|
||||
value: loadingProgress.expectedTotalBytes != null
|
||||
? loadingProgress.cumulativeBytesLoaded /
|
||||
loadingProgress.expectedTotalBytes!
|
||||
? loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes!
|
||||
: null,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -2,37 +2,34 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [AnimatedAlign].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [AnimatedAlign].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const AnimatedAlignExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class AnimatedAlignExampleApp extends StatelessWidget {
|
||||
const AnimatedAlignExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
body: const MyStatefulWidget(),
|
||||
appBar: AppBar(title: const Text('AnimatedAlign Sample')),
|
||||
body: const AnimatedAlignExample(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class AnimatedAlignExample extends StatefulWidget {
|
||||
const AnimatedAlignExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<AnimatedAlignExample> createState() => _AnimatedAlignExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _AnimatedAlignExampleState extends State<AnimatedAlignExample> {
|
||||
bool selected = false;
|
||||
|
||||
@override
|
||||
|
||||
@@ -2,37 +2,34 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [AnimatedContainer].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [AnimatedContainer].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const AnimatedContainerExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class AnimatedContainerExampleApp extends StatelessWidget {
|
||||
const AnimatedContainerExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
body: const MyStatefulWidget(),
|
||||
appBar: AppBar(title: const Text('AnimatedContainer Sample')),
|
||||
body: const AnimatedContainerExample(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class AnimatedContainerExample extends StatefulWidget {
|
||||
const AnimatedContainerExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<AnimatedContainerExample> createState() => _AnimatedContainerExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _AnimatedContainerExampleState extends State<AnimatedContainerExample> {
|
||||
bool selected = false;
|
||||
|
||||
@override
|
||||
@@ -48,8 +45,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
width: selected ? 200.0 : 100.0,
|
||||
height: selected ? 100.0 : 200.0,
|
||||
color: selected ? Colors.red : Colors.blue,
|
||||
alignment:
|
||||
selected ? Alignment.center : AlignmentDirectional.topCenter,
|
||||
alignment: selected ? Alignment.center : AlignmentDirectional.topCenter,
|
||||
duration: const Duration(seconds: 2),
|
||||
curve: Curves.fastOutSlowIn,
|
||||
child: const FlutterLogo(size: 75),
|
||||
|
||||
@@ -2,37 +2,34 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [AnimatedFractionallySizedBox].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [AnimatedFractionallySizedBox].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const AnimatedFractionallySizedBoxExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class AnimatedFractionallySizedBoxExampleApp extends StatelessWidget {
|
||||
const AnimatedFractionallySizedBoxExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
body: const MyStatefulWidget(),
|
||||
appBar: AppBar(title: const Text('AnimatedFractionallySizedBox Sample')),
|
||||
body: const AnimatedFractionallySizedBoxExample(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class AnimatedFractionallySizedBoxExample extends StatefulWidget {
|
||||
const AnimatedFractionallySizedBoxExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<AnimatedFractionallySizedBoxExample> createState() => _AnimatedFractionallySizedBoxExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _AnimatedFractionallySizedBoxExampleState extends State<AnimatedFractionallySizedBoxExample> {
|
||||
bool selected = false;
|
||||
|
||||
@override
|
||||
|
||||
@@ -2,37 +2,34 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [AnimatedPadding].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [AnimatedPadding].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const AnimatedPaddingExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class AnimatedPaddingExampleApp extends StatelessWidget {
|
||||
const AnimatedPaddingExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
body: const MyStatefulWidget(),
|
||||
appBar: AppBar(title: const Text('AnimatedPadding Sample')),
|
||||
body: const AnimatedPaddingExample(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class AnimatedPaddingExample extends StatefulWidget {
|
||||
const AnimatedPaddingExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<AnimatedPaddingExample> createState() => _AnimatedPaddingExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _AnimatedPaddingExampleState extends State<AnimatedPaddingExample> {
|
||||
double padValue = 0.0;
|
||||
void _updatePadding(double value) {
|
||||
setState(() {
|
||||
|
||||
@@ -2,39 +2,36 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [AnimatedPositioned].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [AnimatedPositioned].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const AnimatedPositionedExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class AnimatedPositionedExampleApp extends StatelessWidget {
|
||||
const AnimatedPositionedExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
appBar: AppBar(title: const Text('AnimatedPositioned Sample')),
|
||||
body: const Center(
|
||||
child: MyStatefulWidget(),
|
||||
child: AnimatedPositionedExample(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class AnimatedPositionedExample extends StatefulWidget {
|
||||
const AnimatedPositionedExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<AnimatedPositionedExample> createState() => _AnimatedPositionedExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _AnimatedPositionedExampleState extends State<AnimatedPositionedExample> {
|
||||
bool selected = false;
|
||||
|
||||
@override
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [AnimatedSlide].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [AnimatedSlide].
|
||||
|
||||
void main() => runApp(const AnimatedSlideApp());
|
||||
|
||||
class AnimatedSlideApp extends StatelessWidget {
|
||||
|
||||
@@ -2,39 +2,36 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [SliverAnimatedOpacity].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [SliverAnimatedOpacity].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const SliverAnimatedOpacityExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class SliverAnimatedOpacityExampleApp extends StatelessWidget {
|
||||
const SliverAnimatedOpacityExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
appBar: AppBar(title: const Text('SliverAnimatedOpacity Sample')),
|
||||
body: const Center(
|
||||
child: MyStatefulWidget(),
|
||||
child: SliverAnimatedOpacityExample(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class SliverAnimatedOpacityExample extends StatefulWidget {
|
||||
const SliverAnimatedOpacityExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<SliverAnimatedOpacityExample> createState() => _SliverAnimatedOpacityExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget>
|
||||
class _SliverAnimatedOpacityExampleState extends State<SliverAnimatedOpacityExample>
|
||||
with SingleTickerProviderStateMixin {
|
||||
bool _visible = true;
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [InheritedModel].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [InheritedModel].
|
||||
|
||||
enum LogoAspect { backgroundColor, large }
|
||||
|
||||
void main() => runApp(const InheritedModelApp());
|
||||
@@ -42,8 +42,7 @@ class LogoModel extends InheritedModel<LogoAspect> {
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(LogoModel oldWidget) {
|
||||
return backgroundColor != oldWidget.backgroundColor ||
|
||||
large != oldWidget.large;
|
||||
return backgroundColor != oldWidget.backgroundColor || large != oldWidget.large;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -97,7 +96,7 @@ class _InheritedModelExampleState extends State<InheritedModelExample> {
|
||||
),
|
||||
);
|
||||
setState(() {
|
||||
if (color == Colors.blue){
|
||||
if (color == Colors.blue) {
|
||||
color = Colors.red;
|
||||
} else {
|
||||
color = Colors.blue;
|
||||
|
||||
@@ -2,24 +2,21 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [InheritedNotifier].
|
||||
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [InheritedNotifier].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const InheritedNotifierExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class InheritedNotifierExampleApp extends StatelessWidget {
|
||||
const InheritedNotifierExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
home: InheritedNotifierExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -32,10 +29,7 @@ class SpinModel extends InheritedNotifier<AnimationController> {
|
||||
});
|
||||
|
||||
static double of(BuildContext context) {
|
||||
return context
|
||||
.dependOnInheritedWidgetOfExactType<SpinModel>()!
|
||||
.notifier!
|
||||
.value;
|
||||
return context.dependOnInheritedWidgetOfExactType<SpinModel>()!.notifier!.value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,17 +52,16 @@ class Spinner extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class InheritedNotifierExample extends StatefulWidget {
|
||||
const InheritedNotifierExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<InheritedNotifierExample> createState() => _InheritedNotifierExampleState();
|
||||
}
|
||||
|
||||
/// [AnimationController]s can be created with `vsync: this` because of
|
||||
/// [TickerProviderStateMixin].
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget>
|
||||
with TickerProviderStateMixin {
|
||||
class _InheritedNotifierExampleState extends State<InheritedNotifierExample> with TickerProviderStateMixin {
|
||||
late AnimationController _controller;
|
||||
|
||||
@override
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [InheritedTheme].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [InheritedTheme].
|
||||
|
||||
void main() {
|
||||
runApp(const MyApp());
|
||||
runApp(const InheritedThemeExampleApp());
|
||||
}
|
||||
|
||||
class MyAppBody extends StatelessWidget {
|
||||
@@ -23,8 +23,7 @@ class MyAppBody extends StatelessWidget {
|
||||
// the new route pushed onto said navigator.
|
||||
// Themes are captured outside of the route's builder because when the
|
||||
// builder executes, the context may not be valid anymore.
|
||||
final CapturedThemes themes =
|
||||
InheritedTheme.capture(from: context, to: navigator.context);
|
||||
final CapturedThemes themes = InheritedTheme.capture(from: context, to: navigator.context);
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
@@ -48,8 +47,8 @@ class MyAppBody extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
class InheritedThemeExampleApp extends StatelessWidget {
|
||||
const InheritedThemeExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -2,31 +2,28 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [InteractiveViewer].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [InteractiveViewer].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const InteractiveViewerExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class InteractiveViewerExampleApp extends StatelessWidget {
|
||||
const InteractiveViewerExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
body: const MyStatelessWidget(),
|
||||
appBar: AppBar(title: const Text('InteractiveViewer Sample')),
|
||||
body: const InteractiveViewerExample(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatelessWidget extends StatelessWidget {
|
||||
const MyStatelessWidget({super.key});
|
||||
class InteractiveViewerExample extends StatelessWidget {
|
||||
const InteractiveViewerExample({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [InteractiveViewer.builder].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:vector_math/vector_math_64.dart' show Quad, Vector3;
|
||||
|
||||
/// Flutter code sample for [InteractiveViewer.builder].
|
||||
|
||||
void main() => runApp(const IVBuilderExampleApp());
|
||||
|
||||
class IVBuilderExampleApp extends StatelessWidget {
|
||||
@@ -80,9 +80,7 @@ class _IVBuilderExampleState extends State<_IVBuilderExample> {
|
||||
return Container(
|
||||
height: _cellHeight,
|
||||
width: _cellWidth,
|
||||
color: row % 2 + column % 2 == 1
|
||||
? Colors.white
|
||||
: Colors.grey.withOpacity(0.1),
|
||||
color: row % 2 + column % 2 == 1 ? Colors.white : Colors.grey.withOpacity(0.1),
|
||||
child: Align(
|
||||
child: Text('$row x $column'),
|
||||
),
|
||||
@@ -97,8 +95,7 @@ class _IVBuilderExampleState extends State<_IVBuilderExample> {
|
||||
}
|
||||
}
|
||||
|
||||
typedef _CellBuilder = Widget Function(
|
||||
BuildContext context, int row, int column);
|
||||
typedef _CellBuilder = Widget Function(BuildContext context, int row, int column);
|
||||
|
||||
class _TableBuilder extends StatelessWidget {
|
||||
const _TableBuilder({
|
||||
|
||||
@@ -2,31 +2,28 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [InteractiveViewer.constrained].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [InteractiveViewer.constrained].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const ConstrainedExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class ConstrainedExampleApp extends StatelessWidget {
|
||||
const ConstrainedExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
body: const MyStatelessWidget(),
|
||||
appBar: AppBar(title: const Text('Constrained Sample')),
|
||||
body: const ConstrainedExample(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatelessWidget extends StatelessWidget {
|
||||
const MyStatelessWidget({super.key});
|
||||
class ConstrainedExample extends StatelessWidget {
|
||||
const ConstrainedExample({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -39,8 +36,7 @@ class MyStatelessWidget 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)
|
||||
@@ -49,9 +45,7 @@ class MyStatelessWidget extends StatelessWidget {
|
||||
for (int column = 0; column < columnCount; column += 1)
|
||||
Container(
|
||||
height: 26,
|
||||
color: row % 2 + column % 2 == 1
|
||||
? Colors.white
|
||||
: Colors.grey.withOpacity(0.1),
|
||||
color: row % 2 + column % 2 == 1 ? Colors.white : Colors.grey.withOpacity(0.1),
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text('$row x $column'),
|
||||
|
||||
@@ -2,39 +2,35 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [InteractiveViewer.transformationController].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [InteractiveViewer.transformationController].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const TransformationControllerExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class TransformationControllerExampleApp extends StatelessWidget {
|
||||
const TransformationControllerExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
home: TransformationControllerExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class TransformationControllerExample extends StatefulWidget {
|
||||
const TransformationControllerExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<TransformationControllerExample> createState() => _TransformationControllerExampleState();
|
||||
}
|
||||
|
||||
/// [AnimationController]s can be created with `vsync: this` because of
|
||||
/// [TickerProviderStateMixin].
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget>
|
||||
class _TransformationControllerExampleState extends State<TransformationControllerExample>
|
||||
with TickerProviderStateMixin {
|
||||
final TransformationController _transformationController =
|
||||
TransformationController();
|
||||
final TransformationController _transformationController = TransformationController();
|
||||
Animation<Matrix4>? _animationReset;
|
||||
late final AnimationController _controllerReset;
|
||||
|
||||
|
||||
@@ -2,28 +2,25 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [LayoutBuilder].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [LayoutBuilder].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const LayoutBuilderExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class LayoutBuilderExampleApp extends StatelessWidget {
|
||||
const LayoutBuilderExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatelessWidget(),
|
||||
home: LayoutBuilderExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatelessWidget extends StatelessWidget {
|
||||
const MyStatelessWidget({super.key});
|
||||
class LayoutBuilderExample extends StatelessWidget {
|
||||
const LayoutBuilderExample({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
void main() => runApp(const MagnifierExampleApp());
|
||||
|
||||
class MyApp extends StatefulWidget {
|
||||
const MyApp({super.key});
|
||||
class MagnifierExampleApp extends StatefulWidget {
|
||||
const MagnifierExampleApp({super.key});
|
||||
static const Size loupeSize = Size(200, 200);
|
||||
|
||||
@override
|
||||
State<MyApp> createState() => _MyAppState();
|
||||
State<MagnifierExampleApp> createState() => _MagnifierExampleAppState();
|
||||
}
|
||||
|
||||
class _MyAppState extends State<MyApp> {
|
||||
class _MagnifierExampleAppState extends State<MagnifierExampleApp> {
|
||||
Offset dragGesturePosition = Offset.zero;
|
||||
|
||||
@override
|
||||
|
||||
@@ -2,43 +2,38 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [MediaQueryData.systemGestureInsets].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [MediaQueryData.systemGestureInsets].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const SystemGestureInsetsExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class SystemGestureInsetsExampleApp extends StatelessWidget {
|
||||
const SystemGestureInsetsExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
home: SystemGestureInsetsExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class SystemGestureInsetsExample extends StatefulWidget {
|
||||
const SystemGestureInsetsExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<SystemGestureInsetsExample> createState() => _SystemGestureInsetsExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _SystemGestureInsetsExampleState extends State<SystemGestureInsetsExample> {
|
||||
double _currentValue = 0.2;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final EdgeInsets systemGestureInsets =
|
||||
MediaQuery.of(context).systemGestureInsets;
|
||||
final EdgeInsets systemGestureInsets = MediaQuery.of(context).systemGestureInsets;
|
||||
return Scaffold(
|
||||
appBar:
|
||||
AppBar(title: const Text('Pad Slider to avoid systemGestureInsets')),
|
||||
appBar: AppBar(title: const Text('Pad Slider to avoid systemGestureInsets')),
|
||||
body: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
// only left and right padding are needed here
|
||||
|
||||
@@ -2,19 +2,18 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Navigator].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [Navigator].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const NavigatorExampleApp());
|
||||
|
||||
class NavigatorExampleApp extends StatelessWidget {
|
||||
const NavigatorExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Flutter Code Sample for Navigator',
|
||||
// MaterialApp contains our top-level Navigator
|
||||
initialRoute: '/',
|
||||
routes: <String, WidgetBuilder>{
|
||||
@@ -52,8 +51,7 @@ class CollectPersonalInfoPage extends StatelessWidget {
|
||||
onTap: () {
|
||||
// This moves from the personal info page to the credentials page,
|
||||
// replacing this page with that one.
|
||||
Navigator.of(context)
|
||||
.pushReplacementNamed('signup/choose_credentials');
|
||||
Navigator.of(context).pushReplacementNamed('signup/choose_credentials');
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.lightBlue,
|
||||
|
||||
@@ -2,38 +2,35 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Navigator.restorablePush].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [Navigator.restorablePush].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const RestorablePushExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class RestorablePushExampleApp extends StatelessWidget {
|
||||
const RestorablePushExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
home: RestorablePushExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class RestorablePushExample extends StatefulWidget {
|
||||
const RestorablePushExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<RestorablePushExample> createState() => _RestorablePushExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _RestorablePushExampleState extends State<RestorablePushExample> {
|
||||
@pragma('vm:entry-point')
|
||||
static Route<void> _myRouteBuilder(BuildContext context, Object? arguments) {
|
||||
return MaterialPageRoute<void>(
|
||||
builder: (BuildContext context) => const MyStatefulWidget(),
|
||||
builder: (BuildContext context) => const RestorablePushExample(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,38 +2,35 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Navigator.restorablePushAndRemoveUntil].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [Navigator.restorablePushAndRemoveUntil].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const RestorablePushAndRemoveUntilExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class RestorablePushAndRemoveUntilExampleApp extends StatelessWidget {
|
||||
const RestorablePushAndRemoveUntilExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
home: RestorablePushAndRemoveUntilExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class RestorablePushAndRemoveUntilExample extends StatefulWidget {
|
||||
const RestorablePushAndRemoveUntilExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<RestorablePushAndRemoveUntilExample> createState() => _RestorablePushAndRemoveUntilExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _RestorablePushAndRemoveUntilExampleState extends State<RestorablePushAndRemoveUntilExample> {
|
||||
@pragma('vm:entry-point')
|
||||
static Route<void> _myRouteBuilder(BuildContext context, Object? arguments) {
|
||||
return MaterialPageRoute<void>(
|
||||
builder: (BuildContext context) => const MyStatefulWidget(),
|
||||
builder: (BuildContext context) => const RestorablePushAndRemoveUntilExample(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,38 +2,35 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Navigator.restorablePushReplacement].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [Navigator.restorablePushReplacement].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const RestorablePushReplacementExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class RestorablePushReplacementExampleApp extends StatelessWidget {
|
||||
const RestorablePushReplacementExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
home: RestorablePushReplacementExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class RestorablePushReplacementExample extends StatefulWidget {
|
||||
const RestorablePushReplacementExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<RestorablePushReplacementExample> createState() => _RestorablePushReplacementExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _RestorablePushReplacementExampleState extends State<RestorablePushReplacementExample> {
|
||||
@pragma('vm:entry-point')
|
||||
static Route<void> _myRouteBuilder(BuildContext context, Object? arguments) {
|
||||
return MaterialPageRoute<void>(
|
||||
builder: (BuildContext context) => const MyStatefulWidget(),
|
||||
builder: (BuildContext context) => const RestorablePushReplacementExample(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,8 +41,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
title: const Text('Sample Code'),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () =>
|
||||
Navigator.restorablePushReplacement(context, _myRouteBuilder),
|
||||
onPressed: () => Navigator.restorablePushReplacement(context, _myRouteBuilder),
|
||||
tooltip: 'Increment Counter',
|
||||
child: const Icon(Icons.add),
|
||||
),
|
||||
|
||||
@@ -2,38 +2,35 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [NavigatorState.restorablePush].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [NavigatorState.restorablePush].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const RestorablePushExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class RestorablePushExampleApp extends StatelessWidget {
|
||||
const RestorablePushExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
home: RestorablePushExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class RestorablePushExample extends StatefulWidget {
|
||||
const RestorablePushExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<RestorablePushExample> createState() => _RestorablePushExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _RestorablePushExampleState extends State<RestorablePushExample> {
|
||||
@pragma('vm:entry-point')
|
||||
static Route<void> _myRouteBuilder(BuildContext context, Object? arguments) {
|
||||
return MaterialPageRoute<void>(
|
||||
builder: (BuildContext context) => const MyStatefulWidget(),
|
||||
builder: (BuildContext context) => const RestorablePushExample(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,38 +2,35 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [NavigatorState.restorablePushAndRemoveUntil].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [NavigatorState.restorablePushAndRemoveUntil].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const RestorablePushAndRemoveUntilExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class RestorablePushAndRemoveUntilExampleApp extends StatelessWidget {
|
||||
const RestorablePushAndRemoveUntilExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
home: RestorablePushAndRemoveUntilExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class RestorablePushAndRemoveUntilExample extends StatefulWidget {
|
||||
const RestorablePushAndRemoveUntilExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<RestorablePushAndRemoveUntilExample> createState() => _RestorablePushAndRemoveUntilExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _RestorablePushAndRemoveUntilExampleState extends State<RestorablePushAndRemoveUntilExample> {
|
||||
@pragma('vm:entry-point')
|
||||
static Route<void> _myRouteBuilder(BuildContext context, Object? arguments) {
|
||||
return MaterialPageRoute<void>(
|
||||
builder: (BuildContext context) => const MyStatefulWidget(),
|
||||
builder: (BuildContext context) => const RestorablePushAndRemoveUntilExample(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,38 +2,35 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [NavigatorState.restorablePushReplacement].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [NavigatorState.restorablePushReplacement].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const RestorablePushReplacementExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class RestorablePushReplacementExampleApp extends StatelessWidget {
|
||||
const RestorablePushReplacementExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
home: RestorablePushReplacementExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class RestorablePushReplacementExample extends StatefulWidget {
|
||||
const RestorablePushReplacementExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<RestorablePushReplacementExample> createState() => _RestorablePushReplacementExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _RestorablePushReplacementExampleState extends State<RestorablePushReplacementExample> {
|
||||
@pragma('vm:entry-point')
|
||||
static Route<void> _myRouteBuilder(BuildContext context, Object? arguments) {
|
||||
return MaterialPageRoute<void>(
|
||||
builder: (BuildContext context) => const MyStatefulWidget(),
|
||||
builder: (BuildContext context) => const RestorablePushReplacementExample(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [RestorableRouteFuture].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [RestorableRouteFuture].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const RestorableRouteFutureExampleApp());
|
||||
|
||||
class RestorableRouteFutureExampleApp extends StatelessWidget {
|
||||
const RestorableRouteFutureExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -40,8 +40,7 @@ class _MyHomeState extends State<MyHome> with RestorationMixin {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_counterRoute = RestorableRouteFuture<int>(
|
||||
onPresent: (NavigatorState navigator, Object? arguments) {
|
||||
_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(
|
||||
@@ -74,8 +73,7 @@ class _MyHomeState extends State<MyHome> with RestorationMixin {
|
||||
// A static `RestorableRouteBuilder` that can re-create the route during
|
||||
// state restoration.
|
||||
@pragma('vm:entry-point')
|
||||
static Route<int> _counterRouteBuilder(
|
||||
BuildContext context, Object? arguments) {
|
||||
static Route<int> _counterRouteBuilder(BuildContext context, Object? arguments) {
|
||||
return MaterialPageRoute<int>(
|
||||
builder: (BuildContext context) => MyCounter(
|
||||
title: arguments!.toString(),
|
||||
|
||||
@@ -2,28 +2,25 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [NestedScrollView].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [NestedScrollView].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const NestedScrollViewExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class NestedScrollViewExampleApp extends StatelessWidget {
|
||||
const NestedScrollViewExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatelessWidget(),
|
||||
home: NestedScrollViewExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatelessWidget extends StatelessWidget {
|
||||
const MyStatelessWidget({super.key});
|
||||
class NestedScrollViewExample extends StatelessWidget {
|
||||
const NestedScrollViewExample({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -43,11 +40,9 @@ class MyStatelessWidget extends StatelessWidget {
|
||||
// scroll view thinks it has not been scrolled.
|
||||
// This is not necessary if the "headerSliverBuilder" only builds
|
||||
// widgets that do not overlap the next sliver.
|
||||
handle:
|
||||
NestedScrollView.sliverOverlapAbsorberHandleFor(context),
|
||||
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
|
||||
sliver: SliverAppBar(
|
||||
title:
|
||||
const Text('Books'), // This is the title in the app bar.
|
||||
title: const Text('Books'), // This is the title in the app bar.
|
||||
pinned: true,
|
||||
expandedHeight: 150.0,
|
||||
// The "forceElevated" property causes the SliverAppBar to show
|
||||
@@ -93,9 +88,7 @@ class MyStatelessWidget extends StatelessWidget {
|
||||
SliverOverlapInjector(
|
||||
// This is the flip side of the SliverOverlapAbsorber
|
||||
// above.
|
||||
handle:
|
||||
NestedScrollView.sliverOverlapAbsorberHandleFor(
|
||||
context),
|
||||
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
|
||||
),
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
|
||||
@@ -2,28 +2,25 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [NestedScrollView].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [NestedScrollView].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const NestedScrollViewExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class NestedScrollViewExampleApp extends StatelessWidget {
|
||||
const NestedScrollViewExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatelessWidget(),
|
||||
home: NestedScrollViewExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatelessWidget extends StatelessWidget {
|
||||
const MyStatelessWidget({super.key});
|
||||
class NestedScrollViewExample extends StatelessWidget {
|
||||
const NestedScrollViewExample({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -32,8 +29,7 @@ class MyStatelessWidget extends StatelessWidget {
|
||||
// Setting floatHeaderSlivers to true is required in order to float
|
||||
// the outer slivers over the inner scrollable.
|
||||
floatHeaderSlivers: true,
|
||||
headerSliverBuilder:
|
||||
(BuildContext context, bool innerBoxIsScrolled) {
|
||||
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
|
||||
return <Widget>[
|
||||
SliverAppBar(
|
||||
title: const Text('Floating Nested SliverAppBar'),
|
||||
|
||||
@@ -2,34 +2,30 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [NestedScrollView].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [NestedScrollView].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const NestedScrollViewExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class NestedScrollViewExampleApp extends StatelessWidget {
|
||||
const NestedScrollViewExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatelessWidget(),
|
||||
home: NestedScrollViewExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatelessWidget extends StatelessWidget {
|
||||
const MyStatelessWidget({super.key});
|
||||
class NestedScrollViewExample extends StatelessWidget {
|
||||
const NestedScrollViewExample({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: NestedScrollView(headerSliverBuilder:
|
||||
(BuildContext context, bool innerBoxIsScrolled) {
|
||||
body: NestedScrollView(headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
|
||||
return <Widget>[
|
||||
SliverOverlapAbsorber(
|
||||
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
|
||||
@@ -49,13 +45,11 @@ class MyStatelessWidget extends StatelessWidget {
|
||||
// If the "controller" property is set, then this scroll view will not
|
||||
// be associated with the NestedScrollView.
|
||||
slivers: <Widget>[
|
||||
SliverOverlapInjector(
|
||||
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context)),
|
||||
SliverOverlapInjector(handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context)),
|
||||
SliverFixedExtentList(
|
||||
itemExtent: 48.0,
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) =>
|
||||
ListTile(title: Text('Item $index')),
|
||||
(BuildContext context, int index) => ListTile(title: Text('Item $index')),
|
||||
childCount: 30,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -2,30 +2,27 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [NestedScrollViewState].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [NestedScrollViewState].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const NestedScrollViewStateExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class NestedScrollViewStateExampleApp extends StatelessWidget {
|
||||
const NestedScrollViewStateExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatelessWidget(),
|
||||
home: NestedScrollViewStateExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
final GlobalKey<NestedScrollViewState> globalKey = GlobalKey();
|
||||
|
||||
class MyStatelessWidget extends StatelessWidget {
|
||||
const MyStatelessWidget({super.key});
|
||||
class NestedScrollViewStateExample extends StatelessWidget {
|
||||
const NestedScrollViewStateExample({super.key});
|
||||
|
||||
@override
|
||||
@override
|
||||
|
||||
@@ -2,28 +2,25 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Notification].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [Notification].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const NotificationExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class NotificationExampleApp extends StatelessWidget {
|
||||
const NotificationExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatelessWidget(),
|
||||
home: NotificationExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatelessWidget extends StatelessWidget {
|
||||
const MyStatelessWidget({super.key});
|
||||
class NotificationExample extends StatelessWidget {
|
||||
const NotificationExample({super.key});
|
||||
|
||||
static const List<String> _tabs = <String>['Months', 'Days'];
|
||||
static const List<String> _months = <String>[
|
||||
@@ -54,11 +51,10 @@ class MyStatelessWidget extends StatelessWidget {
|
||||
return true;
|
||||
},
|
||||
child: NestedScrollView(
|
||||
headerSliverBuilder:
|
||||
(BuildContext context, bool innerBoxIsScrolled) {
|
||||
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
|
||||
return <Widget>[
|
||||
SliverAppBar(
|
||||
title: const Text('Flutter Code Sample'),
|
||||
title: const Text('Notification Sample'),
|
||||
pinned: true,
|
||||
floating: true,
|
||||
bottom: TabBar(
|
||||
|
||||
@@ -2,33 +2,30 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [OverflowBar].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [OverflowBar].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const OverflowBarExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class OverflowBarExampleApp extends StatelessWidget {
|
||||
const OverflowBarExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
appBar: AppBar(title: const Text('OverflowBar Sample')),
|
||||
body: const Center(
|
||||
child: MyStatelessWidget(),
|
||||
child: OverflowBarExample(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatelessWidget extends StatelessWidget {
|
||||
const MyStatelessWidget({super.key});
|
||||
class OverflowBarExample extends StatelessWidget {
|
||||
const OverflowBarExample({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -39,8 +36,7 @@ class MyStatelessWidget extends StatelessWidget {
|
||||
child: Material(
|
||||
color: Colors.white,
|
||||
elevation: 24,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(4))),
|
||||
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4))),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: SingleChildScrollView(
|
||||
@@ -56,9 +52,7 @@ class MyStatelessWidget extends StatelessWidget {
|
||||
overflowAlignment: OverflowBarAlignment.end,
|
||||
children: <Widget>[
|
||||
TextButton(child: const Text('Cancel'), onPressed: () {}),
|
||||
TextButton(
|
||||
child: const Text('Really Really Cancel'),
|
||||
onPressed: () {}),
|
||||
TextButton(child: const Text('Really Really Cancel'), onPressed: () {}),
|
||||
OutlinedButton(child: const Text('OK'), onPressed: () {}),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Overlay].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [Overlay].
|
||||
|
||||
void main() => runApp(const OverlayApp());
|
||||
|
||||
class OverlayApp extends StatelessWidget {
|
||||
@@ -65,13 +65,13 @@ class _OverlayExampleState extends State<OverlayExample> {
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Explore page',
|
||||
style: TextStyle(
|
||||
color: Colors.red,
|
||||
),
|
||||
style: TextStyle(
|
||||
color: Colors.red,
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
Icons.arrow_downward,
|
||||
color: Colors.red
|
||||
color: Colors.red,
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -80,13 +80,13 @@ class _OverlayExampleState extends State<OverlayExample> {
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Commute page',
|
||||
style: TextStyle(
|
||||
color: Colors.green,
|
||||
),
|
||||
style: TextStyle(
|
||||
color: Colors.green,
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
Icons.arrow_downward,
|
||||
color: Colors.green
|
||||
color: Colors.green,
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -95,13 +95,13 @@ class _OverlayExampleState extends State<OverlayExample> {
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Saved page',
|
||||
style: TextStyle(
|
||||
color: Colors.orange,
|
||||
),
|
||||
style: TextStyle(
|
||||
color: Colors.orange,
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
Icons.arrow_downward,
|
||||
color: Colors.orange
|
||||
color: Colors.orange,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -2,19 +2,18 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for OverlayPortal
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [OverlayPortal].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const OverlayPortalExampleApp());
|
||||
|
||||
class OverlayPortalExampleApp extends StatelessWidget {
|
||||
const OverlayPortalExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Flutter Code Sample',
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text('OverlayPortal Example')),
|
||||
body: const Center(child: ClickableTooltipWidget()),
|
||||
|
||||
@@ -2,36 +2,32 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [GlowingOverscrollIndicator].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [GlowingOverscrollIndicator].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const GlowingOverscrollIndicatorExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class GlowingOverscrollIndicatorExampleApp extends StatelessWidget {
|
||||
const GlowingOverscrollIndicatorExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
body: const MyStatelessWidget(),
|
||||
appBar: AppBar(title: const Text('GlowingOverscrollIndicator Sample')),
|
||||
body: const GlowingOverscrollIndicatorExample(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatelessWidget extends StatelessWidget {
|
||||
const MyStatelessWidget({super.key});
|
||||
class GlowingOverscrollIndicatorExample extends StatelessWidget {
|
||||
const GlowingOverscrollIndicatorExample({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final double leadingPaintOffset =
|
||||
MediaQuery.of(context).padding.top + AppBar().preferredSize.height;
|
||||
final double leadingPaintOffset = MediaQuery.of(context).padding.top + AppBar().preferredSize.height;
|
||||
return NotificationListener<OverscrollIndicatorNotification>(
|
||||
onNotification: (OverscrollIndicatorNotification notification) {
|
||||
if (notification.leading) {
|
||||
|
||||
@@ -2,31 +2,28 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [GlowingOverscrollIndicator].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [GlowingOverscrollIndicator].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const GlowingOverscrollIndicatorExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class GlowingOverscrollIndicatorExampleApp extends StatelessWidget {
|
||||
const GlowingOverscrollIndicatorExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
body: const MyStatelessWidget(),
|
||||
appBar: AppBar(title: const Text('GlowingOverscrollIndicator Sample')),
|
||||
body: const GlowingOverscrollIndicatorExample(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatelessWidget extends StatelessWidget {
|
||||
const MyStatelessWidget({super.key});
|
||||
class GlowingOverscrollIndicatorExample extends StatelessWidget {
|
||||
const GlowingOverscrollIndicatorExample({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user