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

[NNBD] Migrate sample code pt 2 (#72798)

parent 3cd1166a
......@@ -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 [Checkbox]. In other words, a checkbox with a label.
......@@ -40,7 +39,7 @@ import 'theme_data.dart';
/// To show the [CheckboxListTile] as disabled, pass null as the [onChanged]
/// callback.
///
/// {@tool dartpad --template=stateful_widget_scaffold_center_no_null_safety}
/// {@tool dartpad --template=stateful_widget_scaffold_center}
///
/// ![CheckboxListTile sample](https://flutter.github.io/assets-for-api-docs/assets/material/checkbox_list_tile.png)
///
......@@ -59,8 +58,8 @@ import 'theme_data.dart';
/// return CheckboxListTile(
/// title: const Text('Animate Slowly'),
/// value: timeDilation != 1.0,
/// onChanged: (bool value) {
/// setState(() { timeDilation = value ? 10.0 : 1.0; });
/// onChanged: (bool? value) {
/// setState(() { timeDilation = value! ? 10.0 : 1.0; });
/// },
/// secondary: const Icon(Icons.hourglass_empty),
/// );
......@@ -85,7 +84,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 sample --template=stateful_widget_scaffold_center_no_null_safety}
/// {@tool sample --template=stateful_widget_scaffold_center}
///
/// ![Checkbox list tile semantics sample](https://flutter.github.io/assets-for-api-docs/assets/material/checkbox_list_tile_semantics.png)
///
......@@ -99,10 +98,10 @@ import 'theme_data.dart';
/// ```dart preamble
/// class LinkedLabelCheckbox extends StatelessWidget {
/// const LinkedLabelCheckbox({
/// this.label,
/// this.padding,
/// this.value,
/// this.onChanged,
/// required this.label,
/// required this.padding,
/// required this.value,
/// required this.onChanged,
/// });
///
/// final String label;
......@@ -133,7 +132,7 @@ import 'theme_data.dart';
/// ),
/// Checkbox(
/// value: value,
/// onChanged: (bool newValue) {
/// onChanged: (bool? newValue) {
/// onChanged(newValue);
/// },
/// ),
......@@ -169,7 +168,7 @@ import 'theme_data.dart';
/// combining [Checkbox] with other widgets, such as [Text], [Padding] and
/// [InkWell].
///
/// {@tool dartpad --template=stateful_widget_scaffold_center_no_null_safety}
/// {@tool dartpad --template=stateful_widget_scaffold_center}
///
/// ![Custom checkbox list tile sample](https://flutter.github.io/assets-for-api-docs/assets/material/checkbox_list_tile_custom.png)
///
......@@ -179,10 +178,10 @@ import 'theme_data.dart';
/// ```dart preamble
/// class LabeledCheckbox extends StatelessWidget {
/// const LabeledCheckbox({
/// this.label,
/// this.padding,
/// this.value,
/// this.onChanged,
/// required this.label,
/// required this.padding,
/// required this.value,
/// required this.onChanged,
/// });
///
/// final String label;
......@@ -203,7 +202,7 @@ import 'theme_data.dart';
/// Expanded(child: Text(label)),
/// Checkbox(
/// value: value,
/// onChanged: (bool newValue) {
/// onChanged: (bool? newValue) {
/// onChanged(newValue);
/// },
/// ),
......
......@@ -728,7 +728,7 @@ class DropdownButtonHideUnderline extends InheritedWidget {
/// dropdown's value. It should also call [State.setState] to rebuild the
/// dropdown with the new value.
///
/// {@tool dartpad --template=stateful_widget_scaffold_center_no_null_safety}
/// {@tool dartpad --template=stateful_widget_scaffold_center}
///
/// This sample shows a `DropdownButton` with a large arrow icon,
/// purple text style, and bold purple underline, whose value is one of "One",
......@@ -753,9 +753,9 @@ class DropdownButtonHideUnderline extends InheritedWidget {
/// height: 2,
/// color: Colors.deepPurpleAccent,
/// ),
/// onChanged: (String newValue) {
/// onChanged: (String? newValue) {
/// setState(() {
/// dropdownValue = newValue;
/// dropdownValue = newValue!;
/// });
/// },
/// items: <String>['One', 'Two', 'Free', 'Four']
......@@ -912,7 +912,7 @@ class DropdownButton<T> extends StatefulWidget {
/// from the list corresponds to the [DropdownMenuItem] of the same index
/// in [items].
///
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
/// {@tool dartpad --template=stateful_widget_scaffold}
///
/// This sample shows a `DropdownButton` with a button with [Text] that
/// corresponds to but is unique from [DropdownMenuItem].
......@@ -927,7 +927,7 @@ class DropdownButton<T> extends StatefulWidget {
/// padding: const EdgeInsets.symmetric(horizontal: 12.0),
/// child: DropdownButton<String>(
/// value: selectedItem,
/// onChanged: (String string) => setState(() => selectedItem = string),
/// onChanged: (String? string) => setState(() => selectedItem = string!),
/// selectedItemBuilder: (BuildContext context) {
/// return items.map<Widget>((String item) {
/// return Text(item);
......@@ -963,7 +963,7 @@ class DropdownButton<T> extends StatefulWidget {
/// To use a separate text style for selected item when it's displayed within
/// the dropdown button, consider using [selectedItemBuilder].
///
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
/// {@tool dartpad --template=stateful_widget_scaffold}
///
/// This sample shows a `DropdownButton` with a dropdown button text style
/// that is different than its menu items.
......@@ -979,9 +979,9 @@ class DropdownButton<T> extends StatefulWidget {
/// color: Colors.blue,
/// child: DropdownButton<String>(
/// value: dropdownValue,
/// onChanged: (String newValue) {
/// onChanged: (String? newValue) {
/// setState(() {
/// dropdownValue = newValue;
/// dropdownValue = newValue!;
/// });
/// },
/// style: TextStyle(color: Colors.blue),
......
......@@ -58,7 +58,7 @@ class _DefaultHeroTag {
/// disabled. Consider changing the [backgroundColor] if disabling the floating
/// action button.
///
/// {@tool dartpad --template=stateless_widget_material_no_null_safety}
/// {@tool dartpad --template=stateless_widget_material}
/// This example shows how to display a [FloatingActionButton] in a
/// [Scaffold], with a pink [backgroundColor] and a thumbs up [Icon].
///
......@@ -85,7 +85,7 @@ class _DefaultHeroTag {
/// ```
/// {@end-tool}
///
/// {@tool dartpad --template=stateless_widget_material_no_null_safety}
/// {@tool dartpad --template=stateless_widget_material}
/// This example shows how to make an extended [FloatingActionButton] in a
/// [Scaffold], with a pink [backgroundColor], a thumbs up [Icon] and a
/// [Text] label that reads "Approve".
......
......@@ -30,7 +30,7 @@ const double _kInnerRadius = 4.5;
/// will respond to [onChanged] by calling [State.setState] to update the
/// radio button's [groupValue].
///
/// {@tool dartpad --template=stateful_widget_scaffold_center_no_null_safety}
/// {@tool dartpad --template=stateful_widget_scaffold_center}
///
/// Here is an example of Radio widgets wrapped in ListTiles, which is similar
/// to what you could get with the RadioListTile widget.
......@@ -52,7 +52,7 @@ const double _kInnerRadius = 4.5;
/// ```
///
/// ```dart
/// SingingCharacter _character = SingingCharacter.lafayette;
/// SingingCharacter? _character = SingingCharacter.lafayette;
///
/// Widget build(BuildContext context) {
/// return Column(
......@@ -62,7 +62,7 @@ const double _kInnerRadius = 4.5;
/// leading: Radio(
/// value: SingingCharacter.lafayette,
/// groupValue: _character,
/// onChanged: (SingingCharacter value) {
/// onChanged: (SingingCharacter? value) {
/// setState(() { _character = value; });
/// },
/// ),
......@@ -72,7 +72,7 @@ const double _kInnerRadius = 4.5;
/// leading: Radio(
/// value: SingingCharacter.jefferson,
/// groupValue: _character,
/// onChanged: (SingingCharacter value) {
/// onChanged: (SingingCharacter? value) {
/// setState(() { _character = value; });
/// },
/// ),
......@@ -202,12 +202,12 @@ class Radio<T> extends StatefulWidget {
///
/// 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',
......@@ -231,7 +231,7 @@ class Radio<T> extends StatefulWidget {
/// // TRY THIS: Try setting the toggleable value to false and
/// // see how that changes the behavior of the widget.
/// toggleable: true,
/// onChanged: (int value) {
/// onChanged: (int? value) {
/// setState(() {
/// groupValue = value;
/// });
......
......@@ -122,7 +122,7 @@ class Step {
/// to this widget based on some logic triggered by the three callbacks that it
/// provides.
///
/// {@tool sample --template=stateful_widget_scaffold_center_no_null_safety}
/// {@tool sample --template=stateful_widget_scaffold_center}
///
/// ```dart
/// int _index = 0;
......@@ -247,14 +247,14 @@ class Stepper extends StatefulWidget {
/// For example, keeping track of the [currentStep] within the callback can
/// change the text of the continue or cancel button depending on which step users are at.
///
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
/// {@tool dartpad --template=stateless_widget_scaffold}
/// Creates a stepper control with custom buttons.
///
/// ```dart
/// Widget build(BuildContext context) {
/// return Stepper(
/// controlsBuilder:
/// (BuildContext context, { VoidCallback onStepContinue, VoidCallback onStepCancel }) {
/// (BuildContext context, { VoidCallback? onStepContinue, VoidCallback? onStepCancel }) {
/// return Row(
/// children: <Widget>[
/// TextButton(
......
......@@ -10,7 +10,6 @@ import 'theme.dart';
import 'theme_data.dart';
// Examples can assume:
// // @dart = 2.9
// void setState(VoidCallback fn) { }
// bool _isSelected;
......@@ -46,7 +45,7 @@ enum _SwitchListTileType { material, adaptive }
/// To show the [SwitchListTile] as disabled, pass null as the [onChanged]
/// callback.
///
/// {@tool dartpad --template=stateful_widget_scaffold_center_no_null_safety}
/// {@tool dartpad --template=stateful_widget_scaffold_center}
///
/// ![SwitchListTile sample](https://flutter.github.io/assets-for-api-docs/assets/material/switch_list_tile.png)
///
......@@ -85,7 +84,7 @@ enum _SwitchListTileType { material, adaptive }
/// 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_center_no_null_safety}
/// {@tool dartpad --template=stateful_widget_scaffold_center}
///
/// ![Switch list tile semantics sample](https://flutter.github.io/assets-for-api-docs/assets/material/switch_list_tile_semantics.png)
///
......@@ -99,10 +98,10 @@ enum _SwitchListTileType { material, adaptive }
/// ```dart preamble
/// class LinkedLabelSwitch extends StatelessWidget {
/// const LinkedLabelSwitch({
/// this.label,
/// this.padding,
/// this.value,
/// this.onChanged,
/// required this.label,
/// required this.padding,
/// required this.value,
/// required this.onChanged,
/// });
///
/// final String label;
......@@ -169,7 +168,7 @@ enum _SwitchListTileType { material, adaptive }
/// combining [Switch] with other widgets, such as [Text], [Padding] and
/// [InkWell].
///
/// {@tool dartpad --template=stateful_widget_scaffold_center_no_null_safety}
/// {@tool dartpad --template=stateful_widget_scaffold_center}
///
/// ![Custom switch list tile sample](https://flutter.github.io/assets-for-api-docs/assets/material/switch_list_tile_custom.png)
///
......@@ -179,16 +178,14 @@ enum _SwitchListTileType { material, adaptive }
/// ```dart preamble
/// class LabeledSwitch extends StatelessWidget {
/// const LabeledSwitch({
/// this.label,
/// this.padding,
/// this.groupValue,
/// this.value,
/// this.onChanged,
/// required this.label,
/// required this.padding,
/// required this.value,
/// required this.onChanged,
/// });
///
/// final String label;
/// final EdgeInsets padding;
/// final bool groupValue;
/// final bool value;
/// final Function onChanged;
///
......
......@@ -30,7 +30,7 @@ import 'tooltip_theme.dart';
///
/// {@youtube 560 315 https://www.youtube.com/watch?v=EeEfD5fI-5Q}
///
/// {@tool dartpad --template=stateless_widget_scaffold_center_no_null_safety}
/// {@tool dartpad --template=stateless_widget_scaffold_center}
///
/// This example show a basic [Tooltip] which has a [Text] as child.
/// [message] contains your label to be shown by the tooltip when
......@@ -47,7 +47,7 @@ import 'tooltip_theme.dart';
/// ```
/// {@end-tool}
///
/// {@tool dartpad --template=stateless_widget_scaffold_center_no_null_safety}
/// {@tool dartpad --template=stateless_widget_scaffold_center}
///
/// This example covers most of the attributes available in Tooltip.
/// `decoration` has been used to give a gradient and borderRadius to Tooltip.
......
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