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 {
/// widget, and the new control should be enabled for keyboard traversal and
/// 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
/// 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
......@@ -813,7 +813,11 @@ class _ActionsMarker extends InheritedWidget {
///
/// ```dart preamble
/// 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 Widget child;
......@@ -826,8 +830,8 @@ class _ActionsMarker extends InheritedWidget {
/// bool _focused = false;
/// bool _hovering = false;
/// bool _on = false;
/// Map<Type, Action<Intent>> _actionMap;
/// Map<LogicalKeySet, Intent> _shortcutMap;
/// late Map<Type, Action<Intent>> _actionMap;
/// late Map<LogicalKeySet, Intent> _shortcutMap;
///
/// @override
/// void initState() {
......
......@@ -12,11 +12,6 @@ import 'package:flutter/foundation.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
/// a specified [Stream].
///
......@@ -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
/// 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
/// 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
///
/// Widget build(BuildContext context) {
/// return DefaultTextStyle(
/// style: Theme.of(context).textTheme.headline2,
/// style: Theme.of(context).textTheme.headline2!,
/// textAlign: TextAlign.center,
/// child: Container(
/// alignment: FractionalOffset.center,
......@@ -614,7 +609,7 @@ class StreamBuilder<T> extends StreamBuilderBase<T, AsyncSnapshot<T>> {
/// `future?.asStream()`, except that snapshots with `ConnectionState.active`
/// 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
/// 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>> {
///
/// Widget build(BuildContext context) {
/// return DefaultTextStyle(
/// style: Theme.of(context).textTheme.headline2,
/// style: Theme.of(context).textTheme.headline2!,
/// textAlign: TextAlign.center,
/// child: FutureBuilder<String>(
/// future: _calculation, // a previously-obtained Future<String> or null
......
......@@ -16,7 +16,7 @@ import 'will_pop_scope.dart';
/// with a context whose ancestor is the [Form], or pass a [GlobalKey] to the
/// [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
/// address and an [ElevatedButton] to submit the form. A [GlobalKey] is used here
/// to identify the [Form] and validate input.
......@@ -38,7 +38,7 @@ import 'will_pop_scope.dart';
/// hintText: 'Enter your email',
/// ),
/// validator: (value) {
/// if (value.isEmpty) {
/// if (value!.isEmpty) {
/// return 'Please enter some text';
/// }
/// return null;
......@@ -50,7 +50,7 @@ import 'will_pop_scope.dart';
/// onPressed: () {
/// // Validate will return true if the form is valid, or false if
/// // the form is invalid.
/// if (_formKey.currentState.validate()) {
/// if (_formKey.currentState!.validate()) {
/// // Process data.
/// }
/// },
......
......@@ -136,7 +136,7 @@ class PageStorageBucket {
/// you should give each of them unique [PageStorageKey]s, or set some of their
/// `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
/// store the states of its children pages. Each page includes a scrollable
......@@ -212,7 +212,7 @@ class PageStorageBucket {
///
/// class ColorBoxPage extends StatelessWidget {
/// ColorBoxPage({
/// Key key,
/// Key? key,
/// }) : super(key: key);
///
/// @override
......
......@@ -80,7 +80,7 @@ import 'scrollable.dart';
/// with some remaining space to allocate as specified by its
/// [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
/// room, in which case they stack vertically and scroll.
///
......@@ -91,7 +91,7 @@ import 'scrollable.dart';
/// ```dart
/// Widget build(BuildContext context) {
/// return DefaultTextStyle(
/// style: Theme.of(context).textTheme.bodyText2,
/// style: Theme.of(context).textTheme.bodyText2!,
/// child: LayoutBuilder(
/// builder: (BuildContext context, BoxConstraints viewportConstraints) {
/// return SingleChildScrollView(
......@@ -154,14 +154,14 @@ import 'scrollable.dart';
/// so that the intrinsic sizing algorithm can short-circuit the computation when it
/// 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
/// the contents, whichever is biggest.
///
/// ```dart
/// Widget build(BuildContext context) {
/// return DefaultTextStyle(
/// style: Theme.of(context).textTheme.bodyText2,
/// style: Theme.of(context).textTheme.bodyText2!,
/// child: LayoutBuilder(
/// builder: (BuildContext context, BoxConstraints viewportConstraints) {
/// return SingleChildScrollView(
......
......@@ -61,7 +61,7 @@ import 'value_listenable_builder.dart';
///
/// ## 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
/// 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
......@@ -75,11 +75,11 @@ import 'value_listenable_builder.dart';
/// return TweenAnimationBuilder(
/// tween: Tween<double>(begin: 0, end: targetValue),
/// duration: Duration(seconds: 1),
/// builder: (BuildContext context, double size, Widget child) {
/// builder: (BuildContext context, double size, Widget? child) {
/// return IconButton(
/// iconSize: size,
/// color: Colors.blue,
/// icon: child,
/// icon: child!,
/// onPressed: () {
/// setState(() {
/// 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