[NNBD] Migrate sample code pt 1 (#72794)
This commit is contained in:
parent
501a23ab19
commit
ce048ee8e6
@ -44,14 +44,14 @@ import 'theme.dart';
|
|||||||
/// If your application does not have a [Drawer], you should provide an
|
/// If your application does not have a [Drawer], you should provide an
|
||||||
/// affordance to call [showAboutDialog] or (at least) [showLicensePage].
|
/// affordance to call [showAboutDialog] or (at least) [showLicensePage].
|
||||||
///
|
///
|
||||||
/// {@tool dartpad --template=stateless_widget_material_no_null_safety}
|
/// {@tool dartpad --template=stateless_widget_material}
|
||||||
///
|
///
|
||||||
/// This sample shows two ways to open [AboutDialog]. The first one
|
/// This sample shows two ways to open [AboutDialog]. The first one
|
||||||
/// uses an [AboutListTile], and the second uses the [showAboutDialog] function.
|
/// uses an [AboutListTile], and the second uses the [showAboutDialog] function.
|
||||||
///
|
///
|
||||||
/// ```dart
|
/// ```dart
|
||||||
/// Widget build(BuildContext context) {
|
/// Widget build(BuildContext context) {
|
||||||
/// final TextStyle textStyle = Theme.of(context).textTheme.bodyText2;
|
/// final TextStyle textStyle = Theme.of(context).textTheme.bodyText2!;
|
||||||
/// final List<Widget> aboutBoxChildren = <Widget>[
|
/// final List<Widget> aboutBoxChildren = <Widget>[
|
||||||
/// SizedBox(height: 24),
|
/// SizedBox(height: 24),
|
||||||
/// RichText(
|
/// RichText(
|
||||||
|
@ -20,7 +20,7 @@ import 'theme.dart';
|
|||||||
/// some text describing a musical, and the other with buttons for buying
|
/// some text describing a musical, and the other with buttons for buying
|
||||||
/// tickets or listening to the show.](https://flutter.github.io/assets-for-api-docs/assets/material/card.png)
|
/// tickets or listening to the show.](https://flutter.github.io/assets-for-api-docs/assets/material/card.png)
|
||||||
///
|
///
|
||||||
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
|
/// {@tool dartpad --template=stateless_widget_scaffold}
|
||||||
///
|
///
|
||||||
/// This sample shows creation of a [Card] widget that shows album information
|
/// This sample shows creation of a [Card] widget that shows album information
|
||||||
/// and two actions.
|
/// and two actions.
|
||||||
@ -63,7 +63,7 @@ import 'theme.dart';
|
|||||||
/// Sometimes the primary action area of a card is the card itself. Cards can be
|
/// Sometimes the primary action area of a card is the card itself. Cards can be
|
||||||
/// one large touch target that shows a detail screen when tapped.
|
/// one large touch target that shows a detail screen when tapped.
|
||||||
///
|
///
|
||||||
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
|
/// {@tool dartpad --template=stateless_widget_scaffold}
|
||||||
///
|
///
|
||||||
/// This sample shows creation of a [Card] widget that can be tapped. When
|
/// This sample shows creation of a [Card] widget that can be tapped. When
|
||||||
/// tapped this [Card]'s [InkWell] displays an "ink splash" that fills the
|
/// tapped this [Card]'s [InkWell] displays an "ink splash" that fills the
|
||||||
|
@ -260,7 +260,7 @@ class DataCell {
|
|||||||
/// [PaginatedDataTable] which automatically splits the data into
|
/// [PaginatedDataTable] which automatically splits the data into
|
||||||
/// multiple pages.
|
/// multiple pages.
|
||||||
///
|
///
|
||||||
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
|
/// {@tool dartpad --template=stateless_widget_scaffold}
|
||||||
///
|
///
|
||||||
/// This sample shows how to display a [DataTable] with three columns: name, age, and
|
/// This sample shows how to display a [DataTable] with three columns: name, age, and
|
||||||
/// role. The columns are defined by three [DataColumn] objects. The table
|
/// role. The columns are defined by three [DataColumn] objects. The table
|
||||||
@ -322,7 +322,7 @@ class DataCell {
|
|||||||
/// {@end-tool}
|
/// {@end-tool}
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
|
/// {@tool dartpad --template=stateful_widget_scaffold}
|
||||||
///
|
///
|
||||||
/// This sample shows how to display a [DataTable] with alternate colors per
|
/// This sample shows how to display a [DataTable] with alternate colors per
|
||||||
/// row, and a custom color for when the row is selected.
|
/// row, and a custom color for when the row is selected.
|
||||||
@ -344,7 +344,7 @@ class DataCell {
|
|||||||
/// rows: List<DataRow>.generate(
|
/// rows: List<DataRow>.generate(
|
||||||
/// numItems,
|
/// numItems,
|
||||||
/// (index) => DataRow(
|
/// (index) => DataRow(
|
||||||
/// color: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) {
|
/// color: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||||
/// // All rows will have the same selected color.
|
/// // All rows will have the same selected color.
|
||||||
/// if (states.contains(MaterialState.selected))
|
/// if (states.contains(MaterialState.selected))
|
||||||
/// return Theme.of(context).colorScheme.primary.withOpacity(0.08);
|
/// return Theme.of(context).colorScheme.primary.withOpacity(0.08);
|
||||||
@ -355,9 +355,9 @@ class DataCell {
|
|||||||
/// }),
|
/// }),
|
||||||
/// cells: [DataCell(Text('Row $index'))],
|
/// cells: [DataCell(Text('Row $index'))],
|
||||||
/// selected: selected[index],
|
/// selected: selected[index],
|
||||||
/// onSelectChanged: (bool value) {
|
/// onSelectChanged: (bool? value) {
|
||||||
/// setState(() {
|
/// setState(() {
|
||||||
/// selected[index] = value;
|
/// selected[index] = value!;
|
||||||
/// });
|
/// });
|
||||||
/// },
|
/// },
|
||||||
/// ),
|
/// ),
|
||||||
|
@ -1171,7 +1171,7 @@ class _InkResponseState extends State<_InkResponseStateWidget>
|
|||||||
///
|
///
|
||||||
/// An example of this situation is as follows:
|
/// An example of this situation is as follows:
|
||||||
///
|
///
|
||||||
/// {@tool dartpad --template=stateful_widget_scaffold_center_no_null_safety}
|
/// {@tool dartpad --template=stateful_widget_scaffold_center}
|
||||||
///
|
///
|
||||||
/// Tap the container to cause it to grow. Then, tap it again and hold before
|
/// Tap the container to cause it to grow. Then, tap it again and hold before
|
||||||
/// the widget reaches its maximum size to observe the clipped ink splash.
|
/// the widget reaches its maximum size to observe the clipped ink splash.
|
||||||
|
@ -2389,7 +2389,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
|
|||||||
/// to describe their decoration. (In fact, this class is merely the
|
/// to describe their decoration. (In fact, this class is merely the
|
||||||
/// configuration of an [InputDecorator], which does all the heavy lifting.)
|
/// configuration of an [InputDecorator], which does all the heavy lifting.)
|
||||||
///
|
///
|
||||||
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
|
/// {@tool dartpad --template=stateless_widget_scaffold}
|
||||||
///
|
///
|
||||||
/// This sample shows how to style a `TextField` using an `InputDecorator`. The
|
/// This sample shows how to style a `TextField` using an `InputDecorator`. The
|
||||||
/// TextField displays a "send message" icon to the left of the input area,
|
/// TextField displays a "send message" icon to the left of the input area,
|
||||||
@ -2414,7 +2414,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
|
|||||||
/// ```
|
/// ```
|
||||||
/// {@end-tool}
|
/// {@end-tool}
|
||||||
///
|
///
|
||||||
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
|
/// {@tool dartpad --template=stateless_widget_scaffold}
|
||||||
///
|
///
|
||||||
/// This sample shows how to style a "collapsed" `TextField` using an
|
/// This sample shows how to style a "collapsed" `TextField` using an
|
||||||
/// `InputDecorator`. The collapsed `TextField` surrounds the hint text and
|
/// `InputDecorator`. The collapsed `TextField` surrounds the hint text and
|
||||||
@ -2434,7 +2434,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
|
|||||||
/// ```
|
/// ```
|
||||||
/// {@end-tool}
|
/// {@end-tool}
|
||||||
///
|
///
|
||||||
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
|
/// {@tool dartpad --template=stateless_widget_scaffold}
|
||||||
///
|
///
|
||||||
/// This sample shows how to create a `TextField` with hint text, a red border
|
/// This sample shows how to create a `TextField` with hint text, a red border
|
||||||
/// on all sides, and an error message. To display a red border and error
|
/// on all sides, and an error message. To display a red border and error
|
||||||
@ -2455,7 +2455,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
|
|||||||
/// ```
|
/// ```
|
||||||
/// {@end-tool}
|
/// {@end-tool}
|
||||||
///
|
///
|
||||||
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
|
/// {@tool dartpad --template=stateless_widget_scaffold}
|
||||||
///
|
///
|
||||||
/// This sample shows how to style a `TextField` with a round border and
|
/// This sample shows how to style a `TextField` with a round border and
|
||||||
/// additional text before and after the input area. It displays "Prefix" before
|
/// additional text before and after the input area. It displays "Prefix" before
|
||||||
@ -2836,7 +2836,8 @@ class InputDecoration {
|
|||||||
/// setting the constraints' minimum height and width to a value lower than
|
/// setting the constraints' minimum height and width to a value lower than
|
||||||
/// 48px.
|
/// 48px.
|
||||||
///
|
///
|
||||||
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
|
/// {@tool dartpad --template=stateless_widget_scaffold}
|
||||||
|
///
|
||||||
/// This example shows the differences between two `TextField` widgets when
|
/// This example shows the differences between two `TextField` widgets when
|
||||||
/// [prefixIconConstraints] is set to the default value and when one is not.
|
/// [prefixIconConstraints] is set to the default value and when one is not.
|
||||||
///
|
///
|
||||||
|
@ -10,7 +10,6 @@ import 'theme.dart';
|
|||||||
import 'theme_data.dart';
|
import 'theme_data.dart';
|
||||||
|
|
||||||
// Examples can assume:
|
// Examples can assume:
|
||||||
// // @dart = 2.9
|
|
||||||
// void setState(VoidCallback fn) { }
|
// void setState(VoidCallback fn) { }
|
||||||
|
|
||||||
/// A [ListTile] with a [Radio]. In other words, a radio button with a label.
|
/// A [ListTile] with a [Radio]. In other words, a radio button with a label.
|
||||||
@ -41,7 +40,7 @@ import 'theme_data.dart';
|
|||||||
/// To show the [RadioListTile] as disabled, pass null as the [onChanged]
|
/// To show the [RadioListTile] as disabled, pass null as the [onChanged]
|
||||||
/// callback.
|
/// callback.
|
||||||
///
|
///
|
||||||
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
|
/// {@tool dartpad --template=stateful_widget_scaffold}
|
||||||
///
|
///
|
||||||
/// 
|
/// 
|
||||||
///
|
///
|
||||||
@ -52,7 +51,7 @@ import 'theme_data.dart';
|
|||||||
/// enum SingingCharacter { lafayette, jefferson }
|
/// enum SingingCharacter { lafayette, jefferson }
|
||||||
/// ```
|
/// ```
|
||||||
/// ```dart
|
/// ```dart
|
||||||
/// SingingCharacter _character = SingingCharacter.lafayette;
|
/// SingingCharacter? _character = SingingCharacter.lafayette;
|
||||||
///
|
///
|
||||||
/// @override
|
/// @override
|
||||||
/// Widget build(BuildContext context) {
|
/// Widget build(BuildContext context) {
|
||||||
@ -62,13 +61,13 @@ import 'theme_data.dart';
|
|||||||
/// title: const Text('Lafayette'),
|
/// title: const Text('Lafayette'),
|
||||||
/// value: SingingCharacter.lafayette,
|
/// value: SingingCharacter.lafayette,
|
||||||
/// groupValue: _character,
|
/// groupValue: _character,
|
||||||
/// onChanged: (SingingCharacter value) { setState(() { _character = value; }); },
|
/// onChanged: (SingingCharacter? value) { setState(() { _character = value; }); },
|
||||||
/// ),
|
/// ),
|
||||||
/// RadioListTile<SingingCharacter>(
|
/// RadioListTile<SingingCharacter>(
|
||||||
/// title: const Text('Thomas Jefferson'),
|
/// title: const Text('Thomas Jefferson'),
|
||||||
/// value: SingingCharacter.jefferson,
|
/// value: SingingCharacter.jefferson,
|
||||||
/// groupValue: _character,
|
/// groupValue: _character,
|
||||||
/// onChanged: (SingingCharacter value) { setState(() { _character = value; }); },
|
/// onChanged: (SingingCharacter? value) { setState(() { _character = value; }); },
|
||||||
/// ),
|
/// ),
|
||||||
/// ],
|
/// ],
|
||||||
/// );
|
/// );
|
||||||
@ -93,7 +92,7 @@ import 'theme_data.dart';
|
|||||||
/// into one. Therefore, it may be necessary to create a custom radio tile
|
/// into one. Therefore, it may be necessary to create a custom radio tile
|
||||||
/// widget to accommodate similar use cases.
|
/// widget to accommodate similar use cases.
|
||||||
///
|
///
|
||||||
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
|
/// {@tool dartpad --template=stateful_widget_scaffold}
|
||||||
///
|
///
|
||||||
/// 
|
/// 
|
||||||
///
|
///
|
||||||
@ -107,11 +106,11 @@ import 'theme_data.dart';
|
|||||||
/// ```dart preamble
|
/// ```dart preamble
|
||||||
/// class LinkedLabelRadio extends StatelessWidget {
|
/// class LinkedLabelRadio extends StatelessWidget {
|
||||||
/// const LinkedLabelRadio({
|
/// const LinkedLabelRadio({
|
||||||
/// this.label,
|
/// required this.label,
|
||||||
/// this.padding,
|
/// required this.padding,
|
||||||
/// this.groupValue,
|
/// required this.groupValue,
|
||||||
/// this.value,
|
/// required this.value,
|
||||||
/// this.onChanged,
|
/// required this.onChanged,
|
||||||
/// });
|
/// });
|
||||||
///
|
///
|
||||||
/// final String label;
|
/// final String label;
|
||||||
@ -129,7 +128,7 @@ import 'theme_data.dart';
|
|||||||
/// Radio<bool>(
|
/// Radio<bool>(
|
||||||
/// groupValue: groupValue,
|
/// groupValue: groupValue,
|
||||||
/// value: value,
|
/// value: value,
|
||||||
/// onChanged: (bool newValue) {
|
/// onChanged: (bool? newValue) {
|
||||||
/// onChanged(newValue);
|
/// onChanged(newValue);
|
||||||
/// }
|
/// }
|
||||||
/// ),
|
/// ),
|
||||||
@ -197,7 +196,7 @@ import 'theme_data.dart';
|
|||||||
/// combining [Radio] with other widgets, such as [Text], [Padding] and
|
/// combining [Radio] with other widgets, such as [Text], [Padding] and
|
||||||
/// [InkWell].
|
/// [InkWell].
|
||||||
///
|
///
|
||||||
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
|
/// {@tool dartpad --template=stateful_widget_scaffold}
|
||||||
///
|
///
|
||||||
/// 
|
/// 
|
||||||
///
|
///
|
||||||
@ -207,11 +206,11 @@ import 'theme_data.dart';
|
|||||||
/// ```dart preamble
|
/// ```dart preamble
|
||||||
/// class LabeledRadio extends StatelessWidget {
|
/// class LabeledRadio extends StatelessWidget {
|
||||||
/// const LabeledRadio({
|
/// const LabeledRadio({
|
||||||
/// this.label,
|
/// required this.label,
|
||||||
/// this.padding,
|
/// required this.padding,
|
||||||
/// this.groupValue,
|
/// required this.groupValue,
|
||||||
/// this.value,
|
/// required this.value,
|
||||||
/// this.onChanged,
|
/// required this.onChanged,
|
||||||
/// });
|
/// });
|
||||||
///
|
///
|
||||||
/// final String label;
|
/// final String label;
|
||||||
@ -234,7 +233,7 @@ import 'theme_data.dart';
|
|||||||
/// Radio<bool>(
|
/// Radio<bool>(
|
||||||
/// groupValue: groupValue,
|
/// groupValue: groupValue,
|
||||||
/// value: value,
|
/// value: value,
|
||||||
/// onChanged: (bool newValue) {
|
/// onChanged: (bool? newValue) {
|
||||||
/// onChanged(newValue);
|
/// onChanged(newValue);
|
||||||
/// },
|
/// },
|
||||||
/// ),
|
/// ),
|
||||||
@ -387,12 +386,12 @@ class RadioListTile<T> extends StatelessWidget {
|
|||||||
///
|
///
|
||||||
/// The default is false.
|
/// The default is false.
|
||||||
///
|
///
|
||||||
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
|
/// {@tool dartpad --template=stateful_widget_scaffold}
|
||||||
/// This example shows how to enable deselecting a radio button by setting the
|
/// This example shows how to enable deselecting a radio button by setting the
|
||||||
/// [toggleable] attribute.
|
/// [toggleable] attribute.
|
||||||
///
|
///
|
||||||
/// ```dart
|
/// ```dart
|
||||||
/// int groupValue;
|
/// int? groupValue;
|
||||||
/// static const List<String> selections = <String>[
|
/// static const List<String> selections = <String>[
|
||||||
/// 'Hercules Mulligan',
|
/// 'Hercules Mulligan',
|
||||||
/// 'Eliza Hamilton',
|
/// 'Eliza Hamilton',
|
||||||
@ -411,7 +410,7 @@ class RadioListTile<T> extends StatelessWidget {
|
|||||||
/// groupValue: groupValue,
|
/// groupValue: groupValue,
|
||||||
/// toggleable: true,
|
/// toggleable: true,
|
||||||
/// title: Text(selections[index]),
|
/// title: Text(selections[index]),
|
||||||
/// onChanged: (int value) {
|
/// onChanged: (int? value) {
|
||||||
/// setState(() {
|
/// setState(() {
|
||||||
/// groupValue = value;
|
/// groupValue = value;
|
||||||
/// });
|
/// });
|
||||||
|
@ -43,7 +43,7 @@ import 'theme_data.dart';
|
|||||||
/// Raised buttons have a minimum size of 88.0 by 36.0 which can be overridden
|
/// Raised buttons have a minimum size of 88.0 by 36.0 which can be overridden
|
||||||
/// with [ButtonTheme].
|
/// with [ButtonTheme].
|
||||||
///
|
///
|
||||||
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
|
/// {@tool dartpad --template=stateless_widget_scaffold}
|
||||||
///
|
///
|
||||||
/// This sample shows how to render a disabled RaisedButton, an enabled RaisedButton
|
/// This sample shows how to render a disabled RaisedButton, an enabled RaisedButton
|
||||||
/// and lastly a RaisedButton with gradient background.
|
/// and lastly a RaisedButton with gradient background.
|
||||||
|
@ -158,7 +158,7 @@ class _SnackBarActionState extends State<SnackBarAction> {
|
|||||||
/// A SnackBar with an action will not time out when TalkBack or VoiceOver are
|
/// A SnackBar with an action will not time out when TalkBack or VoiceOver are
|
||||||
/// enabled. This is controlled by [AccessibilityFeatures.accessibleNavigation].
|
/// enabled. This is controlled by [AccessibilityFeatures.accessibleNavigation].
|
||||||
///
|
///
|
||||||
/// {@tool dartpad --template=stateless_widget_scaffold_center_no_null_safety}
|
/// {@tool dartpad --template=stateless_widget_scaffold_center}
|
||||||
///
|
///
|
||||||
/// Here is an example of a [SnackBar] with an [action] button implemented using
|
/// Here is an example of a [SnackBar] with an [action] button implemented using
|
||||||
/// [SnackBarAction].
|
/// [SnackBarAction].
|
||||||
@ -185,7 +185,7 @@ class _SnackBarActionState extends State<SnackBarAction> {
|
|||||||
/// ```
|
/// ```
|
||||||
/// {@end-tool}
|
/// {@end-tool}
|
||||||
///
|
///
|
||||||
/// {@tool dartpad --template=stateless_widget_scaffold_center_no_null_safety}
|
/// {@tool dartpad --template=stateless_widget_scaffold_center}
|
||||||
///
|
///
|
||||||
/// Here is an example of a customized [SnackBar]. It utilizes
|
/// Here is an example of a customized [SnackBar]. It utilizes
|
||||||
/// [behavior], [shape], [padding], [width], and [duration] to customize the
|
/// [behavior], [shape], [padding], [width], and [duration] to customize the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user