Skip to content

Commit

Permalink
#fixup migrate deprecated buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
X-Wei committed Feb 20, 2021
1 parent c7d4886 commit b5c3fa5
Show file tree
Hide file tree
Showing 26 changed files with 71 additions and 71 deletions.
2 changes: 1 addition & 1 deletion lib/my_app_routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ const kMyAppRoutesBasic = <MyRouteGroup>[
sourceFilePath: 'lib/routes/widgets_buttons_ex.dart',
title: 'Buttons',
description:
'RaisedButton, FlatButton, OutlineButton, IconButton&Tooltips',
'ElevatedButton, TextButton, OutlineButton, IconButton&Tooltips',
links: {
'Doc':
'https://docs.flutter.io/flutter/material/ButtonBar-class.html',
Expand Down
4 changes: 2 additions & 2 deletions lib/routes/animation_animated_builder_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ class _AnimatedBuilderExampleState extends State<AnimatedBuilderExample>
},
child: const FlutterLogo(size: 72.0),
),
RaisedButton(
ElevatedButton(
onPressed: () => _controller.forward(),
child: const Text('Forward animation'),
),
RaisedButton(
ElevatedButton(
onPressed: () => _controller.reverse(),
child: const Text('Reverse animation'),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/animation_animated_container_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class _AnimatedContainerExampleState extends State<AnimatedContainerExample> {
curve: Curves.fastOutSlowIn,
child: const FlutterLogo(),
),
RaisedButton.icon(
ElevatedButton.icon(
icon: const Icon(Icons.update),
label: const Text('Change random property'),
onPressed: () => setState(
Expand Down
4 changes: 2 additions & 2 deletions lib/routes/animation_animated_widget_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ class _AnimatedWidgetExampleState extends State<AnimatedWidgetExample>
_AnimatedLogo(
animation: this._sizeAnimation,
),
RaisedButton(
ElevatedButton(
onPressed: () => _controller.forward(),
child: const Text('Forward animation'),
),
RaisedButton(
ElevatedButton(
onPressed: () => _controller.reverse(),
child: const Text('Reverse animation'),
),
Expand Down
6 changes: 3 additions & 3 deletions lib/routes/animation_animations_pkg_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class AnimationsPackageExample extends StatelessWidget {
'https://pub.dev/documentation/animations/latest/animations/showModal.html'),
),
),
RaisedButton(
ElevatedButton(
onPressed: () => showModal(
configuration: const FadeScaleTransitionConfiguration(
transitionDuration: Duration(milliseconds: 500),
Expand Down Expand Up @@ -191,13 +191,13 @@ class __SharedAxisExState extends State<_SharedAxisEx> {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
FlatButton(
TextButton(
onPressed: this._currentPageIdx == 0
? null
: () => setState(() => this._currentPageIdx--),
child: const Text('BACK'),
),
RaisedButton(
ElevatedButton(
onPressed: this._currentPageIdx == 2
? null
: () => setState(() => this._currentPageIdx++),
Expand Down
6 changes: 3 additions & 3 deletions lib/routes/animation_low_level_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,17 @@ class _LowLevelAnimationExampleState extends State<LowLevelAnimationExample>
width: this._sizeAnimation.value,
child: const FlutterLogo(),
),
RaisedButton(
ElevatedButton(
onPressed:
this._controller.isCompleted ? null : () => _controller.forward(),
child: const Text('Forward animation'),
),
RaisedButton(
ElevatedButton(
onPressed:
this._controller.isDismissed ? null : () => _controller.reverse(),
child: const Text('Reverse animation'),
),
RaisedButton(
ElevatedButton(
onPressed: () {
// Use addStatusListener() for notifications of changes to the
// animation’s state, such as starting, stopping, or reversing
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/async_streamcontroller_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class _StreamControllerExampleState extends State<StreamControllerExample> {
},
),
),
RaisedButton.icon(
ElevatedButton.icon(
icon: const Icon(Icons.send),
label: const Text('Send random word to input stream'),
onPressed: () => this._inputStreamController.sink.add(
Expand Down
4 changes: 2 additions & 2 deletions lib/routes/firebase_chatroom_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class _FirebaseChatroomExampleState extends State<FirebaseChatroomExample> {
'To send messages, you must log in '
'in the "Firebase login" demo.'),
actions: <Widget>[
FlatButton(
TextButton(
onPressed: () => Navigator.of(ctx).pop(),
child: const Text('OK'),
)
Expand Down Expand Up @@ -198,7 +198,7 @@ class _FirebaseChatroomExampleState extends State<FirebaseChatroomExample> {
'Go to the "Firebase login" example, and log in from there. '
'You will then be able to send messages.'),
actions: <Widget>[
FlatButton(
TextButton(
onPressed: () => Navigator.of(ctx).pop(),
child: const Text('OK'),
)
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/firebase_login_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class _FirebaseLoginExampleState extends State<FirebaseLoginExample> {
},
child: const Text('Log in anonymously'),
);
final signOutBtn = FlatButton(
final signOutBtn = TextButton(
onPressed: this._busy
? null
: () async {
Expand Down
8 changes: 4 additions & 4 deletions lib/routes/firebase_mlkit_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -241,19 +241,19 @@ class _FirebaseMLKitExampleState extends State<FirebaseMLKitExample> {
scrollDirection: Axis.horizontal,
child: ButtonBar(
children: <Widget>[
RaisedButton(
ElevatedButton(
onPressed: this._imageLabelling,
child: const Text('Image Labelling'),
),
RaisedButton(
ElevatedButton(
onPressed: this._textOcr,
child: const Text('Text OCR'),
),
RaisedButton(
ElevatedButton(
onPressed: this._barcodeScan,
child: const Text('Barcode Scan'),
),
RaisedButton(
ElevatedButton(
onPressed: this._faceDetect,
child: const Text('Face Detection'),
),
Expand Down
4 changes: 2 additions & 2 deletions lib/routes/lists_slidable_tile_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ class _SlidableTileExampleState extends State<SlidableTileExample> {
actionType == SlideActionType.primary ? 'Archive' : 'Delete'),
content: const Text('Confirm action?'),
actions: <Widget>[
FlatButton(
TextButton(
onPressed: () => Navigator.of(context).pop(false),
child: const Text('Cancel'),
),
FlatButton(
TextButton(
onPressed: () => Navigator.of(context).pop(true),
child: const Text('Ok'),
),
Expand Down
6 changes: 3 additions & 3 deletions lib/routes/multimedia_extended_image_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ class _ExtendedImageExampleState extends State<ExtendedImageExample> {
scrollDirection: Axis.horizontal,
child: ButtonBar(
children: <Widget>[
RaisedButton.icon(
ElevatedButton.icon(
label: const Text('Rotate right'),
icon: const Icon(Icons.rotate_right),
onPressed: () => _editorKey.currentState.rotate(),
),
RaisedButton.icon(
ElevatedButton.icon(
label: const Text('Rotate left'),
icon: const Icon(Icons.rotate_left),
onPressed: () => _editorKey.currentState.rotate(right: false),
),
RaisedButton.icon(
ElevatedButton.icon(
label: const Text('Reset'),
icon: const Icon(Icons.restore),
onPressed: () => _editorKey.currentState.reset(),
Expand Down
4 changes: 2 additions & 2 deletions lib/routes/multimedia_video_player_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class _VideoPlayerExampleState extends State<VideoPlayerExample> {
Text(
'${_videoController.value.position} / ${_videoController.value.duration}'),
VideoProgressIndicator(_videoController, allowScrubbing: true),
RaisedButton.icon(
ElevatedButton.icon(
onPressed: () => _videoController.value.isPlaying
? _videoController.pause()
: _videoController.play(),
Expand All @@ -86,7 +86,7 @@ class _VideoPlayerExampleState extends State<VideoPlayerExample> {
VideoProgressIndicator(_audioController, allowScrubbing: true),
Text(
'${_audioController.value.position} / ${_audioController.value.duration}'),
RaisedButton.icon(
ElevatedButton.icon(
onPressed: () => _audioController.value.isPlaying
? _audioController.pause()
: _audioController.play(),
Expand Down
6 changes: 3 additions & 3 deletions lib/routes/nav_bottom_sheet_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ class _BottomSheetExampleState extends State<BottomSheetExample> {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
ElevatedButton(
onPressed: () => this
._scaffoldKey
.currentState
.showBottomSheet((ctx) => _buildBottomSheet(ctx)),
child: const Text('show bottom sheet'),
),
RaisedButton(
ElevatedButton(
onPressed: () => showModalBottomSheet(
context: context, builder: (ctx) => _buildBottomSheet(ctx)),
child: const Text('show modal bottom sheet'),
Expand Down Expand Up @@ -64,7 +64,7 @@ class _BottomSheetExampleState extends State<BottomSheetExample> {
),
Container(
alignment: Alignment.center,
child: RaisedButton.icon(
child: ElevatedButton.icon(
icon: const Icon(Icons.save),
label: const Text('Save and close'),
onPressed: () => Navigator.pop(context),
Expand Down
30 changes: 15 additions & 15 deletions lib/routes/nav_dialogs_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class DialogsExample extends StatelessWidget {
padding: const EdgeInsets.all(32.0),
children: <Widget>[
////// Alert dialog.
RaisedButton(
color: Colors.red,
ElevatedButton(
style: ElevatedButton.styleFrom(primary: Colors.red),
onPressed: () {
// The function showDialog<T> returns Future<T>.
// Use Navigator.pop() to return value (of type T).
Expand All @@ -25,11 +25,11 @@ class DialogsExample extends StatelessWidget {
'Sample alert',
),
actions: <Widget>[
FlatButton(
TextButton(
onPressed: () => Navigator.pop(context, 'Cancel'),
child: const Text('Cancel'),
),
FlatButton(
TextButton(
onPressed: () => Navigator.pop(context, 'OK'),
child: const Text('OK'),
),
Expand All @@ -49,8 +49,8 @@ class DialogsExample extends StatelessWidget {
child: const Text('Alert Dialog'),
),
////// Simple Dialog.
RaisedButton(
color: Colors.yellow,
ElevatedButton(
style: ElevatedButton.styleFrom(primary: Colors.yellow),
onPressed: () {
showDialog<String>(
context: context,
Expand Down Expand Up @@ -88,8 +88,8 @@ class DialogsExample extends StatelessWidget {
child: const Text('Simple dialog'),
),
////// Time Picker Dialog.
RaisedButton(
color: Colors.green,
ElevatedButton(
style: ElevatedButton.styleFrom(primary: Colors.green),
onPressed: () {
final DateTime now = DateTime.now();
showTimePicker(
Expand All @@ -109,8 +109,8 @@ class DialogsExample extends StatelessWidget {
child: const Text('Time Picker Dialog'),
),
////// Date Picker Dialog.
RaisedButton(
color: Colors.blue,
ElevatedButton(
style: ElevatedButton.styleFrom(primary: Colors.blue),
onPressed: () {
showDatePicker(
context: context,
Expand All @@ -131,8 +131,8 @@ class DialogsExample extends StatelessWidget {
child: const Text('Date Picker Dialog'),
),
////// DateRange Picker Dialog.
RaisedButton(
color: Colors.purple,
ElevatedButton(
style: ElevatedButton.styleFrom(primary: Colors.purple),
onPressed: () {
showDateRangePicker(
context: context,
Expand All @@ -154,8 +154,8 @@ class DialogsExample extends StatelessWidget {
child: const Text('Date Range Picker Dialog'),
),
////// Bottom Sheet Dialog.
RaisedButton(
color: Colors.orange,
ElevatedButton(
style: ElevatedButton.styleFrom(primary: Colors.orange),
onPressed: () {
// Or: showModalBottomSheet(), with model bottom sheet, clicking
// anywhere will dismiss the bottom sheet.
Expand All @@ -179,7 +179,7 @@ class DialogsExample extends StatelessWidget {
),
ButtonBar(
children: <Widget>[
FlatButton(
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('OK'),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/nav_pageselector_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class PageSelectorExample extends StatelessWidget {
child: const TabBarView(children: kIcons),
),
),
RaisedButton(
ElevatedButton(
onPressed: () {
final TabController controller =
DefaultTabController.of(context);
Expand Down
4 changes: 2 additions & 2 deletions lib/routes/nav_routes_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class RoutesExample extends StatelessWidget {
title: const Text('Page 1'),
),
body: Center(
child: RaisedButton(
child: ElevatedButton(
onPressed: () {
// Navigator maintains a stack-like structure of pages. Jumping
// between routes is by push/pop of Navigator.
Expand All @@ -50,7 +50,7 @@ class _PageTwo extends MaterialPageRoute<void> {
// https://stackoverflow.com/a/51304732.
body: Builder(
builder: (BuildContext context) => Center(
child: RaisedButton(
child: ElevatedButton(
onPressed: () {
// Navigator.push<T> returns a Future<T>, which is the
// return value of the pushed route when it's popped.
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/networking_googlebooks_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class _RestApiGoogleBooksExampleState extends State<RestApiGoogleBooksExample> {
const SizedBox(height: 4),
ButtonBar(
children: <Widget>[
RaisedButton(
ElevatedButton(
onPressed:
_pending ? null : () => this._search(_queryController.text),
child: const Text('Search'),
Expand Down
4 changes: 2 additions & 2 deletions lib/routes/networking_rest_api_fetch_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ class _RestApiFetchExampleState extends State<RestApiFetchExample> {
),
ButtonBar(
children: <Widget>[
RaisedButton(
ElevatedButton(
onPressed: _pending
? null
: () => this
._httpGet(_urlController.text, _apiTokenController.text),
child: const Text('Get'),
),
RaisedButton(
ElevatedButton(
onPressed: this._reset,
child: const Text('Reset'),
),
Expand Down
4 changes: 2 additions & 2 deletions lib/routes/networking_rest_api_send_ex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ From https://jsonplaceholder.typicode.com/guide.html we see that the API expects
),
ButtonBar(
children: <Widget>[
RaisedButton(
ElevatedButton(
onPressed: _pending
? null
: () => this._httpPost(
Expand All @@ -74,7 +74,7 @@ From https://jsonplaceholder.typicode.com/guide.html we see that the API expects
),
child: const Text('Post'),
),
RaisedButton(
ElevatedButton(
onPressed: this._reset,
child: const Text('Reset'),
),
Expand Down
Loading

0 comments on commit b5c3fa5

Please sign in to comment.