Flutter Platform Aware Widgets
Example project showing how to create platform-aware widget classes in Flutter.
Rationale
Flutter has a rich set of Material and Cupertino widgets that can be used to build beautiful looking UIs on Android and iOS.
However, tailoring apps to adopt platform specific conventions can result in a lot of conditionals:
if (Platform.isIOS) {
// return Cupertino widget
} else {
// return Material widget
}
This project shows how to abstract away this logic by defining a base PlatformWidget
class, that can be subclassed as needed.
This demo shows this approach in practice with a small set of platform-aware widgets.
Supported widgets
PlatformSwitch
PlatformAlertDialog
andPlatformAlertDialogAction
PlatformButton
PlatformScaffold
andPlatformAppBar