[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
|
||||
/// 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
|
||||
/// uses an [AboutListTile], and the second uses the [showAboutDialog] function.
|
||||
///
|
||||
/// ```dart
|
||||
/// 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>[
|
||||
/// SizedBox(height: 24),
|
||||
/// RichText(
|
||||
|
@ -20,7 +20,7 @@ import 'theme.dart';
|
||||
/// 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)
|
||||
///
|
||||
/// {@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
|
||||
/// 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
|
||||
/// 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
|
||||
/// 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
|
||||
/// 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
|
||||
/// role. The columns are defined by three [DataColumn] objects. The table
|
||||
@ -322,7 +322,7 @@ class DataCell {
|
||||
/// {@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
|
||||
/// row, and a custom color for when the row is selected.
|
||||
@ -344,7 +344,7 @@ class DataCell {
|
||||
/// rows: List<DataRow>.generate(
|
||||
/// numItems,
|
||||
/// (index) => DataRow(
|
||||
/// color: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) {
|
||||
/// color: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
/// // All rows will have the same selected color.
|
||||
/// if (states.contains(MaterialState.selected))
|
||||
/// return Theme.of(context).colorScheme.primary.withOpacity(0.08);
|
||||
@ -355,9 +355,9 @@ class DataCell {
|
||||
/// }),
|
||||
/// cells: [DataCell(Text('Row $index'))],
|
||||
/// selected: selected[index],
|
||||
/// onSelectChanged: (bool value) {
|
||||
/// onSelectChanged: (bool? value) {
|
||||
/// setState(() {
|
||||
/// selected[index] = value;
|
||||
/// selected[index] = value!;
|
||||
/// });
|
||||
/// },
|
||||
/// ),
|
||||
|
@ -1171,7 +1171,7 @@ class _InkResponseState extends State<_InkResponseStateWidget>
|
||||
///
|
||||
/// 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
|
||||
/// 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
|
||||
/// 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
|
||||
/// 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}
|
||||
///
|
||||
/// {@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
|
||||
/// `InputDecorator`. The collapsed `TextField` surrounds the hint text and
|
||||
@ -2434,7 +2434,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
|
||||
/// ```
|
||||
/// {@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
|
||||
/// 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}
|
||||
///
|
||||
/// {@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
|
||||
/// 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
|
||||
/// 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
|
||||
/// [prefixIconConstraints] is set to the default value and when one is not.
|
||||
///
|
||||
|
@ -10,7 +10,6 @@ import 'theme.dart';
|
||||
import 'theme_data.dart';
|
||||
|
||||
// Examples can assume:
|
||||
// // @dart = 2.9
|
||||
// void setState(VoidCallback fn) { }
|
||||
|
||||
/// 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]
|
||||
/// 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 }
|
||||
/// ```
|
||||
/// ```dart
|
||||
/// SingingCharacter _character = SingingCharacter.lafayette;
|
||||
/// SingingCharacter? _character = SingingCharacter.lafayette;
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
@ -62,13 +61,13 @@ import 'theme_data.dart';
|
||||
/// title: const Text('Lafayette'),
|
||||
/// value: SingingCharacter.lafayette,
|
||||
/// groupValue: _character,
|
||||
/// onChanged: (SingingCharacter value) { setState(() { _character = value; }); },
|
||||
/// onChanged: (SingingCharacter? value) { setState(() { _character = value; }); },
|
||||
/// ),
|
||||
/// RadioListTile<SingingCharacter>(
|
||||
/// title: const Text('Thomas Jefferson'),
|
||||
/// value: SingingCharacter.jefferson,
|
||||
/// 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
|
||||
/// 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
|
||||
/// class LinkedLabelRadio extends StatelessWidget {
|
||||
/// const LinkedLabelRadio({
|
||||
/// this.label,
|
||||
/// this.padding,
|
||||
/// this.groupValue,
|
||||
/// this.value,
|
||||
/// this.onChanged,
|
||||
/// required this.label,
|
||||
/// required this.padding,
|
||||
/// required this.groupValue,
|
||||
/// required this.value,
|
||||
/// required this.onChanged,
|
||||
/// });
|
||||
///
|
||||
/// final String label;
|
||||
@ -129,7 +128,7 @@ import 'theme_data.dart';
|
||||
/// Radio<bool>(
|
||||
/// groupValue: groupValue,
|
||||
/// value: value,
|
||||
/// onChanged: (bool newValue) {
|
||||
/// onChanged: (bool? newValue) {
|
||||
/// onChanged(newValue);
|
||||
/// }
|
||||
/// ),
|
||||
@ -197,7 +196,7 @@ import 'theme_data.dart';
|
||||
/// combining [Radio] with other widgets, such as [Text], [Padding] and
|
||||
/// [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
|
||||
/// class LabeledRadio extends StatelessWidget {
|
||||
/// const LabeledRadio({
|
||||
/// this.label,
|
||||
/// this.padding,
|
||||
/// this.groupValue,
|
||||
/// this.value,
|
||||
/// this.onChanged,
|
||||
/// required this.label,
|
||||
/// required this.padding,
|
||||
/// required this.groupValue,
|
||||
/// required this.value,
|
||||
/// required this.onChanged,
|
||||
/// });
|
||||
///
|
||||
/// final String label;
|
||||
@ -234,7 +233,7 @@ import 'theme_data.dart';
|
||||
/// Radio<bool>(
|
||||
/// groupValue: groupValue,
|
||||
/// value: value,
|
||||
/// onChanged: (bool newValue) {
|
||||
/// onChanged: (bool? newValue) {
|
||||
/// onChanged(newValue);
|
||||
/// },
|
||||
/// ),
|
||||
@ -387,12 +386,12 @@ class RadioListTile<T> extends StatelessWidget {
|
||||
///
|
||||
/// 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
|
||||
/// [toggleable] attribute.
|
||||
///
|
||||
/// ```dart
|
||||
/// int groupValue;
|
||||
/// int? groupValue;
|
||||
/// static const List<String> selections = <String>[
|
||||
/// 'Hercules Mulligan',
|
||||
/// 'Eliza Hamilton',
|
||||
@ -411,7 +410,7 @@ class RadioListTile<T> extends StatelessWidget {
|
||||
/// groupValue: groupValue,
|
||||
/// toggleable: true,
|
||||
/// title: Text(selections[index]),
|
||||
/// onChanged: (int value) {
|
||||
/// onChanged: (int? value) {
|
||||
/// setState(() {
|
||||
/// 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
|
||||
/// 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
|
||||
/// 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
|
||||
/// 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
|
||||
/// [SnackBarAction].
|
||||
@ -185,7 +185,7 @@ class _SnackBarActionState extends State<SnackBarAction> {
|
||||
/// ```
|
||||
/// {@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
|
||||
/// [behavior], [shape], [padding], [width], and [duration] to customize the
|
||||
|
Loading…
x
Reference in New Issue
Block a user