flutter_platform_widgets
flutter_platform_widgets copied to clipboard
PlatformButton
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
There is PlatformElevatedButton and PlatformTextButton
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
Also why are not these 2 ones appearing in the widgets list @aqwert? https://pub.dev/packages/flutter_platform_widgets
@aqwert what's the solution?
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
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
ok thanks