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 {
/// 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<FollowCurve2D> 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<double> animation;
/// late Animation<double> 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!
/// ),
/// ),
......
......@@ -266,16 +266,12 @@ typedef RefreshCallback = Future<void> 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<Color> colors = [
/// CupertinoColors.systemYellow,
......
......@@ -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();
/// },
/// );
......
......@@ -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<MetricsReactor> 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
......
......@@ -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;
///
......
......@@ -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.
///
......
......@@ -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
......
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