Unverified Commit a6117269 authored by Darren Austin's avatar Darren Austin Committed by GitHub

Migrated some services and widgets doc comments to null safety. (#72792)

parent 6118eaa0
......@@ -58,7 +58,7 @@ abstract class KeyboardKey with Diagnosticable {
/// // The node used to request the keyboard focus.
/// final FocusNode _focusNode = FocusNode();
/// // The message to display.
/// String _message;
/// String? _message;
///
/// // Focus nodes need to be disposed.
/// @override
......@@ -75,7 +75,7 @@ abstract class KeyboardKey with Diagnosticable {
/// _message = 'Pressed the "Q" key!';
/// } else {
/// if (kReleaseMode) {
/// _message = 'Not a Q: Key label is "${event.logicalKey.keyLabel ?? '<none>'}"';
/// _message = 'Not a Q: Key label is "${event.logicalKey.keyLabel}"';
/// } else {
/// // This will only print useful information in debug mode.
/// _message = 'Not a Q: Pressed ${event.logicalKey.debugName}';
......@@ -91,13 +91,13 @@ abstract class KeyboardKey with Diagnosticable {
/// color: Colors.white,
/// alignment: Alignment.center,
/// child: DefaultTextStyle(
/// style: textTheme.headline4,
/// style: textTheme.headline4!,
/// child: RawKeyboardListener(
/// focusNode: _focusNode,
/// onKey: _handleKeyEvent,
/// child: AnimatedBuilder(
/// animation: _focusNode,
/// builder: (BuildContext context, Widget child) {
/// builder: (BuildContext context, Widget? child) {
/// if (!_focusNode.hasFocus) {
/// return GestureDetector(
/// onTap: () {
......@@ -346,7 +346,7 @@ class LogicalKeyboardKey extends KeyboardKey {
/// // The node used to request the keyboard focus.
/// final FocusNode _focusNode = FocusNode();
/// // The message to display.
/// String _message;
/// String? _message;
///
/// // Focus nodes need to be disposed.
/// @override
......@@ -374,13 +374,13 @@ class LogicalKeyboardKey extends KeyboardKey {
/// color: Colors.white,
/// alignment: Alignment.center,
/// child: DefaultTextStyle(
/// style: textTheme.headline4,
/// style: textTheme.headline4!,
/// child: RawKeyboardListener(
/// focusNode: _focusNode,
/// onKey: _handleKeyEvent,
/// child: AnimatedBuilder(
/// animation: _focusNode,
/// builder: (BuildContext context, Widget child) {
/// builder: (BuildContext context, Widget? child) {
/// if (!_focusNode.hasFocus) {
/// return GestureDetector(
/// onTap: () {
......
......@@ -45,7 +45,7 @@ abstract class KeyboardKey with Diagnosticable {
/// look at the physical key to make sure that regardless of the character the
/// key produces, you got the key that is in that location on the keyboard.
///
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
/// {@tool dartpad --template=stateful_widget_scaffold}
/// This example shows how to detect if the user has selected the logical "Q"
/// key.
///
......@@ -58,7 +58,7 @@ abstract class KeyboardKey with Diagnosticable {
/// // The node used to request the keyboard focus.
/// final FocusNode _focusNode = FocusNode();
/// // The message to display.
/// String _message;
/// String? _message;
///
/// // Focus nodes need to be disposed.
/// @override
......@@ -75,7 +75,7 @@ abstract class KeyboardKey with Diagnosticable {
/// _message = 'Pressed the "Q" key!';
/// } else {
/// if (kReleaseMode) {
/// _message = 'Not a Q: Key label is "${event.logicalKey.keyLabel ?? '<none>'}"';
/// _message = 'Not a Q: Key label is "${event.logicalKey.keyLabel}"';
/// } else {
/// // This will only print useful information in debug mode.
/// _message = 'Not a Q: Pressed ${event.logicalKey.debugName}';
......@@ -91,13 +91,13 @@ abstract class KeyboardKey with Diagnosticable {
/// color: Colors.white,
/// alignment: Alignment.center,
/// child: DefaultTextStyle(
/// style: textTheme.headline4,
/// style: textTheme.headline4!,
/// child: RawKeyboardListener(
/// focusNode: _focusNode,
/// onKey: _handleKeyEvent,
/// child: AnimatedBuilder(
/// animation: _focusNode,
/// builder: (BuildContext context, Widget child) {
/// builder: (BuildContext context, Widget? child) {
/// if (!_focusNode.hasFocus) {
/// return GestureDetector(
/// onTap: () {
......@@ -1987,7 +1987,7 @@ class LogicalKeyboardKey extends KeyboardKey {
/// looking for "the key next next to the TAB key", since on a French keyboard,
/// the key next to the TAB key has an "A" on it.
///
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
/// {@tool dartpad --template=stateful_widget_scaffold}
/// This example shows how to detect if the user has selected the physical key
/// to the right of the CAPS LOCK key.
///
......@@ -1999,7 +1999,7 @@ class LogicalKeyboardKey extends KeyboardKey {
/// // The node used to request the keyboard focus.
/// final FocusNode _focusNode = FocusNode();
/// // The message to display.
/// String _message;
/// String? _message;
///
/// // Focus nodes need to be disposed.
/// @override
......@@ -2027,13 +2027,13 @@ class LogicalKeyboardKey extends KeyboardKey {
/// color: Colors.white,
/// alignment: Alignment.center,
/// child: DefaultTextStyle(
/// style: textTheme.headline4,
/// style: textTheme.headline4!,
/// child: RawKeyboardListener(
/// focusNode: _focusNode,
/// onKey: _handleKeyEvent,
/// child: AnimatedBuilder(
/// animation: _focusNode,
/// builder: (BuildContext context, Widget child) {
/// builder: (BuildContext context, Widget? child) {
/// if (!_focusNode.hasFocus) {
/// return GestureDetector(
/// onTap: () {
......
......@@ -12,9 +12,6 @@ import 'binding.dart';
import 'message_codec.dart';
import 'message_codecs.dart';
// Examples can assume:
// // @dart = 2.9
/// A named channel for communicating with platform plugins using asynchronous
/// message passing.
///
......@@ -196,9 +193,9 @@ class MethodChannel {
/// static const MethodChannel _channel = MethodChannel('music');
///
/// static Future<bool> isLicensed() async {
/// // invokeMethod returns a Future<T> which can be inferred as bool
/// // in this context.
/// return _channel.invokeMethod('isLicensed');
/// // invokeMethod returns a Future<T?>, so we handle the case where
/// // the return value is null by treating null as false.
/// return _channel.invokeMethod<bool>('isLicensed').then<bool>((bool? value) => value ?? false);
/// }
///
/// static Future<List<Song>> songs() async {
......
......@@ -344,7 +344,7 @@ class SystemChrome {
/// navigation bar and synthesize them into a single style. This can be used
/// to configure the system styles when an app bar is not used.
///
/// {@tool sample --template=stateful_widget_material_no_null_safety}
/// {@tool sample --template=stateful_widget_material}
/// The following example creates a widget that changes the status bar color
/// to a random value on Android.
///
......
......@@ -11,8 +11,7 @@ import 'ticker_provider.dart';
import 'transitions.dart';
// Examples can assume:
// // @dart = 2.9
// bool _first;
// bool _first = false;
/// Specifies which of two children to show. See [AnimatedCrossFade].
///
......
This diff is collapsed.
......@@ -48,11 +48,10 @@ export 'package:flutter/gestures.dart' show
export 'package:flutter/rendering.dart' show RenderSemanticsGestureHandler;
// Examples can assume:
// // @dart = 2.9
// bool _lights;
// late bool _lights;
// void setState(VoidCallback fn) { }
// String _last;
// Color _color;
// late String _last;
// late Color _color;
/// Factory for creating gesture recognizers.
///
......@@ -1045,8 +1044,8 @@ class RawGestureDetector extends StatefulWidget {
/// ```dart
/// class ForcePressGestureDetectorWithSemantics extends StatelessWidget {
/// const ForcePressGestureDetectorWithSemantics({
/// this.child,
/// this.onForcePress,
/// required this.child,
/// required this.onForcePress,
/// });
///
/// final Widget child;
......
......@@ -762,7 +762,7 @@ class Image extends StatefulWidget {
/// ```
/// {@endtemplate}
///
/// {@tool dartpad --template=stateless_widget_material_no_null_safety}
/// {@tool dartpad --template=stateless_widget_material}
///
/// The following sample demonstrates how to use this builder to implement an
/// image that fades in once it's been loaded.
......@@ -781,8 +781,8 @@ class Image extends StatefulWidget {
/// ),
/// child: Image.network(
/// 'https://flutter.github.io/assets-for-api-docs/assets/widgets/puffin.jpg',
/// frameBuilder: (BuildContext context, Widget child, int frame, bool wasSynchronouslyLoaded) {
/// if (wasSynchronouslyLoaded) {
/// frameBuilder: (BuildContext context, Widget child, int? frame, bool? wasSynchronouslyLoaded) {
/// if (wasSynchronouslyLoaded ?? false) {
/// return child;
/// }
/// return AnimatedOpacity(
......@@ -828,7 +828,7 @@ class Image extends StatefulWidget {
///
/// {@macro flutter.widgets.Image.frameBuilder.chainedBuildersExample}
///
/// {@tool dartpad --template=stateless_widget_material_no_null_safety}
/// {@tool dartpad --template=stateless_widget_material}
///
/// The following sample uses [loadingBuilder] to show a
/// [CircularProgressIndicator] while an image loads over the network.
......@@ -843,13 +843,13 @@ class Image extends StatefulWidget {
/// ),
/// child: Image.network(
/// 'https://example.com/image.jpg',
/// loadingBuilder: (BuildContext context, Widget child, ImageChunkEvent loadingProgress) {
/// loadingBuilder: (BuildContext context, Widget child, ImageChunkEvent? loadingProgress) {
/// if (loadingProgress == null)
/// return child;
/// return Center(
/// child: CircularProgressIndicator(
/// value: loadingProgress.expectedTotalBytes != null
/// ? loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes
/// ? loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes!
/// : null,
/// ),
/// );
......@@ -873,7 +873,7 @@ class Image extends StatefulWidget {
/// [FlutterError.onError]. If it is provided, the caller should either handle
/// the exception by providing a replacement widget, or rethrow the exception.
///
/// {@tool dartpad --template=stateless_widget_material_no_null_safety}
/// {@tool dartpad --template=stateless_widget_material}
///
/// The following sample uses [errorBuilder] to show a '😢' in place of the
/// image that fails to load, and prints the error to the console.
......@@ -888,7 +888,7 @@ class Image extends StatefulWidget {
/// ),
/// child: Image.network(
/// 'https://example.does.not.exist/image.jpg',
/// errorBuilder: (BuildContext context, Object exception, StackTrace stackTrace) {
/// errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
/// // Appropriate logging or analytics, e.g.
/// // myAnalytics.recordError(
/// // 'An error occurred loading "https://example.does.not.exist/image.jpg"',
......
......@@ -19,7 +19,6 @@ import 'ticker_provider.dart';
import 'transitions.dart';
// Examples can assume:
// // @dart = 2.9
// class MyWidget extends ImplicitlyAnimatedWidget {
// MyWidget() : super(duration: const Duration(seconds: 1));
// final Color targetColor = Colors.black;
......@@ -480,14 +479,14 @@ abstract class ImplicitlyAnimatedWidgetState<T extends ImplicitlyAnimatedWidget>
///
/// ```dart
/// class MyWidgetState extends AnimatedWidgetBaseState<MyWidget> {
/// ColorTween _colorTween;
/// ColorTween? _colorTween;
///
/// @override
/// Widget build(BuildContext context) {
/// return Text(
/// 'Hello World',
/// // Computes the value of the text color at any given time.
/// style: TextStyle(color: _colorTween.evaluate(animation)),
/// style: TextStyle(color: _colorTween?.evaluate(animation)),
/// );
/// }
///
......@@ -502,7 +501,7 @@ abstract class ImplicitlyAnimatedWidgetState<T extends ImplicitlyAnimatedWidget>
/// // A function that takes a color value and returns a tween
/// // beginning at that value.
/// (value) => ColorTween(begin: value),
/// );
/// ) as ColorTween?;
///
/// // We could have more tweens than one by using the visitor
/// // multiple times.
......@@ -573,7 +572,7 @@ abstract class AnimatedWidgetBaseState<T extends ImplicitlyAnimatedWidget> exten
///
/// {@youtube 560 315 https://www.youtube.com/watch?v=yI-8QHpGIP4}
///
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
/// {@tool dartpad --template=stateful_widget_scaffold}
///
/// The following example (depicted above) transitions an AnimatedContainer
/// between two states. It adjusts the `height`, `width`, `color`, and
......@@ -812,7 +811,7 @@ class _AnimatedContainerState extends AnimatedWidgetBaseState<AnimatedContainer>
/// of [Curves.fastOutSlowIn].
/// {@animation 250 266 https://flutter.github.io/assets-for-api-docs/assets/widgets/animated_padding.mp4}
///
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
/// {@tool dartpad --template=stateful_widget_scaffold}
///
/// The following code implements the [AnimatedPadding] widget, using a [curve] of
/// [Curves.easeInOut].
......@@ -933,7 +932,7 @@ class _AnimatedPaddingState extends AnimatedWidgetBaseState<AnimatedPadding> {
/// it also requires more development overhead as you have to manually manage
/// the lifecycle of the underlying [AnimationController].
///
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
/// {@tool dartpad --template=stateful_widget_scaffold}
///
/// The following code implements the [AnimatedAlign] widget, using a [curve] of
/// [Curves.fastOutSlowIn].
......@@ -1098,7 +1097,7 @@ class _AnimatedAlignState extends AnimatedWidgetBaseState<AnimatedAlign> {
/// it also requires more development overhead as you have to manually manage
/// the lifecycle of the underlying [AnimationController].
///
/// {@tool dartpad --template=stateful_widget_scaffold_center_no_null_safety}
/// {@tool dartpad --template=stateful_widget_scaffold_center}
///
/// The following example transitions an AnimatedPositioned
/// between two states. It adjusts the `height`, `width`, and
......@@ -1550,7 +1549,7 @@ class _AnimatedOpacityState extends ImplicitlyAnimatedWidgetState<AnimatedOpacit
/// Here's an illustration of what using this widget looks like, using a [curve]
/// of [Curves.fastOutSlowIn].
///
/// {@tool dartpad --template=stateful_widget_scaffold_center_freeform_state_no_null_safety}
/// {@tool dartpad --template=stateful_widget_scaffold_center_freeform_state}
/// Creates a [CustomScrollView] with a [SliverFixedExtentList] and a
/// [FloatingActionButton]. Pressing the button animates the lists' opacity.
///
......
......@@ -10,9 +10,6 @@ import 'package:flutter/services.dart';
import 'editable_text.dart';
import 'restoration.dart';
// Examples can assume:
// // @dart = 2.9
/// A [RestorableProperty] that makes the wrapped value accessible to the owning
/// [State] object via the [value] getter and setter.
///
......@@ -22,7 +19,7 @@ import 'restoration.dart';
///
/// ## Using a RestorableValue
///
/// {@tool dartpad --template=stateful_widget_restoration_no_null_safety}
/// {@tool dartpad --template=stateful_widget_restoration}
/// A [StatefulWidget] that has a restorable [int] property.
///
/// ```dart
......@@ -33,7 +30,7 @@ import 'restoration.dart';
/// RestorableInt _answer = RestorableInt(42);
///
/// @override
/// void restoreState(RestorationBucket oldBucket, bool initialRestore) {
/// void restoreState(RestorationBucket? oldBucket, bool initialRestore) {
/// // All restorable properties must be registered with the mixin. After
/// // registration, the answer either has its old value restored or is
/// // initialized to its default value.
......@@ -77,15 +74,18 @@ import 'restoration.dart';
/// Duration createDefaultValue() => const Duration();
///
/// @override
/// void didUpdateValue(Duration oldValue) {
/// if (oldValue.inMicroseconds != value.inMicroseconds)
/// void didUpdateValue(Duration? oldValue) {
/// if (oldValue == null || oldValue.inMicroseconds != value.inMicroseconds)
/// notifyListeners();
/// }
///
/// @override
/// Duration fromPrimitives(Object data) {
/// Duration fromPrimitives(Object? data) {
/// if (data != null) {
/// return Duration(microseconds: data as int);
/// }
/// return const Duration();
/// }
///
/// @override
/// Object toPrimitives() {
......
......@@ -24,9 +24,8 @@ import 'scroll_controller.dart';
import 'transitions.dart';
// Examples can assume:
// // @dart = 2.9
// dynamic routeObserver;
// NavigatorState navigator;
// late NavigatorState navigator;
/// A route that displays widgets in the [Navigator]'s [Overlay].
abstract class OverlayRoute<T> extends Route<T> {
......@@ -541,7 +540,7 @@ mixin LocalHistoryRoute<T> on Route<T> {
/// // rectangle. When this local history entry is removed, we hide the red
/// // rectangle.
/// setState(() => _showRectangle = true);
/// ModalRoute.of(context).addLocalHistoryEntry(
/// ModalRoute.of(context)?.addLocalHistoryEntry(
/// LocalHistoryEntry(
/// onRemove: () {
/// // Hide the red rectangle.
......
......@@ -13,8 +13,7 @@ import 'inherited_theme.dart';
import 'media_query.dart';
// Examples can assume:
// // @dart = 2.9
// String _name;
// late String _name;
/// The text style to apply to descendant [Text] widgets which don't have an
/// explicit style.
......
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