Migrate manual_tests to null safety (#82611)
This commit is contained in:
parent
aae6cc8e29
commit
a8e2606963
@ -23,9 +23,9 @@ void main() {
|
|||||||
/// the undo stack when they are invoked.
|
/// the undo stack when they are invoked.
|
||||||
class Memento extends Object with Diagnosticable {
|
class Memento extends Object with Diagnosticable {
|
||||||
const Memento({
|
const Memento({
|
||||||
@required this.name,
|
required this.name,
|
||||||
@required this.undo,
|
required this.undo,
|
||||||
@required this.redo,
|
required this.redo,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Returns true if this Memento can be used to undo.
|
/// Returns true if this Memento can be used to undo.
|
||||||
@ -110,11 +110,11 @@ class UndoableActionDispatcher extends ActionDispatcher implements Listenable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Object invokeAction(Action<Intent> action, Intent intent, [BuildContext context]) {
|
Object? invokeAction(Action<Intent> action, Intent intent, [BuildContext? context]) {
|
||||||
final Object result = super.invokeAction(action, intent, context);
|
final Object? result = super.invokeAction(action, intent, context);
|
||||||
print('Invoking ${action is UndoableAction ? 'undoable ' : ''}$intent as $action: $this ');
|
print('Invoking ${action is UndoableAction ? 'undoable ' : ''}$intent as $action: $this ');
|
||||||
if (action is UndoableAction) {
|
if (action is UndoableAction) {
|
||||||
_completedActions.addLast(result as Memento);
|
_completedActions.addLast(result! as Memento);
|
||||||
_undoneActions.clear();
|
_undoneActions.clear();
|
||||||
_pruneActions();
|
_pruneActions();
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
@ -193,14 +193,22 @@ class UndoIntent extends Intent {
|
|||||||
class UndoAction extends Action<UndoIntent> {
|
class UndoAction extends Action<UndoIntent> {
|
||||||
@override
|
@override
|
||||||
bool isEnabled(UndoIntent intent) {
|
bool isEnabled(UndoIntent intent) {
|
||||||
final UndoableActionDispatcher manager = Actions.of(primaryFocus?.context ?? FocusDemo.appKey.currentContext) as UndoableActionDispatcher;
|
final BuildContext? buildContext = primaryFocus?.context ?? FocusDemo.appKey.currentContext;
|
||||||
|
if (buildContext == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final UndoableActionDispatcher manager = Actions.of(buildContext) as UndoableActionDispatcher;
|
||||||
return manager.canUndo;
|
return manager.canUndo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void invoke(UndoIntent intent) {
|
void invoke(UndoIntent intent) {
|
||||||
final UndoableActionDispatcher manager = Actions.of(primaryFocus?.context ?? FocusDemo.appKey.currentContext) as UndoableActionDispatcher;
|
final BuildContext? buildContext = primaryFocus?.context ?? FocusDemo.appKey.currentContext;
|
||||||
manager?.undo();
|
if (buildContext == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final UndoableActionDispatcher manager = Actions.of(primaryFocus?.context ?? FocusDemo.appKey.currentContext!) as UndoableActionDispatcher;
|
||||||
|
manager.undo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,14 +219,22 @@ class RedoIntent extends Intent {
|
|||||||
class RedoAction extends Action<RedoIntent> {
|
class RedoAction extends Action<RedoIntent> {
|
||||||
@override
|
@override
|
||||||
bool isEnabled(RedoIntent intent) {
|
bool isEnabled(RedoIntent intent) {
|
||||||
final UndoableActionDispatcher manager = Actions.of(primaryFocus.context) as UndoableActionDispatcher;
|
final BuildContext? buildContext = primaryFocus?.context ?? FocusDemo.appKey.currentContext;
|
||||||
|
if (buildContext == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final UndoableActionDispatcher manager = Actions.of(buildContext) as UndoableActionDispatcher;
|
||||||
return manager.canRedo;
|
return manager.canRedo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
RedoAction invoke(RedoIntent intent) {
|
RedoAction invoke(RedoIntent intent) {
|
||||||
final UndoableActionDispatcher manager = Actions.of(primaryFocus.context) as UndoableActionDispatcher;
|
final BuildContext? buildContext = primaryFocus?.context ?? FocusDemo.appKey.currentContext;
|
||||||
manager?.redo();
|
if (buildContext == null) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
final UndoableActionDispatcher manager = Actions.of(buildContext) as UndoableActionDispatcher;
|
||||||
|
manager.redo();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -226,11 +242,11 @@ class RedoAction extends Action<RedoIntent> {
|
|||||||
/// An action that can be undone.
|
/// An action that can be undone.
|
||||||
abstract class UndoableAction<T extends Intent> extends Action<T> {
|
abstract class UndoableAction<T extends Intent> extends Action<T> {
|
||||||
/// The [Intent] this action was originally invoked with.
|
/// The [Intent] this action was originally invoked with.
|
||||||
Intent get invocationIntent => _invocationTag;
|
Intent? get invocationIntent => _invocationTag;
|
||||||
Intent _invocationTag;
|
Intent? _invocationTag;
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
set invocationIntent(Intent value) => _invocationTag = value;
|
set invocationIntent(Intent? value) => _invocationTag = value;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@mustCallSuper
|
@mustCallSuper
|
||||||
@ -244,8 +260,8 @@ class UndoableFocusActionBase<T extends Intent> extends UndoableAction<T> {
|
|||||||
@mustCallSuper
|
@mustCallSuper
|
||||||
Memento invoke(T intent) {
|
Memento invoke(T intent) {
|
||||||
super.invoke(intent);
|
super.invoke(intent);
|
||||||
final FocusNode previousFocus = primaryFocus;
|
final FocusNode? previousFocus = primaryFocus;
|
||||||
return Memento(name: previousFocus.debugLabel, undo: () {
|
return Memento(name: previousFocus!.debugLabel!, undo: () {
|
||||||
previousFocus.requestFocus();
|
previousFocus.requestFocus();
|
||||||
}, redo: () {
|
}, redo: () {
|
||||||
return invoke(intent);
|
return invoke(intent);
|
||||||
@ -267,7 +283,7 @@ class UndoableNextFocusAction extends UndoableFocusActionBase<NextFocusIntent> {
|
|||||||
@override
|
@override
|
||||||
Memento invoke(NextFocusIntent intent) {
|
Memento invoke(NextFocusIntent intent) {
|
||||||
final Memento memento = super.invoke(intent);
|
final Memento memento = super.invoke(intent);
|
||||||
primaryFocus.nextFocus();
|
primaryFocus?.nextFocus();
|
||||||
return memento;
|
return memento;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -276,25 +292,25 @@ class UndoablePreviousFocusAction extends UndoableFocusActionBase<PreviousFocusI
|
|||||||
@override
|
@override
|
||||||
Memento invoke(PreviousFocusIntent intent) {
|
Memento invoke(PreviousFocusIntent intent) {
|
||||||
final Memento memento = super.invoke(intent);
|
final Memento memento = super.invoke(intent);
|
||||||
primaryFocus.previousFocus();
|
primaryFocus?.previousFocus();
|
||||||
return memento;
|
return memento;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UndoableDirectionalFocusAction extends UndoableFocusActionBase<DirectionalFocusIntent> {
|
class UndoableDirectionalFocusAction extends UndoableFocusActionBase<DirectionalFocusIntent> {
|
||||||
TraversalDirection direction;
|
TraversalDirection? direction;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Memento invoke(DirectionalFocusIntent intent) {
|
Memento invoke(DirectionalFocusIntent intent) {
|
||||||
final Memento memento = super.invoke(intent);
|
final Memento memento = super.invoke(intent);
|
||||||
primaryFocus.focusInDirection(intent.direction);
|
primaryFocus?.focusInDirection(intent.direction);
|
||||||
return memento;
|
return memento;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A button class that takes focus when clicked.
|
/// A button class that takes focus when clicked.
|
||||||
class DemoButton extends StatefulWidget {
|
class DemoButton extends StatefulWidget {
|
||||||
const DemoButton({Key key, this.name}) : super(key: key);
|
const DemoButton({Key? key, required this.name}) : super(key: key);
|
||||||
|
|
||||||
final String name;
|
final String name;
|
||||||
|
|
||||||
@ -303,19 +319,13 @@ class DemoButton extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _DemoButtonState extends State<DemoButton> {
|
class _DemoButtonState extends State<DemoButton> {
|
||||||
FocusNode _focusNode;
|
late final FocusNode _focusNode = FocusNode(debugLabel: widget.name);
|
||||||
final GlobalKey _nameKey = GlobalKey();
|
final GlobalKey _nameKey = GlobalKey();
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_focusNode = FocusNode(debugLabel: widget.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _handleOnPressed() {
|
void _handleOnPressed() {
|
||||||
print('Button ${widget.name} pressed.');
|
print('Button ${widget.name} pressed.');
|
||||||
setState(() {
|
setState(() {
|
||||||
Actions.invoke(_nameKey.currentContext, RequestFocusIntent(_focusNode));
|
Actions.invoke(_nameKey.currentContext!, RequestFocusIntent(_focusNode));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,7 +346,7 @@ class _DemoButtonState extends State<DemoButton> {
|
|||||||
return Colors.red;
|
return Colors.red;
|
||||||
if (states.contains(MaterialState.hovered))
|
if (states.contains(MaterialState.hovered))
|
||||||
return Colors.blue;
|
return Colors.blue;
|
||||||
return null;
|
return Colors.transparent;
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
onPressed: () => _handleOnPressed(),
|
onPressed: () => _handleOnPressed(),
|
||||||
@ -346,7 +356,7 @@ class _DemoButtonState extends State<DemoButton> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class FocusDemo extends StatefulWidget {
|
class FocusDemo extends StatefulWidget {
|
||||||
const FocusDemo({Key key}) : super(key: key);
|
const FocusDemo({Key? key}) : super(key: key);
|
||||||
|
|
||||||
static GlobalKey appKey = GlobalKey();
|
static GlobalKey appKey = GlobalKey();
|
||||||
|
|
||||||
@ -355,16 +365,14 @@ class FocusDemo extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _FocusDemoState extends State<FocusDemo> {
|
class _FocusDemoState extends State<FocusDemo> {
|
||||||
FocusNode outlineFocus;
|
final FocusNode outlineFocus = FocusNode(debugLabel: 'Demo Focus Node');
|
||||||
UndoableActionDispatcher dispatcher;
|
late final UndoableActionDispatcher dispatcher = UndoableActionDispatcher();
|
||||||
bool canUndo;
|
bool canUndo = false;
|
||||||
bool canRedo;
|
bool canRedo = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
outlineFocus = FocusNode(debugLabel: 'Demo Focus Node');
|
|
||||||
dispatcher = UndoableActionDispatcher();
|
|
||||||
canUndo = dispatcher.canUndo;
|
canUndo = dispatcher.canUndo;
|
||||||
canRedo = dispatcher.canRedo;
|
canRedo = dispatcher.canRedo;
|
||||||
dispatcher.addListener(_handleUndoStateChange);
|
dispatcher.addListener(_handleUndoStateChange);
|
||||||
@ -415,7 +423,7 @@ class _FocusDemoState extends State<FocusDemo> {
|
|||||||
debugLabel: 'Scope',
|
debugLabel: 'Scope',
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
child: DefaultTextStyle(
|
child: DefaultTextStyle(
|
||||||
style: textTheme.headline4,
|
style: textTheme.headline4!,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text('Actions Demo'),
|
title: const Text('Actions Demo'),
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class AnimatedIconsTestApp extends StatelessWidget {
|
class AnimatedIconsTestApp extends StatelessWidget {
|
||||||
const AnimatedIconsTestApp({Key key}) : super(key: key);
|
const AnimatedIconsTestApp({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -19,7 +19,7 @@ class AnimatedIconsTestApp extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class IconsList extends StatelessWidget {
|
class IconsList extends StatelessWidget {
|
||||||
const IconsList({Key key}) : super(key: key);
|
const IconsList({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -30,7 +30,7 @@ class IconsList extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class IconSampleRow extends StatefulWidget {
|
class IconSampleRow extends StatefulWidget {
|
||||||
const IconSampleRow(this.sample, {Key key}) : super(key: key);
|
const IconSampleRow(this.sample, {Key? key}) : super(key: key);
|
||||||
|
|
||||||
final IconSample sample;
|
final IconSample sample;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ class IconSampleRow extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class IconSampleRowState extends State<IconSampleRow> with SingleTickerProviderStateMixin {
|
class IconSampleRowState extends State<IconSampleRow> with SingleTickerProviderStateMixin {
|
||||||
AnimationController progress;
|
late final AnimationController progress = AnimationController(vsync: this, duration: const Duration(milliseconds: 300));
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -63,7 +63,6 @@ class IconSampleRowState extends State<IconSampleRow> with SingleTickerProviderS
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
progress = AnimationController(vsync: this, duration: const Duration(milliseconds: 300));
|
|
||||||
progress.addListener(_handleChange);
|
progress.addListener(_handleChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,18 +7,18 @@ import 'dart:math';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class CardModel {
|
class CardModel {
|
||||||
CardModel(this.value, this.height) {
|
CardModel(this.value, this.height) :
|
||||||
textController = TextEditingController(text: 'Item $value');
|
textController = TextEditingController(text: 'Item $value');
|
||||||
}
|
|
||||||
int value;
|
int value;
|
||||||
double height;
|
double height;
|
||||||
int get color => ((value % 9) + 1) * 100;
|
int get color => ((value % 9) + 1) * 100;
|
||||||
TextEditingController textController;
|
final TextEditingController textController;
|
||||||
Key get key => ObjectKey(this);
|
Key get key => ObjectKey(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
class CardCollection extends StatefulWidget {
|
class CardCollection extends StatefulWidget {
|
||||||
const CardCollection({Key key}) : super(key: key);
|
const CardCollection({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
CardCollectionState createState() => CardCollectionState();
|
CardCollectionState createState() => CardCollectionState();
|
||||||
@ -41,7 +41,7 @@ class CardCollectionState extends State<CardCollection> {
|
|||||||
];
|
];
|
||||||
|
|
||||||
MaterialColor _primaryColor = Colors.deepPurple;
|
MaterialColor _primaryColor = Colors.deepPurple;
|
||||||
List<CardModel> _cardModels;
|
List<CardModel> _cardModels = <CardModel>[];
|
||||||
DismissDirection _dismissDirection = DismissDirection.horizontal;
|
DismissDirection _dismissDirection = DismissDirection.horizontal;
|
||||||
TextAlign _textAlign = TextAlign.center;
|
TextAlign _textAlign = TextAlign.center;
|
||||||
bool _editable = false;
|
bool _editable = false;
|
||||||
@ -164,21 +164,21 @@ class CardCollectionState extends State<CardCollection> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _selectColor(MaterialColor selection) {
|
void _selectColor(MaterialColor? selection) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_primaryColor = selection;
|
_primaryColor = selection!;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _changeDismissDirection(DismissDirection newDismissDirection) {
|
void _changeDismissDirection(DismissDirection? newDismissDirection) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_dismissDirection = newDismissDirection;
|
_dismissDirection = newDismissDirection!;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _changeTextAlign(TextAlign newTextAlign) {
|
void _changeTextAlign(TextAlign? newTextAlign) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_textAlign = newTextAlign;
|
_textAlign = newTextAlign!;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ class CardCollectionState extends State<CardCollection> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildDrawerColorRadioItem(String label, MaterialColor itemValue, MaterialColor currentValue, ValueChanged<MaterialColor> onChanged, { IconData icon, bool enabled = true }) {
|
Widget buildDrawerColorRadioItem(String label, MaterialColor itemValue, MaterialColor currentValue, ValueChanged<MaterialColor?> onChanged, { IconData? icon, bool enabled = true }) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: Icon(icon),
|
leading: Icon(icon),
|
||||||
title: Text(label),
|
title: Text(label),
|
||||||
@ -206,7 +206,7 @@ class CardCollectionState extends State<CardCollection> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildDrawerDirectionRadioItem(String label, DismissDirection itemValue, DismissDirection currentValue, ValueChanged<DismissDirection> onChanged, { IconData icon, bool enabled = true }) {
|
Widget buildDrawerDirectionRadioItem(String label, DismissDirection itemValue, DismissDirection currentValue, ValueChanged<DismissDirection?> onChanged, { IconData? icon, bool enabled = true }) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: Icon(icon),
|
leading: Icon(icon),
|
||||||
title: Text(label),
|
title: Text(label),
|
||||||
@ -219,7 +219,7 @@ class CardCollectionState extends State<CardCollection> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildFontRadioItem(String label, TextAlign itemValue, TextAlign currentValue, ValueChanged<TextAlign> onChanged, { IconData icon, bool enabled = true }) {
|
Widget buildFontRadioItem(String label, TextAlign itemValue, TextAlign currentValue, ValueChanged<TextAlign?> onChanged, { IconData? icon, bool enabled = true }) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: Icon(icon),
|
leading: Icon(icon),
|
||||||
title: Text(label),
|
title: Text(label),
|
||||||
@ -306,7 +306,7 @@ class CardCollectionState extends State<CardCollection> {
|
|||||||
rightArrowIcon = Opacity(opacity: 0.1, child: rightArrowIcon);
|
rightArrowIcon = Opacity(opacity: 0.1, child: rightArrowIcon);
|
||||||
|
|
||||||
final ThemeData theme = Theme.of(context);
|
final ThemeData theme = Theme.of(context);
|
||||||
final TextStyle backgroundTextStyle = theme.primaryTextTheme.headline6;
|
final TextStyle? backgroundTextStyle = theme.primaryTextTheme.headline6;
|
||||||
|
|
||||||
// The background Widget appears behind the Dismissible card when the card
|
// The background Widget appears behind the Dismissible card when the card
|
||||||
// moves to the left or right. The Positioned widget ensures that the
|
// moves to the left or right. The Positioned widget ensures that the
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class ColorTestingDemo extends StatelessWidget {
|
class ColorTestingDemo extends StatelessWidget {
|
||||||
const ColorTestingDemo({ Key key }) : super(key: key);
|
const ColorTestingDemo({ Key? key }) : super(key: key);
|
||||||
|
|
||||||
static const String routeName = '/color_demo';
|
static const String routeName = '/color_demo';
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ class ColorTestingDemo extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ColorDemoHome extends StatelessWidget {
|
class ColorDemoHome extends StatelessWidget {
|
||||||
const ColorDemoHome({Key key}) : super(key: key);
|
const ColorDemoHome({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -52,7 +52,7 @@ class ColorDemoHome extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class GradientRow extends StatelessWidget {
|
class GradientRow extends StatelessWidget {
|
||||||
const GradientRow({ Key key, this.rightColor, this.leftColor }) : super(key: key);
|
const GradientRow({ Key? key, required this.rightColor, required this.leftColor }) : super(key: key);
|
||||||
|
|
||||||
final Color leftColor;
|
final Color leftColor;
|
||||||
final Color rightColor;
|
final Color rightColor;
|
||||||
@ -73,7 +73,7 @@ class GradientRow extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ColorRow extends StatelessWidget {
|
class ColorRow extends StatelessWidget {
|
||||||
const ColorRow({ Key key, this.color }) : super(key: key);
|
const ColorRow({ Key? key, required this.color }) : super(key: key);
|
||||||
|
|
||||||
final Color color;
|
final Color color;
|
||||||
|
|
||||||
|
@ -17,12 +17,12 @@ final Map<int, Color> m2SwatchColors = <int, Color>{
|
|||||||
800: const Color(0xff270096),
|
800: const Color(0xff270096),
|
||||||
900: const Color(0xff270096),
|
900: const Color(0xff270096),
|
||||||
};
|
};
|
||||||
final MaterialColor m2Swatch = MaterialColor(m2SwatchColors[500].value, m2SwatchColors);
|
final MaterialColor m2Swatch = MaterialColor(m2SwatchColors[500]!.value, m2SwatchColors);
|
||||||
|
|
||||||
void main() => runApp(const MyApp());
|
void main() => runApp(const MyApp());
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
const MyApp({Key key}) : super(key: key);
|
const MyApp({Key? key}) : super(key: key);
|
||||||
|
|
||||||
static const String _title = 'Density Test';
|
static const String _title = 'Density Test';
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ class MyApp extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MyHomePage extends StatefulWidget {
|
class MyHomePage extends StatefulWidget {
|
||||||
const MyHomePage({Key key, this.title}) : super(key: key);
|
const MyHomePage({Key? key, required this.title}) : super(key: key);
|
||||||
|
|
||||||
final String title;
|
final String title;
|
||||||
|
|
||||||
@ -112,11 +112,11 @@ class OptionModel extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class LabeledCheckbox extends StatelessWidget {
|
class LabeledCheckbox extends StatelessWidget {
|
||||||
const LabeledCheckbox({Key key, this.label, this.onChanged, this.value}) : super(key: key);
|
const LabeledCheckbox({Key? key, required this.label, this.onChanged, this.value}) : super(key: key);
|
||||||
|
|
||||||
final String label;
|
final String label;
|
||||||
final ValueChanged<bool> onChanged;
|
final ValueChanged<bool?>? onChanged;
|
||||||
final bool value;
|
final bool? value;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -134,7 +134,7 @@ class LabeledCheckbox extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Options extends StatefulWidget {
|
class Options extends StatefulWidget {
|
||||||
const Options(this.model, {Key key}) : super(key: key);
|
const Options(this.model, {Key? key}) : super(key: key);
|
||||||
|
|
||||||
final OptionModel model;
|
final OptionModel model;
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ class _OptionsState extends State<Options> {
|
|||||||
return 'custom';
|
return 'custom';
|
||||||
}
|
}
|
||||||
|
|
||||||
VisualDensity _profileToDensity(String profile) {
|
VisualDensity _profileToDensity(String? profile) {
|
||||||
switch (profile) {
|
switch (profile) {
|
||||||
case 'standard':
|
case 'standard':
|
||||||
return VisualDensity.standard;
|
return VisualDensity.standard;
|
||||||
@ -304,7 +304,7 @@ class _OptionsState extends State<Options> {
|
|||||||
child: DropdownButton<String>(
|
child: DropdownButton<String>(
|
||||||
style: TextStyle(color: Colors.grey[50]),
|
style: TextStyle(color: Colors.grey[50]),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
onChanged: (String value) {
|
onChanged: (String? value) {
|
||||||
widget.model.density = _profileToDensity(value);
|
widget.model.density = _profileToDensity(value);
|
||||||
},
|
},
|
||||||
items: const <DropdownMenuItem<String>>[
|
items: const <DropdownMenuItem<String>>[
|
||||||
@ -321,15 +321,15 @@ class _OptionsState extends State<Options> {
|
|||||||
),
|
),
|
||||||
LabeledCheckbox(
|
LabeledCheckbox(
|
||||||
label: 'Enabled',
|
label: 'Enabled',
|
||||||
onChanged: (bool checked) {
|
onChanged: (bool? checked) {
|
||||||
widget.model.enable = checked;
|
widget.model.enable = checked == true;
|
||||||
},
|
},
|
||||||
value: widget.model.enable,
|
value: widget.model.enable,
|
||||||
),
|
),
|
||||||
LabeledCheckbox(
|
LabeledCheckbox(
|
||||||
label: 'Slow',
|
label: 'Slow',
|
||||||
onChanged: (bool checked) {
|
onChanged: (bool? checked) {
|
||||||
widget.model.slowAnimations = checked;
|
widget.model.slowAnimations = checked == true;
|
||||||
Future<void>.delayed(const Duration(milliseconds: 150)).then((_) {
|
Future<void>.delayed(const Duration(milliseconds: 150)).then((_) {
|
||||||
if (widget.model.slowAnimations) {
|
if (widget.model.slowAnimations) {
|
||||||
timeDilation = 20.0;
|
timeDilation = 20.0;
|
||||||
@ -342,8 +342,8 @@ class _OptionsState extends State<Options> {
|
|||||||
),
|
),
|
||||||
LabeledCheckbox(
|
LabeledCheckbox(
|
||||||
label: 'RTL',
|
label: 'RTL',
|
||||||
onChanged: (bool checked) {
|
onChanged: (bool? checked) {
|
||||||
widget.model.rtl = checked;
|
widget.model.rtl = checked == true;
|
||||||
},
|
},
|
||||||
value: widget.model.rtl,
|
value: widget.model.rtl,
|
||||||
),
|
),
|
||||||
@ -365,7 +365,7 @@ class _OptionsState extends State<Options> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ControlTile extends StatelessWidget {
|
class _ControlTile extends StatelessWidget {
|
||||||
const _ControlTile({Key key, @required this.label, @required this.child})
|
const _ControlTile({Key? key, required this.label, required this.child})
|
||||||
: assert(label != null),
|
: assert(label != null),
|
||||||
assert(child != null),
|
assert(child != null),
|
||||||
super(key: key);
|
super(key: key);
|
||||||
@ -398,13 +398,12 @@ class _ControlTile extends StatelessWidget {
|
|||||||
class _MyHomePageState extends State<MyHomePage> {
|
class _MyHomePageState extends State<MyHomePage> {
|
||||||
static final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
static final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
final OptionModel _model = OptionModel();
|
final OptionModel _model = OptionModel();
|
||||||
TextEditingController textController;
|
final TextEditingController textController = TextEditingController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_model.addListener(_modelChanged);
|
_model.addListener(_modelChanged);
|
||||||
textController = TextEditingController();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -565,9 +564,9 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
children: List<Widget>.generate(checkboxValues.length, (int index) {
|
children: List<Widget>.generate(checkboxValues.length, (int index) {
|
||||||
return Checkbox(
|
return Checkbox(
|
||||||
onChanged: _model.enable
|
onChanged: _model.enable
|
||||||
? (bool value) {
|
? (bool? value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
checkboxValues[index] = value;
|
checkboxValues[index] = value == true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
@ -583,9 +582,9 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
children: List<Widget>.generate(4, (int index) {
|
children: List<Widget>.generate(4, (int index) {
|
||||||
return Radio<int>(
|
return Radio<int>(
|
||||||
onChanged: _model.enable
|
onChanged: _model.enable
|
||||||
? (int value) {
|
? (int? value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
radioValue = value;
|
radioValue = value!;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
|
@ -7,7 +7,7 @@ import 'dart:math' as math;
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class ExampleDragTarget extends StatefulWidget {
|
class ExampleDragTarget extends StatefulWidget {
|
||||||
const ExampleDragTarget({Key key}) : super(key: key);
|
const ExampleDragTarget({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ExampleDragTargetState createState() => ExampleDragTargetState();
|
ExampleDragTargetState createState() => ExampleDragTargetState();
|
||||||
@ -26,7 +26,7 @@ class ExampleDragTargetState extends State<ExampleDragTarget> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return DragTarget<Color>(
|
return DragTarget<Color>(
|
||||||
onAccept: _handleAccept,
|
onAccept: _handleAccept,
|
||||||
builder: (BuildContext context, List<Color> data, List<dynamic> rejectedData) {
|
builder: (BuildContext context, List<Color?> data, List<dynamic> rejectedData) {
|
||||||
return Container(
|
return Container(
|
||||||
height: 100.0,
|
height: 100.0,
|
||||||
margin: const EdgeInsets.all(10.0),
|
margin: const EdgeInsets.all(10.0),
|
||||||
@ -44,11 +44,11 @@ class ExampleDragTargetState extends State<ExampleDragTarget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Dot extends StatefulWidget {
|
class Dot extends StatefulWidget {
|
||||||
const Dot({ Key key, this.color, this.size, this.child, this.tappable = false }) : super(key: key);
|
const Dot({ Key? key, this.color, this.size, this.child, this.tappable = false }) : super(key: key);
|
||||||
|
|
||||||
final Color color;
|
final Color? color;
|
||||||
final double size;
|
final double? size;
|
||||||
final Widget child;
|
final Widget? child;
|
||||||
final bool tappable;
|
final bool tappable;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -77,17 +77,17 @@ class DotState extends State<Dot> {
|
|||||||
|
|
||||||
class ExampleDragSource extends StatelessWidget {
|
class ExampleDragSource extends StatelessWidget {
|
||||||
const ExampleDragSource({
|
const ExampleDragSource({
|
||||||
Key key,
|
Key? key,
|
||||||
this.color,
|
this.color,
|
||||||
this.heavy = false,
|
this.heavy = false,
|
||||||
this.under = true,
|
this.under = true,
|
||||||
this.child,
|
this.child,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final Color color;
|
final Color? color;
|
||||||
final bool heavy;
|
final bool heavy;
|
||||||
final bool under;
|
final bool under;
|
||||||
final Widget child;
|
final Widget? child;
|
||||||
|
|
||||||
static const double kDotSize = 50.0;
|
static const double kDotSize = 50.0;
|
||||||
static const double kHeavyMultiplier = 1.5;
|
static const double kHeavyMultiplier = 1.5;
|
||||||
@ -100,7 +100,7 @@ class ExampleDragSource extends StatelessWidget {
|
|||||||
size *= kHeavyMultiplier;
|
size *= kHeavyMultiplier;
|
||||||
|
|
||||||
final Widget contents = DefaultTextStyle(
|
final Widget contents = DefaultTextStyle(
|
||||||
style: Theme.of(context).textTheme.bodyText2,
|
style: Theme.of(context).textTheme.bodyText2!,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
child: Dot(
|
child: Dot(
|
||||||
color: color,
|
color: color,
|
||||||
@ -176,7 +176,7 @@ class DashOutlineCirclePainter extends CustomPainter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MovableBall extends StatelessWidget {
|
class MovableBall extends StatelessWidget {
|
||||||
const MovableBall(this.position, this.ballPosition, this.callback, {Key key}) : super(key: key);
|
const MovableBall(this.position, this.ballPosition, this.callback, {Key? key}) : super(key: key);
|
||||||
|
|
||||||
final int position;
|
final int position;
|
||||||
final int ballPosition;
|
final int ballPosition;
|
||||||
@ -188,7 +188,7 @@ class MovableBall extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final Widget ball = DefaultTextStyle(
|
final Widget ball = DefaultTextStyle(
|
||||||
style: Theme.of(context).primaryTextTheme.bodyText2,
|
style: Theme.of(context).primaryTextTheme.bodyText2!,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
child: Dot(
|
child: Dot(
|
||||||
key: kBallKey,
|
key: kBallKey,
|
||||||
@ -216,7 +216,7 @@ class MovableBall extends StatelessWidget {
|
|||||||
} else {
|
} else {
|
||||||
return DragTarget<bool>(
|
return DragTarget<bool>(
|
||||||
onAccept: (bool data) { callback(position); },
|
onAccept: (bool data) { callback(position); },
|
||||||
builder: (BuildContext context, List<bool> accepted, List<dynamic> rejected) {
|
builder: (BuildContext context, List<bool?> accepted, List<dynamic> rejected) {
|
||||||
return dashedBall;
|
return dashedBall;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -225,7 +225,7 @@ class MovableBall extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class DragAndDropApp extends StatefulWidget {
|
class DragAndDropApp extends StatefulWidget {
|
||||||
const DragAndDropApp({Key key}) : super(key: key);
|
const DragAndDropApp({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
DragAndDropAppState createState() => DragAndDropAppState();
|
DragAndDropAppState createState() => DragAndDropAppState();
|
||||||
|
@ -13,7 +13,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class DemoButton extends StatefulWidget {
|
class DemoButton extends StatefulWidget {
|
||||||
const DemoButton({Key key, this.name, this.canRequestFocus = true, this.autofocus = false}) : super(key: key);
|
const DemoButton({Key? key, required this.name, this.canRequestFocus = true, this.autofocus = false}) : super(key: key);
|
||||||
|
|
||||||
final String name;
|
final String name;
|
||||||
final bool canRequestFocus;
|
final bool canRequestFocus;
|
||||||
@ -24,20 +24,14 @@ class DemoButton extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _DemoButtonState extends State<DemoButton> {
|
class _DemoButtonState extends State<DemoButton> {
|
||||||
FocusNode focusNode;
|
late final FocusNode focusNode = FocusNode(
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
focusNode = FocusNode(
|
|
||||||
debugLabel: widget.name,
|
debugLabel: widget.name,
|
||||||
canRequestFocus: widget.canRequestFocus,
|
canRequestFocus: widget.canRequestFocus,
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
focusNode?.dispose();
|
focusNode.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +58,7 @@ class _DemoButtonState extends State<DemoButton> {
|
|||||||
return Colors.red.withOpacity(0.25);
|
return Colors.red.withOpacity(0.25);
|
||||||
if (states.contains(MaterialState.hovered))
|
if (states.contains(MaterialState.hovered))
|
||||||
return Colors.blue.withOpacity(0.25);
|
return Colors.blue.withOpacity(0.25);
|
||||||
return null;
|
return Colors.transparent;
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
onPressed: () => _handleOnPressed(),
|
onPressed: () => _handleOnPressed(),
|
||||||
@ -74,14 +68,14 @@ class _DemoButtonState extends State<DemoButton> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class FocusDemo extends StatefulWidget {
|
class FocusDemo extends StatefulWidget {
|
||||||
const FocusDemo({Key key}) : super(key: key);
|
const FocusDemo({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<FocusDemo> createState() => _FocusDemoState();
|
State<FocusDemo> createState() => _FocusDemoState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _FocusDemoState extends State<FocusDemo> {
|
class _FocusDemoState extends State<FocusDemo> {
|
||||||
FocusNode outlineFocus;
|
FocusNode? outlineFocus;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -91,7 +85,7 @@ class _FocusDemoState extends State<FocusDemo> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
outlineFocus.dispose();
|
outlineFocus?.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +136,7 @@ class _FocusDemoState extends State<FocusDemo> {
|
|||||||
onKey: _handleKeyPress,
|
onKey: _handleKeyPress,
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
child: DefaultTextStyle(
|
child: DefaultTextStyle(
|
||||||
style: textTheme.headline4,
|
style: textTheme.headline4!,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text('Focus Demo'),
|
title: const Text('Focus Demo'),
|
||||||
|
@ -12,7 +12,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class DemoButton extends StatelessWidget {
|
class DemoButton extends StatelessWidget {
|
||||||
const DemoButton({Key key, this.name}) : super(key: key);
|
const DemoButton({Key? key, required this.name}) : super(key: key);
|
||||||
|
|
||||||
final String name;
|
final String name;
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ class DemoButton extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class HoverDemo extends StatefulWidget {
|
class HoverDemo extends StatefulWidget {
|
||||||
const HoverDemo({Key key}) : super(key: key);
|
const HoverDemo({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<HoverDemo> createState() => _HoverDemoState();
|
State<HoverDemo> createState() => _HoverDemoState();
|
||||||
@ -42,12 +42,12 @@ class _HoverDemoState extends State<HoverDemo> {
|
|||||||
final TextTheme textTheme = Theme.of(context).textTheme;
|
final TextTheme textTheme = Theme.of(context).textTheme;
|
||||||
final ButtonStyle overrideFocusColor = ButtonStyle(
|
final ButtonStyle overrideFocusColor = ButtonStyle(
|
||||||
overlayColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) {
|
overlayColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) {
|
||||||
return states.contains(MaterialState.focused) ? Colors.deepOrangeAccent : null;
|
return states.contains(MaterialState.focused) ? Colors.deepOrangeAccent : Colors.transparent;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
return DefaultTextStyle(
|
return DefaultTextStyle(
|
||||||
style: textTheme.headline4,
|
style: textTheme.headline4!,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text('Hover Demo'),
|
title: const Text('Hover Demo'),
|
||||||
|
@ -45,12 +45,12 @@ class _IgnoreDrag extends Drag {
|
|||||||
|
|
||||||
class _PointDemoPainter extends CustomPainter {
|
class _PointDemoPainter extends CustomPainter {
|
||||||
_PointDemoPainter({
|
_PointDemoPainter({
|
||||||
Animation<double> repaint,
|
Animation<double>? repaint,
|
||||||
this.arc,
|
required this.arc,
|
||||||
}) : _repaint = repaint, super(repaint: repaint);
|
}) : _repaint = repaint, super(repaint: repaint);
|
||||||
|
|
||||||
final MaterialPointArcTween arc;
|
final MaterialPointArcTween arc;
|
||||||
final Animation<double> _repaint;
|
final Animation<double>? _repaint;
|
||||||
|
|
||||||
void drawPoint(Canvas canvas, Offset point, Color color) {
|
void drawPoint(Canvas canvas, Offset point, Color color) {
|
||||||
final Paint paint = Paint()
|
final Paint paint = Paint()
|
||||||
@ -69,7 +69,7 @@ class _PointDemoPainter extends CustomPainter {
|
|||||||
final Paint paint = Paint();
|
final Paint paint = Paint();
|
||||||
|
|
||||||
if (arc.center != null)
|
if (arc.center != null)
|
||||||
drawPoint(canvas, arc.center, Colors.grey.shade400);
|
drawPoint(canvas, arc.center!, Colors.grey.shade400);
|
||||||
|
|
||||||
paint
|
paint
|
||||||
..isAntiAlias = false // Work-around for github.com/flutter/flutter/issues/5720
|
..isAntiAlias = false // Work-around for github.com/flutter/flutter/issues/5720
|
||||||
@ -77,23 +77,23 @@ class _PointDemoPainter extends CustomPainter {
|
|||||||
..strokeWidth = 4.0
|
..strokeWidth = 4.0
|
||||||
..style = PaintingStyle.stroke;
|
..style = PaintingStyle.stroke;
|
||||||
if (arc.center != null && arc.radius != null)
|
if (arc.center != null && arc.radius != null)
|
||||||
canvas.drawCircle(arc.center, arc.radius, paint);
|
canvas.drawCircle(arc.center!, arc.radius!, paint);
|
||||||
else
|
else
|
||||||
canvas.drawLine(arc.begin, arc.end, paint);
|
canvas.drawLine(arc.begin!, arc.end!, paint);
|
||||||
|
|
||||||
drawPoint(canvas, arc.begin, Colors.green);
|
drawPoint(canvas, arc.begin!, Colors.green);
|
||||||
drawPoint(canvas, arc.end, Colors.red);
|
drawPoint(canvas, arc.end!, Colors.red);
|
||||||
|
|
||||||
paint
|
paint
|
||||||
..color = Colors.green
|
..color = Colors.green
|
||||||
..style = PaintingStyle.fill;
|
..style = PaintingStyle.fill;
|
||||||
canvas.drawCircle(arc.lerp(_repaint.value), _kPointRadius, paint);
|
canvas.drawCircle(arc.lerp(_repaint!.value), _kPointRadius, paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTest(Offset position) {
|
bool hitTest(Offset position) {
|
||||||
return (arc.begin - position).distanceSquared < _kTargetSlop
|
return (arc.begin! - position).distanceSquared < _kTargetSlop
|
||||||
|| (arc.end - position).distanceSquared < _kTargetSlop;
|
|| (arc.end! - position).distanceSquared < _kTargetSlop;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -101,7 +101,7 @@ class _PointDemoPainter extends CustomPainter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _PointDemo extends StatefulWidget {
|
class _PointDemo extends StatefulWidget {
|
||||||
const _PointDemo({ Key key, this.controller }) : super(key: key);
|
const _PointDemo({ Key? key, required this.controller }) : super(key: key);
|
||||||
|
|
||||||
final AnimationController controller;
|
final AnimationController controller;
|
||||||
|
|
||||||
@ -112,11 +112,11 @@ class _PointDemo extends StatefulWidget {
|
|||||||
class _PointDemoState extends State<_PointDemo> {
|
class _PointDemoState extends State<_PointDemo> {
|
||||||
final GlobalKey _painterKey = GlobalKey();
|
final GlobalKey _painterKey = GlobalKey();
|
||||||
|
|
||||||
CurvedAnimation _animation;
|
CurvedAnimation? _animation;
|
||||||
_DragTarget _dragTarget;
|
_DragTarget? _dragTarget;
|
||||||
Size _screenSize;
|
Size? _screenSize;
|
||||||
Offset _begin;
|
Offset? _begin;
|
||||||
Offset _end;
|
Offset? _end;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -135,9 +135,9 @@ class _PointDemoState extends State<_PointDemo> {
|
|||||||
if (_dragTarget != null)
|
if (_dragTarget != null)
|
||||||
return _IgnoreDrag();
|
return _IgnoreDrag();
|
||||||
|
|
||||||
final RenderBox box = _painterKey.currentContext.findRenderObject() as RenderBox;
|
final RenderBox? box = _painterKey.currentContext!.findRenderObject() as RenderBox?;
|
||||||
final double startOffset = (box.localToGlobal(_begin) - position).distanceSquared;
|
final double startOffset = (box!.localToGlobal(_begin!) - position).distanceSquared;
|
||||||
final double endOffset = (box.localToGlobal(_end) - position).distanceSquared;
|
final double endOffset = (box.localToGlobal(_end!) - position).distanceSquared;
|
||||||
setState(() {
|
setState(() {
|
||||||
if (startOffset < endOffset && startOffset < _kTargetSlop)
|
if (startOffset < endOffset && startOffset < _kTargetSlop)
|
||||||
_dragTarget = _DragTarget.start;
|
_dragTarget = _DragTarget.start;
|
||||||
@ -151,15 +151,15 @@ class _PointDemoState extends State<_PointDemo> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _handleDragUpdate(DragUpdateDetails details) {
|
void _handleDragUpdate(DragUpdateDetails details) {
|
||||||
switch (_dragTarget) {
|
switch (_dragTarget!) {
|
||||||
case _DragTarget.start:
|
case _DragTarget.start:
|
||||||
setState(() {
|
setState(() {
|
||||||
_begin = _begin + details.delta;
|
_begin = _begin! + details.delta;
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case _DragTarget.end:
|
case _DragTarget.end:
|
||||||
setState(() {
|
setState(() {
|
||||||
_end = _end + details.delta;
|
_end = _end! + details.delta;
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -210,7 +210,7 @@ class _PointDemoState extends State<_PointDemo> {
|
|||||||
child: Text(
|
child: Text(
|
||||||
'Tap the refresh button to run the animation. Drag the green '
|
'Tap the refresh button to run the animation. Drag the green '
|
||||||
"and red points to change the animation's path.",
|
"and red points to change the animation's path.",
|
||||||
style: Theme.of(context).textTheme.caption.copyWith(fontSize: 16.0),
|
style: Theme.of(context).textTheme.caption?.copyWith(fontSize: 16.0),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -222,8 +222,8 @@ class _PointDemoState extends State<_PointDemo> {
|
|||||||
|
|
||||||
class _RectangleDemoPainter extends CustomPainter {
|
class _RectangleDemoPainter extends CustomPainter {
|
||||||
_RectangleDemoPainter({
|
_RectangleDemoPainter({
|
||||||
Animation<double> repaint,
|
required Animation<double> repaint,
|
||||||
this.arc,
|
required this.arc,
|
||||||
}) : _repaint = repaint, super(repaint: repaint);
|
}) : _repaint = repaint, super(repaint: repaint);
|
||||||
|
|
||||||
final MaterialRectArcTween arc;
|
final MaterialRectArcTween arc;
|
||||||
@ -252,15 +252,15 @@ class _RectangleDemoPainter extends CustomPainter {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void paint(Canvas canvas, Size size) {
|
void paint(Canvas canvas, Size size) {
|
||||||
drawRect(canvas, arc.begin, Colors.green);
|
drawRect(canvas, arc.begin!, Colors.green);
|
||||||
drawRect(canvas, arc.end, Colors.red);
|
drawRect(canvas, arc.end!, Colors.red);
|
||||||
drawRect(canvas, arc.lerp(_repaint.value), Colors.blue);
|
drawRect(canvas, arc.lerp(_repaint.value), Colors.blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool hitTest(Offset position) {
|
bool hitTest(Offset position) {
|
||||||
return (arc.begin.center - position).distanceSquared < _kTargetSlop
|
return (arc.begin!.center - position).distanceSquared < _kTargetSlop
|
||||||
|| (arc.end.center - position).distanceSquared < _kTargetSlop;
|
|| (arc.end!.center - position).distanceSquared < _kTargetSlop;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -268,7 +268,7 @@ class _RectangleDemoPainter extends CustomPainter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _RectangleDemo extends StatefulWidget {
|
class _RectangleDemo extends StatefulWidget {
|
||||||
const _RectangleDemo({ Key key, this.controller }) : super(key: key);
|
const _RectangleDemo({ Key? key, required this.controller }) : super(key: key);
|
||||||
|
|
||||||
final AnimationController controller;
|
final AnimationController controller;
|
||||||
|
|
||||||
@ -279,17 +279,11 @@ class _RectangleDemo extends StatefulWidget {
|
|||||||
class _RectangleDemoState extends State<_RectangleDemo> {
|
class _RectangleDemoState extends State<_RectangleDemo> {
|
||||||
final GlobalKey _painterKey = GlobalKey();
|
final GlobalKey _painterKey = GlobalKey();
|
||||||
|
|
||||||
CurvedAnimation _animation;
|
late final CurvedAnimation _animation = CurvedAnimation(parent: widget.controller, curve: Curves.fastOutSlowIn);
|
||||||
_DragTarget _dragTarget;
|
_DragTarget? _dragTarget;
|
||||||
Size _screenSize;
|
Size? _screenSize;
|
||||||
Rect _begin;
|
Rect? _begin;
|
||||||
Rect _end;
|
Rect? _end;
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_animation = CurvedAnimation(parent: widget.controller, curve: Curves.fastOutSlowIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
@ -302,9 +296,9 @@ class _RectangleDemoState extends State<_RectangleDemo> {
|
|||||||
if (_dragTarget != null)
|
if (_dragTarget != null)
|
||||||
return _IgnoreDrag();
|
return _IgnoreDrag();
|
||||||
|
|
||||||
final RenderBox box = _painterKey.currentContext.findRenderObject() as RenderBox;
|
final RenderBox? box = _painterKey.currentContext?.findRenderObject() as RenderBox?;
|
||||||
final double startOffset = (box.localToGlobal(_begin.center) - position).distanceSquared;
|
final double startOffset = (box!.localToGlobal(_begin!.center) - position).distanceSquared;
|
||||||
final double endOffset = (box.localToGlobal(_end.center) - position).distanceSquared;
|
final double endOffset = (box.localToGlobal(_end!.center) - position).distanceSquared;
|
||||||
setState(() {
|
setState(() {
|
||||||
if (startOffset < endOffset && startOffset < _kTargetSlop)
|
if (startOffset < endOffset && startOffset < _kTargetSlop)
|
||||||
_dragTarget = _DragTarget.start;
|
_dragTarget = _DragTarget.start;
|
||||||
@ -317,15 +311,15 @@ class _RectangleDemoState extends State<_RectangleDemo> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _handleDragUpdate(DragUpdateDetails details) {
|
void _handleDragUpdate(DragUpdateDetails details) {
|
||||||
switch (_dragTarget) {
|
switch (_dragTarget!) {
|
||||||
case _DragTarget.start:
|
case _DragTarget.start:
|
||||||
setState(() {
|
setState(() {
|
||||||
_begin = _begin.shift(details.delta);
|
_begin = _begin?.shift(details.delta);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case _DragTarget.end:
|
case _DragTarget.end:
|
||||||
setState(() {
|
setState(() {
|
||||||
_end = _end.shift(details.delta);
|
_end = _end?.shift(details.delta);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -382,7 +376,7 @@ class _RectangleDemoState extends State<_RectangleDemo> {
|
|||||||
child: Text(
|
child: Text(
|
||||||
'Tap the refresh button to run the animation. Drag the rectangles '
|
'Tap the refresh button to run the animation. Drag the rectangles '
|
||||||
"to change the animation's path.",
|
"to change the animation's path.",
|
||||||
style: Theme.of(context).textTheme.caption.copyWith(fontSize: 16.0),
|
style: Theme.of(context).textTheme.caption!.copyWith(fontSize: 16.0),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -406,37 +400,31 @@ class _ArcDemo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class AnimationDemo extends StatefulWidget {
|
class AnimationDemo extends StatefulWidget {
|
||||||
const AnimationDemo({ Key key }) : super(key: key);
|
const AnimationDemo({ Key? key }) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<AnimationDemo> createState() => _AnimationDemoState();
|
State<AnimationDemo> createState() => _AnimationDemoState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AnimationDemoState extends State<AnimationDemo> with TickerProviderStateMixin {
|
class _AnimationDemoState extends State<AnimationDemo> with TickerProviderStateMixin {
|
||||||
List<_ArcDemo> _allDemos;
|
late final List<_ArcDemo> _allDemos = <_ArcDemo>[
|
||||||
|
_ArcDemo('POINT', (_ArcDemo demo) {
|
||||||
@override
|
return _PointDemo(
|
||||||
void initState() {
|
key: demo.key,
|
||||||
super.initState();
|
controller: demo.controller,
|
||||||
_allDemos = <_ArcDemo>[
|
);
|
||||||
_ArcDemo('POINT', (_ArcDemo demo) {
|
}, this),
|
||||||
return _PointDemo(
|
_ArcDemo('RECTANGLE', (_ArcDemo demo) {
|
||||||
key: demo.key,
|
return _RectangleDemo(
|
||||||
controller: demo.controller,
|
key: demo.key,
|
||||||
);
|
controller: demo.controller,
|
||||||
}, this),
|
);
|
||||||
_ArcDemo('RECTANGLE', (_ArcDemo demo) {
|
}, this),
|
||||||
return _RectangleDemo(
|
];
|
||||||
key: demo.key,
|
|
||||||
controller: demo.controller,
|
|
||||||
);
|
|
||||||
}, this),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _play(_ArcDemo demo) async {
|
Future<void> _play(_ArcDemo demo) async {
|
||||||
await demo.controller.forward();
|
await demo.controller.forward();
|
||||||
if (demo.key.currentState != null && demo.key.currentState.mounted)
|
if (demo.key.currentState != null && demo.key.currentState!.mounted)
|
||||||
demo.controller.reverse();
|
demo.controller.reverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -456,7 +444,7 @@ class _AnimationDemoState extends State<AnimationDemo> with TickerProviderStateM
|
|||||||
return FloatingActionButton(
|
return FloatingActionButton(
|
||||||
child: const Icon(Icons.refresh),
|
child: const Icon(Icons.refresh),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_play(_allDemos[DefaultTabController.of(context).index]);
|
_play(_allDemos[DefaultTabController.of(context)!.index]);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -20,8 +20,8 @@ enum MarkerType { topLeft, bottomRight, touch }
|
|||||||
|
|
||||||
class _MarkerPainter extends CustomPainter {
|
class _MarkerPainter extends CustomPainter {
|
||||||
const _MarkerPainter({
|
const _MarkerPainter({
|
||||||
this.size,
|
required this.size,
|
||||||
this.type,
|
required this.type,
|
||||||
});
|
});
|
||||||
|
|
||||||
final double size;
|
final double size;
|
||||||
@ -56,21 +56,21 @@ class _MarkerPainter extends CustomPainter {
|
|||||||
|
|
||||||
class Marker extends StatelessWidget {
|
class Marker extends StatelessWidget {
|
||||||
const Marker({
|
const Marker({
|
||||||
Key key,
|
Key? key,
|
||||||
this.type = MarkerType.touch,
|
this.type = MarkerType.touch,
|
||||||
this.position,
|
this.position,
|
||||||
this.size = 40.0,
|
this.size = 40.0,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final Offset position;
|
final Offset? position;
|
||||||
final double size;
|
final double size;
|
||||||
final MarkerType type;
|
final MarkerType type;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Positioned(
|
return Positioned(
|
||||||
left: position.dx - size / 2.0,
|
left: position!.dx - size / 2.0,
|
||||||
top: position.dy - size / 2.0,
|
top: position!.dy - size / 2.0,
|
||||||
width: size,
|
width: size,
|
||||||
height: size,
|
height: size,
|
||||||
child: IgnorePointer(
|
child: IgnorePointer(
|
||||||
@ -86,7 +86,7 @@ class Marker extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class OverlayGeometryApp extends StatefulWidget {
|
class OverlayGeometryApp extends StatefulWidget {
|
||||||
const OverlayGeometryApp({Key key}) : super(key: key);
|
const OverlayGeometryApp({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
OverlayGeometryAppState createState() => OverlayGeometryAppState();
|
OverlayGeometryAppState createState() => OverlayGeometryAppState();
|
||||||
@ -95,22 +95,22 @@ class OverlayGeometryApp extends StatefulWidget {
|
|||||||
typedef CardTapCallback = void Function(GlobalKey targetKey, Offset globalPosition);
|
typedef CardTapCallback = void Function(GlobalKey targetKey, Offset globalPosition);
|
||||||
|
|
||||||
class CardBuilder extends SliverChildDelegate {
|
class CardBuilder extends SliverChildDelegate {
|
||||||
CardBuilder({ this.cardModels, this.onTapUp });
|
CardBuilder({List<CardModel>? cardModels, this.onTapUp }) : cardModels = cardModels ?? <CardModel>[];
|
||||||
|
|
||||||
final List<CardModel> cardModels;
|
final List<CardModel> cardModels;
|
||||||
final CardTapCallback onTapUp;
|
final CardTapCallback? onTapUp;
|
||||||
|
|
||||||
static const TextStyle cardLabelStyle =
|
static const TextStyle cardLabelStyle =
|
||||||
TextStyle(color: Colors.white, fontSize: 18.0, fontWeight: FontWeight.bold);
|
TextStyle(color: Colors.white, fontSize: 18.0, fontWeight: FontWeight.bold);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, int index) {
|
Widget? build(BuildContext context, int index) {
|
||||||
if (index >= cardModels.length)
|
if (index >= cardModels.length)
|
||||||
return null;
|
return null;
|
||||||
final CardModel cardModel = cardModels[index];
|
final CardModel cardModel = cardModels[index];
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
key: cardModel.key,
|
key: cardModel.key,
|
||||||
onTapUp: (TapUpDetails details) { onTapUp(cardModel.targetKey, details.globalPosition); },
|
onTapUp: (TapUpDetails details) { onTapUp!(cardModel.targetKey, details.globalPosition); },
|
||||||
child: Card(
|
child: Card(
|
||||||
key: cardModel.targetKey,
|
key: cardModel.targetKey,
|
||||||
color: cardModel.color,
|
color: cardModel.color,
|
||||||
@ -133,7 +133,7 @@ class CardBuilder extends SliverChildDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class OverlayGeometryAppState extends State<OverlayGeometryApp> {
|
class OverlayGeometryAppState extends State<OverlayGeometryApp> {
|
||||||
List<CardModel> cardModels;
|
List<CardModel> cardModels = <CardModel>[];
|
||||||
Map<MarkerType, Offset> markers = <MarkerType, Offset>{};
|
Map<MarkerType, Offset> markers = <MarkerType, Offset>{};
|
||||||
double markersScrollOffset = 0.0;
|
double markersScrollOffset = 0.0;
|
||||||
|
|
||||||
@ -146,8 +146,8 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
|
|||||||
48.0, 63.0, 82.0, 146.0, 60.0, 55.0, 84.0, 96.0, 50.0,
|
48.0, 63.0, 82.0, 146.0, 60.0, 55.0, 84.0, 96.0, 50.0,
|
||||||
];
|
];
|
||||||
cardModels = List<CardModel>.generate(cardHeights.length, (int i) {
|
cardModels = List<CardModel>.generate(cardHeights.length, (int i) {
|
||||||
final Color color = Color.lerp(Colors.red.shade300, Colors.blue.shade900, i / cardHeights.length);
|
final Color? color = Color.lerp(Colors.red.shade300, Colors.blue.shade900, i / cardHeights.length);
|
||||||
return CardModel(i, cardHeights[i], color);
|
return CardModel(i, cardHeights[i], color!);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,10 +156,9 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
final double dy = markersScrollOffset - notification.metrics.extentBefore;
|
final double dy = markersScrollOffset - notification.metrics.extentBefore;
|
||||||
markersScrollOffset = notification.metrics.extentBefore;
|
markersScrollOffset = notification.metrics.extentBefore;
|
||||||
for (final MarkerType type in markers.keys) {
|
markers.forEach((MarkerType type, Offset oldPosition) {
|
||||||
final Offset oldPosition = markers[type];
|
|
||||||
markers[type] = oldPosition.translate(0.0, dy);
|
markers[type] = oldPosition.translate(0.0, dy);
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -168,12 +167,12 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
|
|||||||
void handleTapUp(GlobalKey target, Offset globalPosition) {
|
void handleTapUp(GlobalKey target, Offset globalPosition) {
|
||||||
setState(() {
|
setState(() {
|
||||||
markers[MarkerType.touch] = globalPosition;
|
markers[MarkerType.touch] = globalPosition;
|
||||||
final RenderBox box = target.currentContext.findRenderObject() as RenderBox;
|
final RenderBox? box = target.currentContext?.findRenderObject() as RenderBox?;
|
||||||
markers[MarkerType.topLeft] = box.localToGlobal(Offset.zero);
|
markers[MarkerType.topLeft] = box!.localToGlobal(Offset.zero);
|
||||||
final Size size = box.size;
|
final Size size = box.size;
|
||||||
markers[MarkerType.bottomRight] = box.localToGlobal(Offset(size.width, size.height));
|
markers[MarkerType.bottomRight] = box.localToGlobal(Offset(size.width, size.height));
|
||||||
final ScrollableState scrollable = Scrollable.of(target.currentContext);
|
final ScrollableState? scrollable = Scrollable.of(target.currentContext!);
|
||||||
markersScrollOffset = scrollable.position.pixels;
|
markersScrollOffset = scrollable!.position.pixels;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ class CardModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class PageViewApp extends StatefulWidget {
|
class PageViewApp extends StatefulWidget {
|
||||||
const PageViewApp({Key key}) : super(key: key);
|
const PageViewApp({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
PageViewAppState createState() => PageViewAppState();
|
PageViewAppState createState() => PageViewAppState();
|
||||||
@ -33,15 +33,15 @@ class PageViewAppState extends State<PageViewApp> {
|
|||||||
];
|
];
|
||||||
|
|
||||||
cardModels = List<CardModel>.generate(cardSizes.length, (int i) {
|
cardModels = List<CardModel>.generate(cardSizes.length, (int i) {
|
||||||
final Color color = Color.lerp(Colors.red.shade300, Colors.blue.shade900, i / cardSizes.length);
|
final Color? color = Color.lerp(Colors.red.shade300, Colors.blue.shade900, i / cardSizes.length);
|
||||||
return CardModel(i, cardSizes[i], color);
|
return CardModel(i, cardSizes[i], color!);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TextStyle cardLabelStyle =
|
static const TextStyle cardLabelStyle =
|
||||||
TextStyle(color: Colors.white, fontSize: 18.0, fontWeight: FontWeight.bold);
|
TextStyle(color: Colors.white, fontSize: 18.0, fontWeight: FontWeight.bold);
|
||||||
|
|
||||||
List<CardModel> cardModels;
|
List<CardModel> cardModels = <CardModel>[];
|
||||||
Size pageSize = const Size(200.0, 200.0);
|
Size pageSize = const Size(200.0, 200.0);
|
||||||
Axis scrollDirection = Axis.horizontal;
|
Axis scrollDirection = Axis.horizontal;
|
||||||
bool itemsWrap = false;
|
bool itemsWrap = false;
|
||||||
|
@ -20,7 +20,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class RawKeyboardDemo extends StatefulWidget {
|
class RawKeyboardDemo extends StatefulWidget {
|
||||||
const RawKeyboardDemo({Key key}) : super(key: key);
|
const RawKeyboardDemo({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<RawKeyboardDemo> createState() => _HardwareKeyDemoState();
|
State<RawKeyboardDemo> createState() => _HardwareKeyDemoState();
|
||||||
@ -28,7 +28,7 @@ class RawKeyboardDemo extends StatefulWidget {
|
|||||||
|
|
||||||
class _HardwareKeyDemoState extends State<RawKeyboardDemo> {
|
class _HardwareKeyDemoState extends State<RawKeyboardDemo> {
|
||||||
final FocusNode _focusNode = FocusNode();
|
final FocusNode _focusNode = FocusNode();
|
||||||
RawKeyEvent _event;
|
RawKeyEvent? _event;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
@ -60,7 +60,7 @@ class _HardwareKeyDemoState extends State<RawKeyboardDemo> {
|
|||||||
autofocus: true,
|
autofocus: true,
|
||||||
child: AnimatedBuilder(
|
child: AnimatedBuilder(
|
||||||
animation: _focusNode,
|
animation: _focusNode,
|
||||||
builder: (BuildContext context, Widget child) {
|
builder: (BuildContext context, Widget? child) {
|
||||||
if (!_focusNode.hasFocus) {
|
if (!_focusNode.hasFocus) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
@ -74,11 +74,11 @@ class _HardwareKeyDemoState extends State<RawKeyboardDemo> {
|
|||||||
return Text('Press a key', style: textTheme.headline4);
|
return Text('Press a key', style: textTheme.headline4);
|
||||||
}
|
}
|
||||||
|
|
||||||
final RawKeyEventData data = _event.data;
|
final RawKeyEventData? data = _event?.data;
|
||||||
final String modifierList = data.modifiersPressed.keys.map<String>(_getEnumName).join(', ').replaceAll('Modifier', '');
|
final String? modifierList = data?.modifiersPressed.keys.map<String>(_getEnumName).join(', ').replaceAll('Modifier', '');
|
||||||
final List<Widget> dataText = <Widget>[
|
final List<Widget> dataText = <Widget>[
|
||||||
Text('${_event.runtimeType}'),
|
Text('${_event.runtimeType}'),
|
||||||
if (_event.character?.isNotEmpty ?? false) Text('character produced: "${_event.character}"'),
|
if (_event?.character?.isNotEmpty ?? false) Text('character produced: "${_event?.character}"'),
|
||||||
Text('modifiers set: $modifierList'),
|
Text('modifiers set: $modifierList'),
|
||||||
];
|
];
|
||||||
if (data is RawKeyEventDataAndroid) {
|
if (data is RawKeyEventDataAndroid) {
|
||||||
@ -119,12 +119,12 @@ class _HardwareKeyDemoState extends State<RawKeyboardDemo> {
|
|||||||
dataText.add(Text('code: ${data.code}'));
|
dataText.add(Text('code: ${data.code}'));
|
||||||
dataText.add(Text('metaState: ${data.metaState} (${_asHex(data.metaState)})'));
|
dataText.add(Text('metaState: ${data.metaState} (${_asHex(data.metaState)})'));
|
||||||
}
|
}
|
||||||
dataText.add(Text('logical: ${_event.logicalKey}'));
|
dataText.add(Text('logical: ${_event?.logicalKey}'));
|
||||||
dataText.add(Text('physical: ${_event.physicalKey}'));
|
dataText.add(Text('physical: ${_event?.physicalKey}'));
|
||||||
if (_event.character != null) {
|
if (_event?.character != null) {
|
||||||
dataText.add(Text('character: ${_event.character}'));
|
dataText.add(Text('character: ${_event?.character}'));
|
||||||
}
|
}
|
||||||
for (final ModifierKey modifier in data.modifiersPressed.keys) {
|
for (final ModifierKey modifier in data!.modifiersPressed.keys) {
|
||||||
for (final KeyboardSide side in KeyboardSide.values) {
|
for (final KeyboardSide side in KeyboardSide.values) {
|
||||||
if (data.isModifierPressed(modifier, side: side)) {
|
if (data.isModifierPressed(modifier, side: side)) {
|
||||||
dataText.add(
|
dataText.add(
|
||||||
@ -135,11 +135,11 @@ class _HardwareKeyDemoState extends State<RawKeyboardDemo> {
|
|||||||
}
|
}
|
||||||
final List<String> pressed = <String>['Pressed:'];
|
final List<String> pressed = <String>['Pressed:'];
|
||||||
for (final LogicalKeyboardKey key in RawKeyboard.instance.keysPressed) {
|
for (final LogicalKeyboardKey key in RawKeyboard.instance.keysPressed) {
|
||||||
pressed.add(key.debugName);
|
pressed.add(key.debugName!);
|
||||||
}
|
}
|
||||||
dataText.add(Text(pressed.join(' ')));
|
dataText.add(Text(pressed.join(' ')));
|
||||||
return DefaultTextStyle(
|
return DefaultTextStyle(
|
||||||
style: textTheme.subtitle1,
|
style: textTheme.subtitle1!,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: dataText,
|
children: dataText,
|
||||||
|
@ -26,7 +26,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Home extends StatefulWidget {
|
class Home extends StatefulWidget {
|
||||||
const Home({ Key key }) : super(key: key);
|
const Home({ Key? key }) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<Home> createState() => _HomeState();
|
State<Home> createState() => _HomeState();
|
||||||
@ -119,7 +119,7 @@ class _HomeState extends State<Home> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Fuzzer extends StatefulWidget {
|
class Fuzzer extends StatefulWidget {
|
||||||
const Fuzzer({ Key key, this.seed }) : super(key: key);
|
const Fuzzer({ Key? key, required this.seed }) : super(key: key);
|
||||||
|
|
||||||
final int seed;
|
final int seed;
|
||||||
|
|
||||||
@ -129,14 +129,12 @@ class Fuzzer extends StatefulWidget {
|
|||||||
|
|
||||||
class _FuzzerState extends State<Fuzzer> with SingleTickerProviderStateMixin {
|
class _FuzzerState extends State<Fuzzer> with SingleTickerProviderStateMixin {
|
||||||
TextSpan _textSpan = const TextSpan(text: 'Welcome to the Flutter text fuzzer.');
|
TextSpan _textSpan = const TextSpan(text: 'Welcome to the Flutter text fuzzer.');
|
||||||
Ticker _ticker;
|
late final Ticker _ticker = createTicker(_updateTextSpan)..start();
|
||||||
math.Random _random;
|
late final math.Random _random = math.Random(widget.seed); // providing a seed is important for reproducibility;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_random = math.Random(widget.seed); // providing a seed is important for reproducibility
|
|
||||||
_ticker = createTicker(_updateTextSpan)..start();
|
|
||||||
_updateTextSpan(null);
|
_updateTextSpan(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +144,7 @@ class _FuzzerState extends State<Fuzzer> with SingleTickerProviderStateMixin {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _updateTextSpan(Duration duration) {
|
void _updateTextSpan(Duration? duration) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_textSpan = _fiddleWith(_textSpan);
|
_textSpan = _fiddleWith(_textSpan);
|
||||||
});
|
});
|
||||||
@ -156,17 +154,17 @@ class _FuzzerState extends State<Fuzzer> with SingleTickerProviderStateMixin {
|
|||||||
return TextSpan(
|
return TextSpan(
|
||||||
text: _fiddleWithText(node.text),
|
text: _fiddleWithText(node.text),
|
||||||
style: _fiddleWithStyle(node.style),
|
style: _fiddleWithStyle(node.style),
|
||||||
children: _fiddleWithChildren(node.children?.map((InlineSpan child) => _fiddleWith(child as TextSpan))?.toList() ?? <TextSpan>[]),
|
children: _fiddleWithChildren(node.children?.map((InlineSpan child) => _fiddleWith(child as TextSpan)).toList() ?? <TextSpan>[]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
String _fiddleWithText(String text) {
|
String? _fiddleWithText(String? text) {
|
||||||
if (_random.nextInt(10) > 0)
|
if (_random.nextInt(10) > 0)
|
||||||
return text;
|
return text;
|
||||||
return _createRandomText();
|
return _createRandomText();
|
||||||
}
|
}
|
||||||
|
|
||||||
TextStyle _fiddleWithStyle(TextStyle style) {
|
TextStyle? _fiddleWithStyle(TextStyle? style) {
|
||||||
if (style == null) {
|
if (style == null) {
|
||||||
switch (_random.nextInt(20)) {
|
switch (_random.nextInt(20)) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -196,7 +194,7 @@ class _FuzzerState extends State<Fuzzer> with SingleTickerProviderStateMixin {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color _fiddleWithColor(Color value) {
|
Color? _fiddleWithColor(Color? value) {
|
||||||
switch (_random.nextInt(10)) {
|
switch (_random.nextInt(10)) {
|
||||||
case 0:
|
case 0:
|
||||||
if (value == null)
|
if (value == null)
|
||||||
@ -218,7 +216,7 @@ class _FuzzerState extends State<Fuzzer> with SingleTickerProviderStateMixin {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextDecoration _fiddleWithDecoration(TextDecoration value) {
|
TextDecoration? _fiddleWithDecoration(TextDecoration? value) {
|
||||||
if (_random.nextInt(10) > 0)
|
if (_random.nextInt(10) > 0)
|
||||||
return value;
|
return value;
|
||||||
switch (_random.nextInt(100)) {
|
switch (_random.nextInt(100)) {
|
||||||
@ -246,7 +244,7 @@ class _FuzzerState extends State<Fuzzer> with SingleTickerProviderStateMixin {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextDecorationStyle _fiddleWithDecorationStyle(TextDecorationStyle value) {
|
TextDecorationStyle? _fiddleWithDecorationStyle(TextDecorationStyle? value) {
|
||||||
switch (_random.nextInt(10)) {
|
switch (_random.nextInt(10)) {
|
||||||
case 0:
|
case 0:
|
||||||
return null;
|
return null;
|
||||||
@ -256,7 +254,7 @@ class _FuzzerState extends State<Fuzzer> with SingleTickerProviderStateMixin {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
FontWeight _fiddleWithFontWeight(FontWeight value) {
|
FontWeight? _fiddleWithFontWeight(FontWeight? value) {
|
||||||
switch (_random.nextInt(10)) {
|
switch (_random.nextInt(10)) {
|
||||||
case 0:
|
case 0:
|
||||||
return null;
|
return null;
|
||||||
@ -266,7 +264,7 @@ class _FuzzerState extends State<Fuzzer> with SingleTickerProviderStateMixin {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
FontStyle _fiddleWithFontStyle(FontStyle value) {
|
FontStyle? _fiddleWithFontStyle(FontStyle? value) {
|
||||||
switch (_random.nextInt(10)) {
|
switch (_random.nextInt(10)) {
|
||||||
case 0:
|
case 0:
|
||||||
return null;
|
return null;
|
||||||
@ -276,7 +274,7 @@ class _FuzzerState extends State<Fuzzer> with SingleTickerProviderStateMixin {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
String _fiddleWithFontFamily(String value) {
|
String? _fiddleWithFontFamily(String? value) {
|
||||||
switch (_random.nextInt(10)) {
|
switch (_random.nextInt(10)) {
|
||||||
case 0:
|
case 0:
|
||||||
return null;
|
return null;
|
||||||
@ -300,7 +298,7 @@ class _FuzzerState extends State<Fuzzer> with SingleTickerProviderStateMixin {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
double _fiddleWithDouble(double value, double defaultValue, double max) {
|
double? _fiddleWithDouble(double? value, double defaultValue, double max) {
|
||||||
switch (_random.nextInt(10)) {
|
switch (_random.nextInt(10)) {
|
||||||
case 0:
|
case 0:
|
||||||
if (value == null)
|
if (value == null)
|
||||||
@ -312,7 +310,7 @@ class _FuzzerState extends State<Fuzzer> with SingleTickerProviderStateMixin {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<TextSpan> _fiddleWithChildren(List<TextSpan> children) {
|
List<TextSpan>? _fiddleWithChildren(List<TextSpan> children) {
|
||||||
switch (_random.nextInt(100)) {
|
switch (_random.nextInt(100)) {
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
@ -340,10 +338,10 @@ class _FuzzerState extends State<Fuzzer> with SingleTickerProviderStateMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int depthOf(TextSpan node) {
|
int depthOf(TextSpan node) {
|
||||||
if (node.children == null || node.children.isEmpty)
|
if (node.children == null || node.children?.isEmpty == true)
|
||||||
return 0;
|
return 0;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for (final TextSpan child in node.children.cast<TextSpan>())
|
for (final TextSpan child in node.children!.cast<TextSpan>())
|
||||||
result = math.max(result, depthOf(child));
|
result = math.max(result, depthOf(child));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -354,7 +352,7 @@ class _FuzzerState extends State<Fuzzer> with SingleTickerProviderStateMixin {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
String _createRandomText() {
|
String? _createRandomText() {
|
||||||
switch (_random.nextInt(90)) {
|
switch (_random.nextInt(90)) {
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
@ -536,7 +534,7 @@ class _FuzzerState extends State<Fuzzer> with SingleTickerProviderStateMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Underlines extends StatefulWidget {
|
class Underlines extends StatefulWidget {
|
||||||
const Underlines({ Key key }) : super(key: key);
|
const Underlines({ Key? key }) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<Underlines> createState() => _UnderlinesState();
|
State<Underlines> createState() => _UnderlinesState();
|
||||||
@ -554,7 +552,7 @@ class _UnderlinesState extends State<Underlines> {
|
|||||||
decorationColor: Colors.yellow.shade500,
|
decorationColor: Colors.yellow.shade500,
|
||||||
);
|
);
|
||||||
|
|
||||||
Widget _wrap(TextDecorationStyle style) {
|
Widget _wrap(TextDecorationStyle? style) {
|
||||||
return Align(
|
return Align(
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
heightFactor: 1.0,
|
heightFactor: 1.0,
|
||||||
@ -641,7 +639,7 @@ class _UnderlinesState extends State<Underlines> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Fallback extends StatefulWidget {
|
class Fallback extends StatefulWidget {
|
||||||
const Fallback({ Key key }) : super(key: key);
|
const Fallback({ Key? key }) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<Fallback> createState() => _FallbackState();
|
State<Fallback> createState() => _FallbackState();
|
||||||
@ -736,7 +734,7 @@ class _FallbackState extends State<Fallback> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Bidi extends StatefulWidget {
|
class Bidi extends StatefulWidget {
|
||||||
const Bidi({ Key key }) : super(key: key);
|
const Bidi({ Key? key }) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<Bidi> createState() => _BidiState();
|
State<Bidi> createState() => _BidiState();
|
||||||
@ -811,7 +809,7 @@ class _BidiState extends State<Bidi> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Zalgo extends StatefulWidget {
|
class Zalgo extends StatefulWidget {
|
||||||
const Zalgo({ Key key, this.seed }) : super(key: key);
|
const Zalgo({ Key? key, required this.seed }) : super(key: key);
|
||||||
|
|
||||||
final int seed;
|
final int seed;
|
||||||
|
|
||||||
@ -820,15 +818,14 @@ class Zalgo extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ZalgoState extends State<Zalgo> with SingleTickerProviderStateMixin {
|
class _ZalgoState extends State<Zalgo> with SingleTickerProviderStateMixin {
|
||||||
String _text;
|
String? _text;
|
||||||
Ticker _ticker;
|
late final Ticker _ticker = createTicker(_update)..start();
|
||||||
math.Random _random;
|
math.Random _random = math.Random();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_random = math.Random(widget.seed); // providing a seed is important for reproducibility
|
_random = math.Random(widget.seed); // providing a seed is important for reproducibility;
|
||||||
_ticker = createTicker(_update)..start();
|
|
||||||
_update(null);
|
_update(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -841,7 +838,7 @@ class _ZalgoState extends State<Zalgo> with SingleTickerProviderStateMixin {
|
|||||||
bool _allowSpacing = false;
|
bool _allowSpacing = false;
|
||||||
bool _varyBase = false;
|
bool _varyBase = false;
|
||||||
|
|
||||||
void _update(Duration duration) {
|
void _update(Duration? duration) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_text = zalgo(
|
_text = zalgo(
|
||||||
_random,
|
_random,
|
||||||
@ -918,7 +915,7 @@ class _ZalgoState extends State<Zalgo> with SingleTickerProviderStateMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Painting extends StatefulWidget {
|
class Painting extends StatefulWidget {
|
||||||
const Painting({ Key key, this.seed }) : super(key: key);
|
const Painting({ Key? key, required this.seed }) : super(key: key);
|
||||||
|
|
||||||
final int seed;
|
final int seed;
|
||||||
|
|
||||||
@ -927,15 +924,14 @@ class Painting extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _PaintingState extends State<Painting> with SingleTickerProviderStateMixin {
|
class _PaintingState extends State<Painting> with SingleTickerProviderStateMixin {
|
||||||
String _text;
|
String? _text;
|
||||||
Ticker _ticker;
|
late final Ticker _ticker = createTicker(_update)..start();
|
||||||
math.Random _random;
|
math.Random _random = math.Random();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_random = math.Random(widget.seed); // providing a seed is important for reproducibility
|
_random = math.Random(widget.seed); // providing a seed is important for reproducibility;
|
||||||
_ticker = createTicker(_update)..start();
|
|
||||||
_update(null);
|
_update(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -950,7 +946,7 @@ class _PaintingState extends State<Painting> with SingleTickerProviderStateMixin
|
|||||||
|
|
||||||
bool _ellipsize = false;
|
bool _ellipsize = false;
|
||||||
|
|
||||||
void _update(Duration duration) {
|
void _update(Duration? duration) {
|
||||||
setState(() {
|
setState(() {
|
||||||
final StringBuffer buffer = StringBuffer();
|
final StringBuffer buffer = StringBuffer();
|
||||||
final int targetLength = _random.nextInt(20) + (_ellipsize ? MediaQuery.of(context).size.width.round() : 1);
|
final int targetLength = _random.nextInt(20) + (_ellipsize ? MediaQuery.of(context).size.width.round() : 1);
|
||||||
@ -963,11 +959,11 @@ class _PaintingState extends State<Painting> with SingleTickerProviderStateMixin
|
|||||||
}
|
}
|
||||||
_text = buffer.toString();
|
_text = buffer.toString();
|
||||||
});
|
});
|
||||||
SchedulerBinding.instance.addPostFrameCallback((Duration duration) {
|
SchedulerBinding.instance?.addPostFrameCallback((Duration duration) {
|
||||||
if (mounted && intrinsicKey.currentContext.size.height != controlKey.currentContext.size.height) {
|
if (mounted && intrinsicKey.currentContext?.size?.height != controlKey.currentContext?.size?.height) {
|
||||||
debugPrint('Found some text that unexpectedly renders at different heights.');
|
debugPrint('Found some text that unexpectedly renders at different heights.');
|
||||||
debugPrint('Text: $_text');
|
debugPrint('Text: $_text');
|
||||||
debugPrint(_text.runes.map<String>((int index) => 'U+' + index.toRadixString(16).padLeft(4, '0')).join(' '));
|
debugPrint(_text?.runes.map<String>((int index) => 'U+' + index.toRadixString(16).padLeft(4, '0')).join(' '));
|
||||||
setState(() {
|
setState(() {
|
||||||
_ticker.stop();
|
_ticker.stop();
|
||||||
});
|
});
|
||||||
@ -1080,7 +1076,7 @@ class _PaintingState extends State<Painting> with SingleTickerProviderStateMixin
|
|||||||
TextButton(
|
TextButton(
|
||||||
onPressed: _ticker.isActive ? null : () {
|
onPressed: _ticker.isActive ? null : () {
|
||||||
print('The currently visible text is: $_text');
|
print('The currently visible text is: $_text');
|
||||||
print(_text.runes.map<String>((int value) => 'U+${value.toRadixString(16).padLeft(4, '0').toUpperCase()}').join(' '));
|
print(_text?.runes.map<String>((int value) => 'U+${value.toRadixString(16).padLeft(4, '0').toUpperCase()}').join(' '));
|
||||||
},
|
},
|
||||||
child: const Text('DUMP TEXT TO LOGS'),
|
child: const Text('DUMP TEXT TO LOGS'),
|
||||||
),
|
),
|
||||||
@ -1096,7 +1092,7 @@ class _PaintingState extends State<Painting> with SingleTickerProviderStateMixin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String zalgo(math.Random random, int targetLength, { bool includeSpacingCombiningMarks = false, String base }) {
|
String zalgo(math.Random random, int targetLength, { bool includeSpacingCombiningMarks = false, String? base }) {
|
||||||
// The following three tables are derived from UnicodeData.txt:
|
// The following three tables are derived from UnicodeData.txt:
|
||||||
// http://unicode.org/Public/UNIDATA/UnicodeData.txt
|
// http://unicode.org/Public/UNIDATA/UnicodeData.txt
|
||||||
// There are three groups, character classes Mc, Me, and Mn.
|
// There are three groups, character classes Mc, Me, and Mn.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name: manual_tests
|
name: manual_tests
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.2.2 <3.0.0"
|
sdk: ">=2.12.0 <3.0.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
|
@ -10,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
import '../../../packages/flutter/test/image_data.dart';
|
import '../../../packages/flutter/test/image_data.dart';
|
||||||
|
|
||||||
// Returns a mock HTTP client that responds with an image to all requests.
|
// Returns a mock HTTP client that responds with an image to all requests.
|
||||||
FakeHttpClient createMockImageHttpClient(SecurityContext _) {
|
FakeHttpClient createMockImageHttpClient(SecurityContext? _) {
|
||||||
final FakeHttpClient client = FakeHttpClient();
|
final FakeHttpClient client = FakeHttpClient();
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
@ -50,10 +50,10 @@ class FakeHttpClientResponse extends Fake implements HttpClientResponse {
|
|||||||
HttpClientResponseCompressionState get compressionState => HttpClientResponseCompressionState.notCompressed;
|
HttpClientResponseCompressionState get compressionState => HttpClientResponseCompressionState.notCompressed;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
StreamSubscription<List<int>> listen(void Function(List<int>) onData, {
|
StreamSubscription<List<int>> listen(void Function(List<int>)? onData, {
|
||||||
void Function() onDone,
|
void Function()? onDone,
|
||||||
Function onError,
|
Function? onError,
|
||||||
bool cancelOnError,
|
bool? cancelOnError,
|
||||||
}) {
|
}) {
|
||||||
return Stream<List<int>>.fromIterable(<List<int>>[kTransparentImage])
|
return Stream<List<int>>.fromIterable(<List<int>>[kTransparentImage])
|
||||||
.listen(onData, onDone: onDone, onError: onError, cancelOnError: cancelOnError);
|
.listen(onData, onDone: onDone, onError: onError, cancelOnError: cancelOnError);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user