diff --git a/packages/flutter/lib/src/widgets/animated_switcher.dart b/packages/flutter/lib/src/widgets/animated_switcher.dart index 4598bec167..687c8e71d5 100644 --- a/packages/flutter/lib/src/widgets/animated_switcher.dart +++ b/packages/flutter/lib/src/widgets/animated_switcher.dart @@ -90,7 +90,7 @@ typedef AnimatedSwitcherLayoutBuilder = Widget Function(Widget? currentChild, Li /// The type of transition can be changed from a cross-fade to a custom /// transition by setting the [transitionBuilder]. /// -/// {@tool dartpad --template=stateful_widget_material_no_null_safety} +/// {@tool dartpad --template=stateful_widget_material} /// This sample shows a counter that animates the scale of a text widget /// whenever the value changes. /// diff --git a/packages/flutter/lib/src/widgets/editable_text.dart b/packages/flutter/lib/src/widgets/editable_text.dart index 5fe021e595..2dc8a620fa 100644 --- a/packages/flutter/lib/src/widgets/editable_text.dart +++ b/packages/flutter/lib/src/widgets/editable_text.dart @@ -84,7 +84,7 @@ const int _kObscureShowLatestCharCursorTicks = 3; /// /// Remember to [dispose] of the [TextEditingController] when it is no longer /// needed. This will ensure we discard any resources used by the object. -/// {@tool dartpad --template=stateful_widget_material_no_null_safety} +/// {@tool dartpad --template=stateful_widget_material} /// This example creates a [TextField] with a [TextEditingController] whose /// change listener forces the entered text to be lower case and keeps the /// cursor at the end of the input. @@ -926,18 +926,13 @@ class EditableText extends StatefulWidget { /// and selection, one can add a listener to its [controller] with /// [TextEditingController.addListener]. /// - /// {@tool dartpad --template=stateful_widget_material_no_null_safety} + /// {@tool dartpad --template=stateful_widget_material} /// /// This example shows how onChanged could be used to check the TextField's /// current value each time the user inserts or deletes a character. /// /// ```dart - /// TextEditingController _controller; - /// - /// void initState() { - /// super.initState(); - /// _controller = TextEditingController(); - /// } + /// final TextEditingController _controller = TextEditingController(); /// /// void dispose() { /// _controller.dispose(); @@ -961,7 +956,7 @@ class EditableText extends StatefulWidget { /// context: context, /// builder: (BuildContext context) { /// return AlertDialog( - /// title: const Text('Thats correct!'), + /// title: const Text('That is correct!'), /// content: Text ('13 is the right answer.'), /// actions: [ /// TextButton( diff --git a/packages/flutter/lib/src/widgets/focus_manager.dart b/packages/flutter/lib/src/widgets/focus_manager.dart index 25d7eadb74..24cae56d86 100644 --- a/packages/flutter/lib/src/widgets/focus_manager.dart +++ b/packages/flutter/lib/src/widgets/focus_manager.dart @@ -303,10 +303,10 @@ enum UnfocusDisposition { /// [DirectionalFocusTraversalPolicyMixin], but custom policies can be built /// based upon these policies. See [FocusTraversalPolicy] for more information. /// -/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety} This example shows how -/// a FocusNode should be managed if not using the [Focus] or [FocusScope] -/// widgets. See the [Focus] widget for a similar example using [Focus] and -/// [FocusScope] widgets. +/// {@tool dartpad --template=stateless_widget_scaffold} +/// This example shows how a FocusNode should be managed if not using the +/// [Focus] or [FocusScope] widgets. See the [Focus] widget for a similar +/// example using [Focus] and [FocusScope] widgets. /// /// ```dart imports /// import 'package:flutter/services.dart'; @@ -314,16 +314,16 @@ enum UnfocusDisposition { /// /// ```dart preamble /// class ColorfulButton extends StatefulWidget { -/// ColorfulButton({Key key}) : super(key: key); +/// ColorfulButton({Key? key}) : super(key: key); /// /// @override /// _ColorfulButtonState createState() => _ColorfulButtonState(); /// } /// /// class _ColorfulButtonState extends State { -/// FocusNode _node; +/// late FocusNode _node; /// bool _focused = false; -/// FocusAttachment _nodeAttachment; +/// late FocusAttachment _nodeAttachment; /// Color _color = Colors.white; /// /// @override @@ -406,7 +406,7 @@ enum UnfocusDisposition { /// Widget build(BuildContext context) { /// final TextTheme textTheme = Theme.of(context).textTheme; /// return DefaultTextStyle( -/// style: textTheme.headline4, +/// style: textTheme.headline4!, /// child: ColorfulButton(), /// ); /// } @@ -786,7 +786,7 @@ class FocusNode with DiagnosticableTreeMixin, ChangeNotifier { /// previous node in the enclosing [FocusTraversalGroup], call [nextFocus] or /// [previousFocus] instead of calling `unfocus`. /// - /// {@tool dartpad --template=stateful_widget_material_no_null_safety} + /// {@tool dartpad --template=stateful_widget_material} /// This example shows the difference between the different [UnfocusDisposition] /// values for [unfocus]. /// @@ -835,9 +835,11 @@ class FocusNode with DiagnosticableTreeMixin, ChangeNotifier { /// children: [ /// Radio( /// groupValue: disposition, - /// onChanged: (UnfocusDisposition value) { + /// onChanged: (UnfocusDisposition? value) { /// setState(() { - /// disposition = value; + /// if (value != null) { + /// disposition = value; + /// } /// }); /// }, /// value: UnfocusDisposition.values[index], @@ -850,7 +852,7 @@ class FocusNode with DiagnosticableTreeMixin, ChangeNotifier { /// child: const Text('UNFOCUS'), /// onPressed: () { /// setState(() { - /// primaryFocus.unfocus(disposition: disposition); + /// primaryFocus!.unfocus(disposition: disposition); /// }); /// }, /// ), diff --git a/packages/flutter/lib/src/widgets/focus_traversal.dart b/packages/flutter/lib/src/widgets/focus_traversal.dart index a59a68e912..81368b61dd 100644 --- a/packages/flutter/lib/src/widgets/focus_traversal.dart +++ b/packages/flutter/lib/src/widgets/focus_traversal.dart @@ -1256,14 +1256,18 @@ class _OrderedFocusInfo { /// /// {@macro flutter.widgets.FocusOrder.comparable} /// -/// {@tool dartpad --template=stateless_widget_scaffold_center_no_null_safety} +/// {@tool dartpad --template=stateless_widget_scaffold_center} /// This sample shows how to assign a traversal order to a widget. In the /// example, the focus order goes from bottom right (the "One" button) to top /// left (the "Six" button). /// /// ```dart preamble /// class DemoButton extends StatelessWidget { -/// const DemoButton({this.name, this.autofocus = false, this.order}); +/// const DemoButton({ +/// required this.name, +/// this.autofocus = false, +/// required this.order, +/// }); /// /// final String name; /// final bool autofocus; @@ -1466,7 +1470,7 @@ class FocusTraversalOrder extends InheritedWidget { /// To prevent the members of the group from being focused, set the /// [descendantsAreFocusable] attribute to false. /// -/// {@tool dartpad --template=stateless_widget_material_no_null_safety} +/// {@tool dartpad --template=stateless_widget_material} /// This sample shows three rows of buttons, each grouped by a /// [FocusTraversalGroup], each with different traversal order policies. Use tab /// traversal to see the order they are traversed in. The first row follows a @@ -1479,10 +1483,10 @@ class FocusTraversalOrder extends InheritedWidget { /// /// the type of T. /// class OrderedButton extends StatefulWidget { /// const OrderedButton({ -/// this.name, +/// required this.name, /// this.canRequestFocus = true, /// this.autofocus = false, -/// this.order, +/// required this.order, /// }); /// /// final String name; @@ -1495,7 +1499,7 @@ class FocusTraversalOrder extends InheritedWidget { /// } /// /// class _OrderedButtonState extends State> { -/// FocusNode focusNode; +/// late FocusNode focusNode; /// /// @override /// void initState() { @@ -1508,12 +1512,12 @@ class FocusTraversalOrder extends InheritedWidget { /// /// @override /// void dispose() { -/// focusNode?.dispose(); +/// focusNode.dispose(); /// super.dispose(); /// } /// /// @override -/// void didUpdateWidget(OrderedButton oldWidget) { +/// void didUpdateWidget(OrderedButton oldWidget) { /// super.didUpdateWidget(oldWidget); /// focusNode.canRequestFocus = widget.canRequestFocus; /// } @@ -1533,7 +1537,7 @@ class FocusTraversalOrder extends InheritedWidget { /// order = LexicalFocusOrder(widget.order.toString()); /// } /// -/// Color overlayColor(Set states) { +/// Color? overlayColor(Set states) { /// if (states.contains(MaterialState.focused)) { /// return Colors.red; /// } @@ -1543,7 +1547,7 @@ class FocusTraversalOrder extends InheritedWidget { /// return null; // defer to the default overlayColor /// } /// -/// Color foregroundColor(Set states) { +/// Color? foregroundColor(Set states) { /// if (states.contains(MaterialState.focused) || states.contains(MaterialState.hovered)) { /// return Colors.white; /// } @@ -1558,8 +1562,8 @@ class FocusTraversalOrder extends InheritedWidget { /// focusNode: focusNode, /// autofocus: widget.autofocus, /// style: ButtonStyle( -/// overlayColor: MaterialStateProperty.resolveWith(overlayColor), -/// foregroundColor: MaterialStateProperty.resolveWith(foregroundColor), +/// overlayColor: MaterialStateProperty.resolveWith(overlayColor), +/// foregroundColor: MaterialStateProperty.resolveWith(foregroundColor), /// ), /// onPressed: () => _handleOnPressed(), /// child: Text(widget.name), diff --git a/packages/flutter/lib/src/widgets/inherited_theme.dart b/packages/flutter/lib/src/widgets/inherited_theme.dart index 1112da0b74..7571c08b7a 100644 --- a/packages/flutter/lib/src/widgets/inherited_theme.dart +++ b/packages/flutter/lib/src/widgets/inherited_theme.dart @@ -17,7 +17,7 @@ import 'framework.dart'; /// like the contents of a new route or an overlay, will be able to see the /// ancestor inherited themes of the context it was built in. /// -/// {@tool dartpad --template=freeform_no_null_safety} +/// {@tool dartpad --template=freeform} /// This example demonstrates how `InheritedTheme.capture()` can be used /// to wrap the contents of a new route with the inherited themes that /// are present when the route was built - but are not present when route diff --git a/packages/flutter/lib/src/widgets/layout_builder.dart b/packages/flutter/lib/src/widgets/layout_builder.dart index 860f685ba1..29f084c6b2 100644 --- a/packages/flutter/lib/src/widgets/layout_builder.dart +++ b/packages/flutter/lib/src/widgets/layout_builder.dart @@ -243,7 +243,7 @@ mixin RenderConstrainedLayoutBuilder