Unverified Commit 0b024108 authored by Kate Lovett's avatar Kate Lovett Committed by GitHub

Migrate more sample code to nnbd (#72829)

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