Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
dafc13f1
Unverified
Commit
dafc13f1
authored
Dec 23, 2020
by
Shi-Hao Hong
Committed by
GitHub
Dec 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NNBD] Migrate sample code pt 2 (#72798)
parent
3cd1166a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
48 additions
and
52 deletions
+48
-52
checkbox_list_tile.dart
packages/flutter/lib/src/material/checkbox_list_tile.dart
+15
-16
dropdown.dart
packages/flutter/lib/src/material/dropdown.dart
+8
-8
floating_action_button.dart
...ages/flutter/lib/src/material/floating_action_button.dart
+2
-2
radio.dart
packages/flutter/lib/src/material/radio.dart
+7
-7
stepper.dart
packages/flutter/lib/src/material/stepper.dart
+3
-3
switch_list_tile.dart
packages/flutter/lib/src/material/switch_list_tile.dart
+11
-14
tooltip.dart
packages/flutter/lib/src/material/tooltip.dart
+2
-2
No files found.
packages/flutter/lib/src/material/checkbox_list_tile.dart
View file @
dafc13f1
...
...
@@ -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);
/// },
/// ),
...
...
packages/flutter/lib/src/material/dropdown.dart
View file @
dafc13f1
...
...
@@ -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),
...
...
packages/flutter/lib/src/material/floating_action_button.dart
View file @
dafc13f1
...
...
@@ -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".
...
...
packages/flutter/lib/src/material/radio.dart
View file @
dafc13f1
...
...
@@ -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;
/// });
...
...
packages/flutter/lib/src/material/stepper.dart
View file @
dafc13f1
...
...
@@ -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(
...
...
packages/flutter/lib/src/material/switch_list_tile.dart
View file @
dafc13f1
...
...
@@ -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;
///
...
...
packages/flutter/lib/src/material/tooltip.dart
View file @
dafc13f1
...
...
@@ -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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment