Unverified Commit 30718a13 authored by Darren Austin's avatar Darren Austin Committed by GitHub

Migrate some more material doc samples to null safety. (#72303)

parent b9cfe053
......@@ -10,8 +10,7 @@ part of material_animated_icons;
// generic vector graphics support in Flutter.
// Examples can assume:
// // @dart = 2.9
// AnimationController controller;
// late AnimationController controller;
/// Shows an animated icon at a given animation [progress].
///
......
......@@ -18,9 +18,6 @@ import 'page.dart';
import 'scaffold.dart' show ScaffoldMessenger, ScaffoldMessengerState;
import 'theme.dart';
// Examples can assume:
// // @dart = 2.9
/// [MaterialApp] uses this [TextStyle] as its [DefaultTextStyle] to encourage
/// developers to be intentional about their [DefaultTextStyle].
///
......@@ -591,7 +588,7 @@ class MaterialApp extends StatefulWidget {
/// LogicalKeySet(LogicalKeyboardKey.select): const ActivateIntent(),
/// },
/// color: const Color(0xFFFF0000),
/// builder: (BuildContext context, Widget child) {
/// builder: (BuildContext context, Widget? child) {
/// return const Placeholder();
/// },
/// );
......@@ -624,7 +621,7 @@ class MaterialApp extends StatefulWidget {
/// ),
/// },
/// color: const Color(0xFFFF0000),
/// builder: (BuildContext context, Widget child) {
/// builder: (BuildContext context, Widget? child) {
/// return const Placeholder();
/// },
/// );
......
......@@ -91,7 +91,7 @@ class _ToolbarContainerLayout extends SingleChildLayoutDelegate {
/// to false. In that case a null leading widget will result in the middle/title widget
/// stretching to start.
///
/// {@tool dartpad --template=stateless_widget_material_no_null_safety}
/// {@tool dartpad --template=stateless_widget_material}
///
/// This sample shows an [AppBar] with two simple actions. The first action
/// opens a [SnackBar], while the second action navigates to a new page.
......@@ -1262,7 +1262,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
/// ```
/// {@end-tool}
///
/// {@tool dartpad --template=freeform_no_null_safety}
/// {@tool dartpad --template=freeform}
///
/// This sample shows a [SliverAppBar] and it's behaviors when using the [pinned], [snap] and [floating] parameters.
///
......@@ -1274,7 +1274,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
/// void main() => runApp(MyApp());
///
/// class MyApp extends StatefulWidget {
/// const MyApp({Key key}) : super(key: key);
/// const MyApp({Key? key}) : super(key: key);
///
/// @override
/// State<StatefulWidget> createState() => _MyAppState();
......
......@@ -13,8 +13,7 @@ import 'scaffold.dart';
import 'theme.dart';
// Examples can assume:
// // @dart = 2.9
// Widget bottomAppBarContents;
// late Widget bottomAppBarContents;
/// A container that is typically used with [Scaffold.bottomNavigationBar], and
/// can have a notch along the top that makes room for an overlapping
......
......@@ -23,9 +23,6 @@ import 'theme.dart';
import 'theme_data.dart';
import 'tooltip.dart';
// Examples can assume:
// // @dart = 2.9
// Some design constants
const double _kChipHeight = 32.0;
const double _kDeleteIconSize = 18.0;
......@@ -224,7 +221,7 @@ abstract class DeletableChipAttributes {
/// that the user tapped the delete button. In order to delete the chip, you
/// have to do something similar to the following sample:
///
/// {@tool dartpad --template=stateful_widget_scaffold_center_no_null_safety}
/// {@tool dartpad --template=stateful_widget_scaffold_center}
///
/// This sample shows how to use [onDeleted] to remove an entry when the
/// delete button is tapped.
......@@ -926,7 +923,7 @@ class InputChip extends StatelessWidget
/// }
///
/// class _MyThreeOptionsState extends State<MyThreeOptions> {
/// int _value = 1;
/// int? _value = 1;
///
/// @override
/// Widget build(BuildContext context) {
......
......@@ -9,8 +9,7 @@ import 'divider_theme.dart';
import 'theme.dart';
// Examples can assume:
// // @dart = 2.9
// BuildContext context;
// late BuildContext context;
/// A thin horizontal line, with padding on either side.
///
......@@ -25,7 +24,7 @@ import 'theme.dart';
/// The box's total height is controlled by [height]. The appropriate
/// padding is automatically computed from the height.
///
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
/// {@tool dartpad --template=stateless_widget_scaffold}
///
/// This sample shows how to display a Divider between an orange and blue box
/// inside a column. The Divider is 20 logical pixels in height and contains a
......
......@@ -416,7 +416,7 @@ enum ListTileControlAffinity {
/// you're looking for, it's easy to create custom list items with a
/// combination of other widgets, such as [Row]s and [Column]s.
///
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
/// {@tool dartpad --template=stateless_widget_scaffold}
///
/// Here is an example of a custom list item that resembles a YouTube-related
/// video list item created with [Expanded] and [Container] widgets.
......@@ -426,10 +426,10 @@ enum ListTileControlAffinity {
/// ```dart preamble
/// class CustomListItem extends StatelessWidget {
/// const CustomListItem({
/// this.thumbnail,
/// this.title,
/// this.user,
/// this.viewCount,
/// required this.thumbnail,
/// required this.title,
/// required this.user,
/// required this.viewCount,
/// });
///
/// final Widget thumbnail;
......@@ -468,10 +468,10 @@ enum ListTileControlAffinity {
///
/// class _VideoDescription extends StatelessWidget {
/// const _VideoDescription({
/// Key key,
/// this.title,
/// this.user,
/// this.viewCount,
/// Key? key,
/// required this.title,
/// required this.user,
/// required this.viewCount,
/// }) : super(key: key);
///
/// final String title;
......@@ -537,7 +537,7 @@ enum ListTileControlAffinity {
/// ```
/// {@end-tool}
///
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
/// {@tool dartpad --template=stateless_widget_scaffold}
///
/// Here is an example of an article list item with multiline titles and
/// subtitles. It utilizes [Row]s and [Column]s, as well as [Expanded] and
......@@ -548,12 +548,12 @@ enum ListTileControlAffinity {
/// ```dart preamble
/// class _ArticleDescription extends StatelessWidget {
/// _ArticleDescription({
/// Key key,
/// this.title,
/// this.subtitle,
/// this.author,
/// this.publishDate,
/// this.readDuration,
/// Key? key,
/// required this.title,
/// required this.subtitle,
/// required this.author,
/// required this.publishDate,
/// required this.readDuration,
/// }) : super(key: key);
///
/// final String title;
......@@ -623,13 +623,13 @@ enum ListTileControlAffinity {
///
/// class CustomListItemTwo extends StatelessWidget {
/// CustomListItemTwo({
/// Key key,
/// this.thumbnail,
/// this.title,
/// this.subtitle,
/// this.author,
/// this.publishDate,
/// this.readDuration,
/// Key? key,
/// required this.thumbnail,
/// required this.title,
/// required this.subtitle,
/// required this.author,
/// required this.publishDate,
/// required this.readDuration,
/// }) : super(key: key);
///
/// final Widget thumbnail;
......@@ -889,14 +889,14 @@ class ListTile extends StatelessWidget {
/// By default the selected color is the theme's primary color. The selected color
/// can be overridden with a [ListTileTheme].
///
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
/// {@tool dartpad --template=stateful_widget_scaffold}
///
/// Here is an example of using a [StatefulWidget] to keep track of the
/// selected index, and using that to set the `selected` property on the
/// corresponding [ListTile].
///
/// ```dart
/// int _selectedIndex;
/// int _selectedIndex = 0;
///
/// @override
/// Widget build(BuildContext context) {
......
......@@ -179,7 +179,7 @@ class _MaterialStateColor extends MaterialStateColor {
/// To use a [MaterialStateMouseCursor], you should create a subclass of
/// [MaterialStateMouseCursor] and implement the abstract `resolve` method.
///
/// {@tool dartpad --template=stateless_widget_scaffold_center_no_null_safety}
/// {@tool dartpad --template=stateless_widget_scaffold_center}
///
/// This example defines a mouse cursor that resolves to
/// [SystemMouseCursors.forbidden] when its widget is disabled.
......@@ -294,7 +294,7 @@ class _EnabledAndDisabledMouseCursor extends MaterialStateMouseCursor {
/// To use a [MaterialStateBorderSide], you should create a subclass of a
/// [MaterialStateBorderSide] and override the abstract `resolve` method.
///
/// {@tool dartpad --template=stateful_widget_material_no_null_safety}
/// {@tool dartpad --template=stateful_widget_material}
///
/// This example defines a subclass of [MaterialStateBorderSide], that resolves
/// to a red border side when its widget is selected.
......@@ -302,7 +302,7 @@ class _EnabledAndDisabledMouseCursor extends MaterialStateMouseCursor {
/// ```dart preamble
/// class RedSelectedBorderSide extends MaterialStateBorderSide {
/// @override
/// BorderSide resolve(Set<MaterialState> states) {
/// BorderSide? resolve(Set<MaterialState> states) {
/// if (states.contains(MaterialState.selected)) {
/// return BorderSide(
/// width: 1,
......@@ -352,7 +352,7 @@ abstract class MaterialStateBorderSide extends BorderSide implements MaterialSta
/// [OutlinedBorder] and implement [MaterialStateOutlinedBorder]'s abstract
/// `resolve` method.
///
/// {@tool dartpad --template=stateful_widget_material_no_null_safety}
/// {@tool dartpad --template=stateful_widget_material}
///
/// This example defines a subclass of [RoundedRectangleBorder] and an
/// implementation of [MaterialStateOutlinedBorder], that resolves to
......@@ -361,7 +361,7 @@ abstract class MaterialStateBorderSide extends BorderSide implements MaterialSta
/// ```dart preamble
/// class SelectedBorder extends RoundedRectangleBorder implements MaterialStateOutlinedBorder {
/// @override
/// OutlinedBorder resolve(Set<MaterialState> states) {
/// OutlinedBorder? resolve(Set<MaterialState> states) {
/// if (states.contains(MaterialState.selected)) {
/// return RoundedRectangleBorder();
/// }
......@@ -423,7 +423,7 @@ abstract class MaterialStateOutlinedBorder extends OutlinedBorder implements Mat
/// of their current material state and [resolve] the button style's
/// material state properties when their value is needed.
///
/// {@tool dartpad --template=stateless_widget_scaffold_center_no_null_safety}
/// {@tool dartpad --template=stateless_widget_scaffold_center}
///
/// This example shows how you can override the default text and icon
/// color (the "foreground color") of a [TextButton] with a
......
......@@ -21,11 +21,10 @@ import 'theme.dart';
import 'tooltip.dart';
// Examples can assume:
// // @dart = 2.9
// enum Commands { heroAndScholar, hurricaneCame }
// dynamic _heroAndScholar;
// dynamic _selection;
// BuildContext context;
// late BuildContext context;
// void setState(VoidCallback fn) { }
const Duration _kMenuDuration = Duration(milliseconds: 300);
......
......@@ -18,7 +18,6 @@ import 'slider_theme.dart';
import 'theme.dart';
// Examples can assume:
// // @dart = 2.9
// RangeValues _rangeValues = RangeValues(0.3, 0.7);
// RangeValues _dollarsRange = RangeValues(50, 100);
// void setState(VoidCallback fn) { }
......@@ -34,7 +33,7 @@ typedef PaintRangeValueIndicator = void Function(PaintingContext context, Offset
///
/// {@youtube 560 315 https://www.youtube.com/watch?v=ufb4gIPDmEs}
///
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
/// {@tool dartpad --template=stateful_widget_scaffold}
///
/// ![A range slider widget, consisting of 5 divisions and showing the default
/// value indicator.](https://flutter.github.io/assets-for-api-docs/assets/material/range_slider.png)
......
......@@ -17,9 +17,6 @@ import 'scaffold.dart';
import 'text_field.dart';
import 'theme.dart';
// Examples can assume:
// // @dart = 2.9
/// Shows a full screen search page and returns the search result selected by
/// the user when the page is closed.
///
......@@ -107,7 +104,7 @@ abstract class SearchDelegate<T> {
/// ```dart
/// class CustomSearchHintDelegate extends SearchDelegate {
/// CustomSearchHintDelegate({
/// String hintText,
/// required String hintText,
/// }) : super(
/// searchFieldLabel: hintText,
/// keyboardType: TextInputType.text,
......
......@@ -21,7 +21,6 @@ import 'slider_theme.dart';
import 'theme.dart';
// Examples can assume:
// // @dart = 2.9
// int _dollars = 0;
// int _duelCommandment = 1;
// void setState(VoidCallback fn) { }
......@@ -40,7 +39,7 @@ enum _SliderType { material, adaptive }
///
/// {@youtube 560 315 https://www.youtube.com/watch?v=ufb4gIPDmEs}
///
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
/// {@tool dartpad --template=stateful_widget_scaffold}
///
/// ![A slider widget, consisting of 5 divisions and showing the default value
/// indicator.](https://flutter.github.io/assets-for-api-docs/assets/material/slider.png)
......
......@@ -13,9 +13,6 @@ import 'colors.dart';
import 'theme.dart';
import 'theme_data.dart';
// Examples can assume:
// // @dart = 2.9
/// Applies a slider theme to descendant [Slider] widgets.
///
/// A slider theme describes the colors and shape choices of the slider
......@@ -93,7 +90,7 @@ class SliderTheme extends InheritedTheme {
/// }
///
/// class LaunchState extends State<Launch> {
/// double _rocketThrust;
/// double _rocketThrust = 0;
///
/// @override
/// Widget build(BuildContext context) {
......@@ -253,7 +250,7 @@ class SliderThemeData with Diagnosticable {
/// }
///
/// class BlissfulState extends State<Blissful> {
/// double _bliss;
/// double _bliss = 0;
///
/// @override
/// Widget build(BuildContext context) {
......
......@@ -11,9 +11,6 @@ import 'theme.dart';
export 'package:flutter/services.dart' show SmartQuotesType, SmartDashesType;
// Examples can assume:
// // @dart = 2.9
/// A [FormField] that contains a [TextField].
///
/// This is a convenience widget that wraps a [TextField] widget in a
......@@ -59,18 +56,18 @@ export 'package:flutter/services.dart' show SmartQuotesType, SmartDashesType;
/// hintText: 'What do people call you?',
/// labelText: 'Name *',
/// ),
/// onSaved: (String value) {
/// onSaved: (String? value) {
/// // This optional block of code can be used to run
/// // code when the user saves the form.
/// },
/// validator: (String value) {
/// return value.contains('@') ? 'Do not use the @ char.' : null;
/// validator: (String? value) {
/// return (value != null && value.contains('@')) ? 'Do not use the @ char.' : null;
/// },
/// )
/// ```
/// {@end-tool}
///
/// {@tool dartpad --template=stateful_widget_material_no_null_safety}
/// {@tool dartpad --template=stateful_widget_material}
/// This example shows how to move the focus to the next field when the user
/// presses the SPACE key.
///
......@@ -91,7 +88,7 @@ export 'package:flutter/services.dart' show SmartQuotesType, SmartDashesType;
/// child: Form(
/// autovalidateMode: AutovalidateMode.always,
/// onChanged: () {
/// Form.of(primaryFocus.context).save();
/// Form.of(primaryFocus!.context!)!.save();
/// },
/// child: Wrap(
/// children: List<Widget>.generate(5, (int index) {
......@@ -100,7 +97,7 @@ export 'package:flutter/services.dart' show SmartQuotesType, SmartDashesType;
/// child: ConstrainedBox(
/// constraints: BoxConstraints.tight(const Size(200, 50)),
/// child: TextFormField(
/// onSaved: (String value) {
/// onSaved: (String? value) {
/// print('Value for field $index saved as "$value"');
/// },
/// ),
......
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