diff --git a/packages/flutter/lib/src/animation/curves.dart b/packages/flutter/lib/src/animation/curves.dart index a0fa703330..6db5459c1d 100644 --- a/packages/flutter/lib/src/animation/curves.dart +++ b/packages/flutter/lib/src/animation/curves.dart @@ -319,7 +319,7 @@ class Cubic extends Curve { /// part of the curve, or hardly at all in another part of the curve, depending /// on the definition of the curve. /// -/// {@tool dartpad --template=stateless_widget_material_no_null_safety} +/// {@tool dartpad --template=stateless_widget_material} /// This example shows how to use a [Curve2D] to modify the position of a widget /// so that it can follow an arbitrary path. /// @@ -346,16 +346,12 @@ class Cubic extends Curve { /// /// class FollowCurve2D extends StatefulWidget { /// const FollowCurve2D({ -/// Key key, -/// @required this.path, +/// Key? key, +/// required this.path, /// this.curve = Curves.easeInOut, -/// @required this.child, +/// required this.child, /// this.duration = const Duration(seconds: 1), -/// }) : assert(path != null), -/// assert(curve != null), -/// assert(child != null), -/// assert(duration != null), -/// super(key: key); +/// }) : super(key: key); /// /// final Curve2D path; /// final Curve curve; @@ -368,9 +364,9 @@ class Cubic extends Curve { /// /// class _FollowCurve2DState extends State with TickerProviderStateMixin { /// // The animation controller for this animation. -/// AnimationController controller; +/// late AnimationController controller; /// // The animation that will be used to apply the widget's animation curve. -/// Animation animation; +/// late Animation animation; /// /// @override /// void initState() { @@ -414,7 +410,7 @@ class Cubic extends Curve { /// child: CircleAvatar( /// backgroundColor: Colors.yellow, /// child: DefaultTextStyle( -/// style: Theme.of(context).textTheme.headline6, +/// style: Theme.of(context).textTheme.headline6!, /// child: Text("B"), // Buzz, buzz! /// ), /// ), diff --git a/packages/flutter/lib/src/cupertino/refresh.dart b/packages/flutter/lib/src/cupertino/refresh.dart index 2d8653bba3..0c2eaf09cf 100644 --- a/packages/flutter/lib/src/cupertino/refresh.dart +++ b/packages/flutter/lib/src/cupertino/refresh.dart @@ -266,16 +266,12 @@ typedef RefreshCallback = Future Function(); /// sliver such as [CupertinoSliverNavigationBar] and your main scrollable /// content's sliver. /// -/// {@tool dartpad --template=stateful_widget_material_no_null_safety} +/// {@tool dartpad --template=stateful_widget_cupertino} /// /// When the user scrolls past [refreshTriggerPullDistance], /// this sample shows the default iOS pull to refresh indicator for 1 second and /// adds a new item to the top of the list view. /// -/// ```dart imports -/// import 'package:flutter/cupertino.dart'; -/// ``` -/// /// ```dart /// List colors = [ /// CupertinoColors.systemYellow, diff --git a/packages/flutter/lib/src/widgets/app.dart b/packages/flutter/lib/src/widgets/app.dart index 3cf1fb7e01..083c8219c6 100644 --- a/packages/flutter/lib/src/widgets/app.dart +++ b/packages/flutter/lib/src/widgets/app.dart @@ -30,9 +30,6 @@ import 'widget_inspector.dart'; export 'dart:ui' show Locale; -// Examples can assume: -// // @dart = 2.9 - /// The signature of [WidgetsApp.localeListResolutionCallback]. /// /// A [LocaleListResolutionCallback] is responsible for computing the locale of the app's @@ -883,7 +880,7 @@ class WidgetsApp extends StatefulWidget { /// LogicalKeySet(LogicalKeyboardKey.select): const ActivateIntent(), /// }, /// color: const Color(0xFFFF0000), - /// builder: (BuildContext context, Widget child) { + /// builder: (BuildContext context, Widget? child) { /// return const Placeholder(); /// }, /// ); @@ -937,7 +934,7 @@ class WidgetsApp extends StatefulWidget { /// ), /// }, /// color: const Color(0xFFFF0000), - /// builder: (BuildContext context, Widget child) { + /// builder: (BuildContext context, Widget? child) { /// return const Placeholder(); /// }, /// ); diff --git a/packages/flutter/lib/src/widgets/binding.dart b/packages/flutter/lib/src/widgets/binding.dart index 9bb56477dd..6723cb663e 100644 --- a/packages/flutter/lib/src/widgets/binding.dart +++ b/packages/flutter/lib/src/widgets/binding.dart @@ -21,9 +21,6 @@ import 'widget_inspector.dart'; export 'dart:ui' show AppLifecycleState, Locale; -// Examples can assume: -// // @dart = 2.9 - /// Interface for classes that register with the Widgets layer binding. /// /// When used as a mixin, provides no-op method implementations. @@ -43,7 +40,7 @@ export 'dart:ui' show AppLifecycleState, Locale; /// /// ```dart /// class AppLifecycleReactor extends StatefulWidget { -/// const AppLifecycleReactor({ Key key }) : super(key: key); +/// const AppLifecycleReactor({ Key? key }) : super(key: key); /// /// @override /// _AppLifecycleReactorState createState() => _AppLifecycleReactorState(); @@ -53,16 +50,16 @@ export 'dart:ui' show AppLifecycleState, Locale; /// @override /// void initState() { /// super.initState(); -/// WidgetsBinding.instance.addObserver(this); +/// WidgetsBinding.instance!.addObserver(this); /// } /// /// @override /// void dispose() { -/// WidgetsBinding.instance.removeObserver(this); +/// WidgetsBinding.instance!.removeObserver(this); /// super.dispose(); /// } /// -/// AppLifecycleState _notification; +/// late AppLifecycleState _notification; /// /// @override /// void didChangeAppLifecycleState(AppLifecycleState state) { @@ -138,31 +135,31 @@ abstract class WidgetsBindingObserver { /// /// ```dart /// class MetricsReactor extends StatefulWidget { - /// const MetricsReactor({ Key key }) : super(key: key); + /// const MetricsReactor({ Key? key }) : super(key: key); /// /// @override /// _MetricsReactorState createState() => _MetricsReactorState(); /// } /// /// class _MetricsReactorState extends State with WidgetsBindingObserver { - /// Size _lastSize; + /// late Size _lastSize; /// /// @override /// void initState() { /// super.initState(); - /// _lastSize = WidgetsBinding.instance.window.physicalSize; - /// WidgetsBinding.instance.addObserver(this); + /// _lastSize = WidgetsBinding.instance!.window.physicalSize; + /// WidgetsBinding.instance!.addObserver(this); /// } /// /// @override /// void dispose() { - /// WidgetsBinding.instance.removeObserver(this); + /// WidgetsBinding.instance!.removeObserver(this); /// super.dispose(); /// } /// /// @override /// void didChangeMetrics() { - /// setState(() { _lastSize = WidgetsBinding.instance.window.physicalSize; }); + /// setState(() { _lastSize = WidgetsBinding.instance!.window.physicalSize; }); /// } /// /// @override @@ -196,7 +193,7 @@ abstract class WidgetsBindingObserver { /// /// ```dart /// class TextScaleFactorReactor extends StatefulWidget { - /// const TextScaleFactorReactor({ Key key }) : super(key: key); + /// const TextScaleFactorReactor({ Key? key }) : super(key: key); /// /// @override /// _TextScaleFactorReactorState createState() => _TextScaleFactorReactorState(); @@ -206,20 +203,20 @@ abstract class WidgetsBindingObserver { /// @override /// void initState() { /// super.initState(); - /// WidgetsBinding.instance.addObserver(this); + /// WidgetsBinding.instance!.addObserver(this); /// } /// /// @override /// void dispose() { - /// WidgetsBinding.instance.removeObserver(this); + /// WidgetsBinding.instance!.removeObserver(this); /// super.dispose(); /// } /// - /// double _lastTextScaleFactor; + /// late double _lastTextScaleFactor; /// /// @override /// void didChangeTextScaleFactor() { - /// setState(() { _lastTextScaleFactor = WidgetsBinding.instance.window.textScaleFactor; }); + /// setState(() { _lastTextScaleFactor = WidgetsBinding.instance!.window.textScaleFactor; }); /// } /// /// @override diff --git a/packages/flutter/lib/src/widgets/scroll_view.dart b/packages/flutter/lib/src/widgets/scroll_view.dart index 32daf1d2a2..cf786686d3 100644 --- a/packages/flutter/lib/src/widgets/scroll_view.dart +++ b/packages/flutter/lib/src/widgets/scroll_view.dart @@ -23,8 +23,7 @@ import 'sliver.dart'; import 'viewport.dart'; // Examples can assume: -// // @dart = 2.9 -// int itemCount; +// late int itemCount; /// A representation of how a [ScrollView] should dismiss the on-screen /// keyboard. @@ -468,7 +467,7 @@ abstract class ScrollView extends StatelessWidget { /// ``` /// {@end-tool} /// -/// {@tool dartpad --template=stateful_widget_material_no_null_safety} +/// {@tool dartpad --template=stateful_widget_material} /// /// By default, if items are inserted at the "top" of a scrolling container like /// [ListView] or [CustomScrollView], the top item and all of the items below it @@ -1335,7 +1334,7 @@ class ListView extends BoxScrollView { /// }, /// childCount: items.length, /// findChildIndexCallback: (Key key) { - /// final ValueKey valueKey = key; + /// final ValueKey valueKey = key as ValueKey; /// final String data = valueKey.value; /// return items.indexOf(data); /// } @@ -1358,7 +1357,10 @@ class ListView extends BoxScrollView { /// } /// /// class KeepAlive extends StatefulWidget { - /// const KeepAlive({Key key, this.data}) : super(key: key); + /// const KeepAlive({ + /// required Key key, + /// required this.data, + /// }) : super(key: key); /// /// final String data; /// diff --git a/packages/flutter/lib/src/widgets/sliver.dart b/packages/flutter/lib/src/widgets/sliver.dart index 185859e0c3..f15d25b149 100644 --- a/packages/flutter/lib/src/widgets/sliver.dart +++ b/packages/flutter/lib/src/widgets/sliver.dart @@ -17,8 +17,7 @@ export 'package:flutter/rendering.dart' show SliverGridDelegateWithMaxCrossAxisExtent; // Examples can assume: -// // @dart = 2.9 -// SliverGridDelegateWithMaxCrossAxisExtent _gridDelegate; +// late SliverGridDelegateWithMaxCrossAxisExtent _gridDelegate; /// A callback which produces a semantic index given a widget and the local index. /// diff --git a/packages/flutter/lib/src/widgets/will_pop_scope.dart b/packages/flutter/lib/src/widgets/will_pop_scope.dart index 7c96284017..c1cf59c66d 100644 --- a/packages/flutter/lib/src/widgets/will_pop_scope.dart +++ b/packages/flutter/lib/src/widgets/will_pop_scope.dart @@ -29,7 +29,7 @@ import 'routes.dart'; /// ``` /// {@end-tool} /// -/// {@tool dartpad --template=stateful_widget_material_no_null_safety} +/// {@tool dartpad --template=stateful_widget_material} /// ```dart /// bool shouldPop = true; /// @override