flutter_platform_widgets icon indicating copy to clipboard operation
flutter_platform_widgets copied to clipboard

PlatformButton

Open erperejildo opened this issue 3 years ago • 3 comments

What are the options now in Flutter 3 to use a dynamic button as we had before with PlatformButton? I checked the changelog but we no longer have any button option

erperejildo avatar Jul 17 '22 14:07 erperejildo

There is PlatformElevatedButton and PlatformTextButton

aqwert avatar Jul 18 '22 00:07 aqwert

Before I used to have a PlatformButton looking like text on iOS (CupertinoButtonData) and with an elevated background on Android (MaterialRaisedButtonData). That seems to be both both separated. How could I have this now without having some check and returning either one widget or the other? This for me was the main reason to use this package

erperejildo avatar Jul 18 '22 08:07 erperejildo

Also why are not these 2 ones appearing in the widgets list @aqwert? https://pub.dev/packages/flutter_platform_widgets

erperejildo avatar Jul 18 '22 08:07 erperejildo

@aqwert what's the solution?

erperejildo avatar Jan 13 '23 09:01 erperejildo

You need to use either PlatformElevatedButton or PlatformTextButton. These were created since flutter removed the old material buttons. There was a deprecation on PlatformButton for a year to give the chance to switch over.

If you want to have a "combined" platform button just create a widget in your project and have a conditional to pick the right button. These new material buttons are so different they needed to have their own separate widget

aqwert avatar Jan 14 '23 05:01 aqwert

Another approach I think is to set originalStyle to true.

PlatformElevatedButton(...,
   cupertino: (_, __) => CupertinoElevatedButtonData(originalStyle: true)
)

That will have an "elevated" material button and a "text" cupertino button.

Same can be done for PlatformTextButton where it have a "text" material button and a "filled" cupertino button

aqwert avatar Jan 14 '23 05:01 aqwert

ok thanks

erperejildo avatar Jan 16 '23 09:01 erperejildo