From 25c386b2ba0a8bd79d80745464e3f79c849f2cdc Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Sun, 6 Jun 2021 10:39:40 +0200 Subject: [PATCH] Stop using deprecated methods --- lib/editors/bottom_bar.dart | 2 +- lib/iap/purchase_thankyou_screen.dart | 19 ++++++++++++------- lib/iap/purchase_widget.dart | 13 +++++++++---- lib/screens/onboarding_screens.dart | 7 +++++-- lib/settings/settings_git_remote.dart | 13 +++++++++---- lib/setup/button.dart | 14 ++++++++++---- lib/setup/screens.dart | 8 ++++---- 7 files changed, 50 insertions(+), 26 deletions(-) diff --git a/lib/editors/bottom_bar.dart b/lib/editors/bottom_bar.dart index dbad38d0..6a05e615 100644 --- a/lib/editors/bottom_bar.dart +++ b/lib/editors/bottom_bar.dart @@ -95,7 +95,7 @@ class EditorBottomBar extends StatelessWidget { icon: const Icon(Icons.undo), onPressed: undoAllowed ? onUndoSelected : null, ), - FlatButton.icon( + TextButton.icon( icon: const Icon(Icons.folder), label: Text(parentFolder.publicName), onPressed: () { diff --git a/lib/iap/purchase_thankyou_screen.dart b/lib/iap/purchase_thankyou_screen.dart index 39baf3e6..059df65a 100644 --- a/lib/iap/purchase_thankyou_screen.dart +++ b/lib/iap/purchase_thankyou_screen.dart @@ -15,14 +15,19 @@ class PurchaseThankYouScreen extends StatelessWidget { style: textTheme.headline4, textAlign: TextAlign.center, ), - RaisedButton( - child: const Text("Back"), - color: theme.primaryColor, - onPressed: () { - Navigator.of(context).pop(); - }, + Padding( padding: const EdgeInsets.fromLTRB(64.0, 16.0, 64.0, 16.0), - ) + child: ElevatedButton( + child: const Text("Back"), + onPressed: () { + Navigator.of(context).pop(); + }, + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all( + Theme.of(context).primaryColor), + ), + ), + ), ], mainAxisAlignment: MainAxisAlignment.spaceAround, ); diff --git a/lib/iap/purchase_widget.dart b/lib/iap/purchase_widget.dart index ca06d8ea..19156eff 100644 --- a/lib/iap/purchase_widget.dart +++ b/lib/iap/purchase_widget.dart @@ -43,11 +43,16 @@ class PurchaseButton extends StatelessWidget { text = tr("widgets.PurchaseButton.fail"); } - return RaisedButton( - child: Text(text, textAlign: TextAlign.center), - color: Theme.of(context).primaryColor, + return Padding( padding: const EdgeInsets.fromLTRB(32.0, 16.0, 32.0, 16.0), - onPressed: product != null ? () => _reportExceptions(context) : null, + child: ElevatedButton( + child: Text(text, textAlign: TextAlign.center), + onPressed: product != null ? () => _reportExceptions(context) : null, + style: ButtonStyle( + backgroundColor: + MaterialStateProperty.all(Theme.of(context).primaryColor), + ), + ), ); } diff --git a/lib/screens/onboarding_screens.dart b/lib/screens/onboarding_screens.dart index 378dbd50..248dffd8 100644 --- a/lib/screens/onboarding_screens.dart +++ b/lib/screens/onboarding_screens.dart @@ -102,14 +102,17 @@ class OnBoardingScreenState extends State { bottomBar = SizedBox( width: double.infinity, height: _bottomBarHeight, - child: RaisedButton( + child: ElevatedButton( key: const ValueKey("GetStarted"), child: Text( tr("OnBoarding.getStarted"), textAlign: TextAlign.center, style: Theme.of(context).textTheme.button, ), - color: Theme.of(context).primaryColor, + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all( + Theme.of(context).primaryColor), + ), onPressed: _finish, ), ); diff --git a/lib/settings/settings_git_remote.dart b/lib/settings/settings_git_remote.dart index d8da364d..d6996a01 100644 --- a/lib/settings/settings_git_remote.dart +++ b/lib/settings/settings_git_remote.dart @@ -254,13 +254,16 @@ class Button extends StatelessWidget { Widget build(BuildContext context) { return SizedBox( width: double.infinity, - child: RaisedButton( + child: ElevatedButton( child: Text( text, textAlign: TextAlign.center, style: Theme.of(context).textTheme.button, ), - color: Theme.of(context).primaryColor, + style: ButtonStyle( + backgroundColor: + MaterialStateProperty.all(Theme.of(context).primaryColor), + ), onPressed: onPressed, ), ); @@ -277,13 +280,15 @@ class RedButton extends StatelessWidget { Widget build(BuildContext context) { return SizedBox( width: double.infinity, - child: RaisedButton( + child: ElevatedButton( child: Text( text, textAlign: TextAlign.center, style: Theme.of(context).textTheme.button, ), - color: Colors.red, + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all(Colors.red), + ), onPressed: onPressed, ), ); diff --git a/lib/setup/button.dart b/lib/setup/button.dart index 85db612b..b5c7bb86 100644 --- a/lib/setup/button.dart +++ b/lib/setup/button.dart @@ -21,27 +21,33 @@ class GitHostSetupButton extends StatelessWidget { if (iconUrl == null) { return SizedBox( width: double.infinity, - child: RaisedButton( + child: ElevatedButton( child: Text( text, textAlign: TextAlign.center, style: Theme.of(context).textTheme.button, ), - color: Theme.of(context).primaryColor, + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all( + Theme.of(context).primaryColor), + ), onPressed: _onPressedWithAnalytics, ), ); } else { return SizedBox( width: double.infinity, - child: RaisedButton.icon( + child: ElevatedButton.icon( label: Text( text, textAlign: TextAlign.center, style: Theme.of(context).textTheme.button, ), icon: Image.asset(iconUrl!, width: 32, height: 32), - color: Theme.of(context).primaryColor, + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all( + Theme.of(context).primaryColor), + ), onPressed: _onPressedWithAnalytics, ), ); diff --git a/lib/setup/screens.dart b/lib/setup/screens.dart index 1a05660e..25708a8f 100644 --- a/lib/setup/screens.dart +++ b/lib/setup/screens.dart @@ -73,7 +73,7 @@ class GitHostSetupScreenState extends State { UserInfo? _userInfo; - Widget? _buildPage(BuildContext context, int pos) { + Widget _buildPage(BuildContext context, int pos) { assert(_pageCount >= 1); if (pos == 0) { @@ -350,16 +350,16 @@ class GitHostSetupScreenState extends State { } assert(_pageChoice[0] != PageChoice0.CustomProvider); - assert(false, "Pos is $pos"); - return null; + + return Container(); } @override Widget build(BuildContext context) { var pageView = PageView.builder( controller: pageController, - itemBuilder: _buildPage as Widget Function(BuildContext, int), + itemBuilder: _buildPage, itemCount: _pageCount, onPageChanged: (int pageNum) { setState(() {