Unverified Commit b21e08c8 authored by Shi-Hao Hong's avatar Shi-Hao Hong Committed by GitHub

[NNBD] Migrate sample code pt 4 (#72842)

parent 691d05da
...@@ -795,7 +795,7 @@ class _ActionsMarker extends InheritedWidget { ...@@ -795,7 +795,7 @@ class _ActionsMarker extends InheritedWidget {
/// widget, and the new control should be enabled for keyboard traversal and /// widget, and the new control should be enabled for keyboard traversal and
/// activation. /// activation.
/// ///
/// {@tool dartpad --template=stateful_widget_material_no_null_safety} /// {@tool dartpad --template=stateful_widget_material}
/// This example shows how keyboard interaction can be added to a custom control /// This example shows how keyboard interaction can be added to a custom control
/// that changes color when hovered and focused, and can toggle a light when /// that changes color when hovered and focused, and can toggle a light when
/// activated, either by touch or by hitting the `X` key on the keyboard when /// activated, either by touch or by hitting the `X` key on the keyboard when
...@@ -813,7 +813,11 @@ class _ActionsMarker extends InheritedWidget { ...@@ -813,7 +813,11 @@ class _ActionsMarker extends InheritedWidget {
/// ///
/// ```dart preamble /// ```dart preamble
/// class FadButton extends StatefulWidget { /// class FadButton extends StatefulWidget {
/// const FadButton({Key key, this.onPressed, this.child}) : super(key: key); /// const FadButton({
/// Key? key,
/// required this.onPressed,
/// required this.child,
/// }) : super(key: key);
/// ///
/// final VoidCallback onPressed; /// final VoidCallback onPressed;
/// final Widget child; /// final Widget child;
...@@ -826,8 +830,8 @@ class _ActionsMarker extends InheritedWidget { ...@@ -826,8 +830,8 @@ class _ActionsMarker extends InheritedWidget {
/// bool _focused = false; /// bool _focused = false;
/// bool _hovering = false; /// bool _hovering = false;
/// bool _on = false; /// bool _on = false;
/// Map<Type, Action<Intent>> _actionMap; /// late Map<Type, Action<Intent>> _actionMap;
/// Map<LogicalKeySet, Intent> _shortcutMap; /// late Map<LogicalKeySet, Intent> _shortcutMap;
/// ///
/// @override /// @override
/// void initState() { /// void initState() {
......
...@@ -12,11 +12,6 @@ import 'package:flutter/foundation.dart'; ...@@ -12,11 +12,6 @@ import 'package:flutter/foundation.dart';
import 'framework.dart'; import 'framework.dart';
// Examples can assume:
// // @dart = 2.9
// dynamic _lot;
// Future<String> _calculation;
/// Base class for widgets that build themselves based on interaction with /// Base class for widgets that build themselves based on interaction with
/// a specified [Stream]. /// a specified [Stream].
/// ///
...@@ -371,7 +366,7 @@ typedef AsyncWidgetBuilder<T> = Widget Function(BuildContext context, AsyncSnaps ...@@ -371,7 +366,7 @@ typedef AsyncWidgetBuilder<T> = Widget Function(BuildContext context, AsyncSnaps
/// as the builder will always be called before the stream listener has a chance /// as the builder will always be called before the stream listener has a chance
/// to be processed. /// to be processed.
/// ///
/// {@tool dartpad --template=stateful_widget_material_no_null_safety} /// {@tool dartpad --template=stateful_widget_material}
/// ///
/// This sample shows a [StreamBuilder] that listens to a Stream that emits bids /// This sample shows a [StreamBuilder] that listens to a Stream that emits bids
/// for an auction. Every time the StreamBuilder receives a bid from the Stream, /// for an auction. Every time the StreamBuilder receives a bid from the Stream,
...@@ -388,7 +383,7 @@ typedef AsyncWidgetBuilder<T> = Widget Function(BuildContext context, AsyncSnaps ...@@ -388,7 +383,7 @@ typedef AsyncWidgetBuilder<T> = Widget Function(BuildContext context, AsyncSnaps
/// ///
/// Widget build(BuildContext context) { /// Widget build(BuildContext context) {
/// return DefaultTextStyle( /// return DefaultTextStyle(
/// style: Theme.of(context).textTheme.headline2, /// style: Theme.of(context).textTheme.headline2!,
/// textAlign: TextAlign.center, /// textAlign: TextAlign.center,
/// child: Container( /// child: Container(
/// alignment: FractionalOffset.center, /// alignment: FractionalOffset.center,
...@@ -614,7 +609,7 @@ class StreamBuilder<T> extends StreamBuilderBase<T, AsyncSnapshot<T>> { ...@@ -614,7 +609,7 @@ class StreamBuilder<T> extends StreamBuilderBase<T, AsyncSnapshot<T>> {
/// `future?.asStream()`, except that snapshots with `ConnectionState.active` /// `future?.asStream()`, except that snapshots with `ConnectionState.active`
/// may appear for the latter, depending on how the stream is implemented. /// may appear for the latter, depending on how the stream is implemented.
/// ///
/// {@tool dartpad --template=stateful_widget_material_no_null_safety} /// {@tool dartpad --template=stateful_widget_material}
/// ///
/// This sample shows a [FutureBuilder] that displays a loading spinner while it /// This sample shows a [FutureBuilder] that displays a loading spinner while it
/// loads data. It displays a success icon and text if the [Future] completes /// loads data. It displays a success icon and text if the [Future] completes
...@@ -630,7 +625,7 @@ class StreamBuilder<T> extends StreamBuilderBase<T, AsyncSnapshot<T>> { ...@@ -630,7 +625,7 @@ class StreamBuilder<T> extends StreamBuilderBase<T, AsyncSnapshot<T>> {
/// ///
/// Widget build(BuildContext context) { /// Widget build(BuildContext context) {
/// return DefaultTextStyle( /// return DefaultTextStyle(
/// style: Theme.of(context).textTheme.headline2, /// style: Theme.of(context).textTheme.headline2!,
/// textAlign: TextAlign.center, /// textAlign: TextAlign.center,
/// child: FutureBuilder<String>( /// child: FutureBuilder<String>(
/// future: _calculation, // a previously-obtained Future<String> or null /// future: _calculation, // a previously-obtained Future<String> or null
......
...@@ -16,7 +16,7 @@ import 'will_pop_scope.dart'; ...@@ -16,7 +16,7 @@ import 'will_pop_scope.dart';
/// with a context whose ancestor is the [Form], or pass a [GlobalKey] to the /// with a context whose ancestor is the [Form], or pass a [GlobalKey] to the
/// [Form] constructor and call [GlobalKey.currentState]. /// [Form] constructor and call [GlobalKey.currentState].
/// ///
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety} /// {@tool dartpad --template=stateful_widget_scaffold}
/// This example shows a [Form] with one [TextFormField] to enter an email /// This example shows a [Form] with one [TextFormField] to enter an email
/// address and an [ElevatedButton] to submit the form. A [GlobalKey] is used here /// address and an [ElevatedButton] to submit the form. A [GlobalKey] is used here
/// to identify the [Form] and validate input. /// to identify the [Form] and validate input.
...@@ -38,7 +38,7 @@ import 'will_pop_scope.dart'; ...@@ -38,7 +38,7 @@ import 'will_pop_scope.dart';
/// hintText: 'Enter your email', /// hintText: 'Enter your email',
/// ), /// ),
/// validator: (value) { /// validator: (value) {
/// if (value.isEmpty) { /// if (value!.isEmpty) {
/// return 'Please enter some text'; /// return 'Please enter some text';
/// } /// }
/// return null; /// return null;
...@@ -50,7 +50,7 @@ import 'will_pop_scope.dart'; ...@@ -50,7 +50,7 @@ import 'will_pop_scope.dart';
/// onPressed: () { /// onPressed: () {
/// // Validate will return true if the form is valid, or false if /// // Validate will return true if the form is valid, or false if
/// // the form is invalid. /// // the form is invalid.
/// if (_formKey.currentState.validate()) { /// if (_formKey.currentState!.validate()) {
/// // Process data. /// // Process data.
/// } /// }
/// }, /// },
......
...@@ -136,7 +136,7 @@ class PageStorageBucket { ...@@ -136,7 +136,7 @@ class PageStorageBucket {
/// you should give each of them unique [PageStorageKey]s, or set some of their /// you should give each of them unique [PageStorageKey]s, or set some of their
/// `keepScrollOffset` false to prevent saving. /// `keepScrollOffset` false to prevent saving.
/// ///
/// {@tool dartpad --template=freeform_no_null_safety} /// {@tool dartpad --template=freeform}
/// ///
/// This sample shows how to explicitly use a [PageStorage] to /// This sample shows how to explicitly use a [PageStorage] to
/// store the states of its children pages. Each page includes a scrollable /// store the states of its children pages. Each page includes a scrollable
...@@ -212,7 +212,7 @@ class PageStorageBucket { ...@@ -212,7 +212,7 @@ class PageStorageBucket {
/// ///
/// class ColorBoxPage extends StatelessWidget { /// class ColorBoxPage extends StatelessWidget {
/// ColorBoxPage({ /// ColorBoxPage({
/// Key key, /// Key? key,
/// }) : super(key: key); /// }) : super(key: key);
/// ///
/// @override /// @override
......
...@@ -80,7 +80,7 @@ import 'scrollable.dart'; ...@@ -80,7 +80,7 @@ import 'scrollable.dart';
/// with some remaining space to allocate as specified by its /// with some remaining space to allocate as specified by its
/// [Column.mainAxisAlignment] argument. /// [Column.mainAxisAlignment] argument.
/// ///
/// {@tool dartpad --template=stateless_widget_material_no_null_safety} /// {@tool dartpad --template=stateless_widget_material}
/// In this example, the children are spaced out equally, unless there's no more /// In this example, the children are spaced out equally, unless there's no more
/// room, in which case they stack vertically and scroll. /// room, in which case they stack vertically and scroll.
/// ///
...@@ -91,7 +91,7 @@ import 'scrollable.dart'; ...@@ -91,7 +91,7 @@ import 'scrollable.dart';
/// ```dart /// ```dart
/// Widget build(BuildContext context) { /// Widget build(BuildContext context) {
/// return DefaultTextStyle( /// return DefaultTextStyle(
/// style: Theme.of(context).textTheme.bodyText2, /// style: Theme.of(context).textTheme.bodyText2!,
/// child: LayoutBuilder( /// child: LayoutBuilder(
/// builder: (BuildContext context, BoxConstraints viewportConstraints) { /// builder: (BuildContext context, BoxConstraints viewportConstraints) {
/// return SingleChildScrollView( /// return SingleChildScrollView(
...@@ -154,14 +154,14 @@ import 'scrollable.dart'; ...@@ -154,14 +154,14 @@ import 'scrollable.dart';
/// so that the intrinsic sizing algorithm can short-circuit the computation when it /// so that the intrinsic sizing algorithm can short-circuit the computation when it
/// reaches those parts of the subtree. /// reaches those parts of the subtree.
/// ///
/// {@tool dartpad --template=stateless_widget_material_no_null_safety} /// {@tool dartpad --template=stateless_widget_material}
/// In this example, the column becomes either as big as viewport, or as big as /// In this example, the column becomes either as big as viewport, or as big as
/// the contents, whichever is biggest. /// the contents, whichever is biggest.
/// ///
/// ```dart /// ```dart
/// Widget build(BuildContext context) { /// Widget build(BuildContext context) {
/// return DefaultTextStyle( /// return DefaultTextStyle(
/// style: Theme.of(context).textTheme.bodyText2, /// style: Theme.of(context).textTheme.bodyText2!,
/// child: LayoutBuilder( /// child: LayoutBuilder(
/// builder: (BuildContext context, BoxConstraints viewportConstraints) { /// builder: (BuildContext context, BoxConstraints viewportConstraints) {
/// return SingleChildScrollView( /// return SingleChildScrollView(
......
...@@ -61,7 +61,7 @@ import 'value_listenable_builder.dart'; ...@@ -61,7 +61,7 @@ import 'value_listenable_builder.dart';
/// ///
/// ## Example Code /// ## Example Code
/// ///
/// {@tool dartpad --template=stateful_widget_scaffold_center_no_null_safety} /// {@tool dartpad --template=stateful_widget_scaffold_center}
/// This example shows an [IconButton] that "zooms" in when the widget first /// This example shows an [IconButton] that "zooms" in when the widget first
/// builds (its size smoothly increases from 0 to 24) and whenever the button /// builds (its size smoothly increases from 0 to 24) and whenever the button
/// is pressed, it smoothly changes its size to the new target value of either /// is pressed, it smoothly changes its size to the new target value of either
...@@ -75,11 +75,11 @@ import 'value_listenable_builder.dart'; ...@@ -75,11 +75,11 @@ import 'value_listenable_builder.dart';
/// return TweenAnimationBuilder( /// return TweenAnimationBuilder(
/// tween: Tween<double>(begin: 0, end: targetValue), /// tween: Tween<double>(begin: 0, end: targetValue),
/// duration: Duration(seconds: 1), /// duration: Duration(seconds: 1),
/// builder: (BuildContext context, double size, Widget child) { /// builder: (BuildContext context, double size, Widget? child) {
/// return IconButton( /// return IconButton(
/// iconSize: size, /// iconSize: size,
/// color: Colors.blue, /// color: Colors.blue,
/// icon: child, /// icon: child!,
/// onPressed: () { /// onPressed: () {
/// setState(() { /// setState(() {
/// targetValue = targetValue == 24.0 ? 48.0 : 24.0; /// targetValue = targetValue == 24.0 ? 48.0 : 24.0;
......
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