platty
Flutter makes no attempt to provide familiar widgets for a specific platform (unlike React Native, ionic, and other cross platform tooling). This has enormous benefits to unified rendering on all platforms, maximum flexibility, and eliminating a whole class of bugs and testing done for each platform. While this is great, many scenarios we want our apps to look and feel like an Android or iOS app. Platty allows you to render iOS (Cupertino) and Android (Material) like widgets with minimal effort and maximum control in a unified API.
No more checking for platform inside render blocks to render a CupertinoButton or FlatButton, let platty do the logic for you! Want to use bottom tabs in your app that resolve to platform specific UI? No problem!
Getting Started
Use platty to unify render-specific APIs for you. The library utilizes the 
information into the Widgets.
BuildContext theming APIs to propagate platforminformation into the Widgets.
By default, all widgets conform to the default 
Also, all widgets provide a
TargetPlatform. It looks up the Theme.of(context).platform for its default.Also, all widgets provide a
renderPlatform prop that allows you to choose which one to render (if you wish).
Replace 
MaterialApp and CupertinoApp with PlatformApp:PlatformApp unifies all of the same properties between MaterialApp and CupertinoApp to allow both instances of widgets in the hiearchy andswitching styling based on platform.
Now you replace widgets that are included in this library with their "P" counterparts:
Button/CupertinoButton -> PButton
FlatButton/CupertinoButton -> PFlatButtonAppBar/CupertinoNavigationBar -> PNavigationBar
SliverAppBar/CupertinoSliverNavigationBar -> PSliverNavigationBarSlider/CupertinoSlider -> PSliderSwitch/CupertinoSwitch -> PSwitchScaffold/CupertinoScaffold -> PScaffoldCircularProgressIndicator/CupertinoActivityIndicator -> PActivityIndicatorBackButton/CupertinoNavigationBarBackButton -> PBackButtonAlertDialog/CupertinoAlertDialog -> PAlertDialogProperties Specific to a platform have a prefix
Any widgets that have ios-only or android-only counterparts, they are prefixed to 
android/ios accordingly:
For example 
However
PButton, androidShape applies to RaisedButton.shape property. It does not exist on a CupertinoButton.However
CupertinoButton has a borderRadius and pressedOpacity. Those two props become iosBorderRadius and iosPressedOpacity.Helpers
This library bundles a few standard functions to easily return code that is unique for each platform. Instead of checking
and switching on the result of
and switching on the result of
Theme.of(context).targetPlatform, utilize the following methods:Specific Platform Instance
To have a specific 
it in a
P-Widget utilize a specific platform theme only, such as Material or Cupertino, you can wrapit in a
PTheme instance:
Or, more simply, utilize helper method:
Also, all 
or calling method:
P-widgets and methods allow you to override the PTheme with a renderPlatformparameter in their constructoror calling method:
This will swap the rendering over to 
Material widgets for this specific widget.
Note: Wrapping a widget with the 
manually specifying the
PTheme will propagate that instance down the widget hierarchy and is thus preferred thanmanually specifying the
renderPlatform for each individual widget.Creating Your Own Platform-Adapting Widgets
We can extend upon the logic included in this library to build our own, powerful platform-adapting widgets.
Included in the library is the
Included in the library is the
PlatformAdaptingWidget base class, which inherits from StatelessWidget.Platform-specific logic
This library comes with a few standard ways to implement behavior based on platform.
You can utilize
with another widget:
You can utilize
platformWrap, which allows you to specify a child, and on 1 or all platforms, wrap itwith another widget:
You can specify any of 
Any render methods not specified default to the
renderCupertino, renderMaterial, or renderFuschia (or none).Any render methods not specified default to the
child.
Also, 
In our
return type based on platform:
platformSelect is a helper that enables returning different objects based on platform in a unified way.In our
PlatformAdaptingWidget, we utilize it to return a different widget based on platform. You can use it to return anyreturn type based on platform:
renderMaterial and renderCupertino are required. renderFuchsia defaults to material.
or you can return a non-widget too:
GitHub
 











 
 
 
