@@ -15,25 +15,25 @@ Want to use bottom tabs in your app that resolve to platform specific UI? No pro
15
15
16
16
List of Widget Files:
17
17
18
- [ Alerts] ( /lib/widgets/alert.dart )
18
+ [ Alerts] ( /lib/src/ widgets/alert.dart )
19
19
20
- [ Back Button] ( /lib/widgets/back_button.dart )
20
+ [ Back Button] ( /lib/src/ widgets/back_button.dart )
21
21
22
- [ Buttons] ( /lib/widgets/button.dart )
22
+ [ Buttons] ( /lib/src/ widgets/button.dart )
23
23
24
- [ Navigation Bars] ( /lib/widgets/navigation_bar.dart )
24
+ [ Navigation Bars] ( /lib/src/ widgets/navigation_bar.dart )
25
25
26
- [ Progress] ( /lib/widgets/progress.dart )
26
+ [ Progress] ( /lib/src/ widgets/progress.dart )
27
27
28
- [ Routing] ( /lib/widgets/routing.dart )
28
+ [ Routing] ( /lib/src/ widgets/routing.dart )
29
29
30
- [ Scaffold] ( /lib/widgets/scaffold.dart )
30
+ [ Scaffold] ( /lib/src/ widgets/scaffold.dart )
31
31
32
- [ Slider] ( /lib/widgets/slider.dart )
32
+ [ Slider] ( /lib/src/ widgets/slider.dart )
33
33
34
- [ Switch] ( /lib/widgets/switches.dart )
34
+ [ Switch] ( /lib/src/ widgets/switches.dart )
35
35
36
- [ TabView] ( /lib/widgets/tabs.dart )
36
+ [ TabView] ( /lib/src/ widgets/tabs.dart )
37
37
38
38
39
39
## Getting Started
@@ -54,10 +54,8 @@ class MyApp extends StatelessWidget {
54
54
Widget build(BuildContext context) {
55
55
return PlatformApp(
56
56
title: 'Flutter Demo',
57
-
58
- // specify Android Material Theme data here. it's a lazy evaluated function, only rendering if platform is Android.
59
- androidTheme: () => ThemeData(
60
-
57
+ // specify our app theme here. We do the leg work of bridging it to Cupertino.
58
+ unifiedTheme: ThemeData(
61
59
primarySwatch: Colors.lightBlue,
62
60
bottomAppBarColor: Colors.red,
63
61
),
@@ -68,14 +66,8 @@ class MyApp extends StatelessWidget {
68
66
69
67
```
70
68
71
- ` PlatformApp ` unifies all of the same properties between ` MaterialApp ` and ` CupertinoApp ` to allow you to choose.
72
-
73
- _ NOTE_ : Not specifying a ` renderPlatform ` will render a ` CupertinoApp ` on ` iOS ` , and might cause issues with widgets that expect
74
- a material app instance.
75
-
76
- _ NOTE_ : There is not a ` CupertinoTheme ` just yet in Flutter. Check out this [ pull request] ( https://github.com/flutter/flutter/pull/23759 ) .
77
- once that is in the main flutter releases, we can then create ` PTheme ` that merges ` MaterialTheme ` and ` CupertinoTheme `
78
- instances. For now it is highly recommended to specify ` targetPlatform: TargetPlatform.android ` in the constructor of ` PlatformApp ` .
69
+ ` PlatformApp ` unifies all of the same properties between ` MaterialApp ` and ` CupertinoApp ` to allow both instances of widgets in the hiearchy and
70
+ switching styling based on platform.
79
71
80
72
Now you replace widgets that are included in this library with their "P" counterparts:
81
73
@@ -101,13 +93,17 @@ Now you replace widgets that are included in this library with their "P" counter
101
93
102
94
` AlertDialog ` /` CupertinoAlertDialog ` -> ` PAlertDialog `
103
95
96
+ ### Properties Specific to a platform have a prefix
104
97
Any widgets that have ios-only or android-only counterparts, they are prefixed to ` android ` /` ios ` accordingly:
105
98
106
99
For example ` PButton ` , ` androidShape ` applies to ` RaisedButton.shape ` property. It does not exist on a ` CupertinoButton ` .
107
100
However ` CupertinoButton ` has a ` borderRadius ` and ` pressedOpacity ` . Those two props become ` iosBorderRadius ` and ` iosPressedOpacity ` .
108
101
109
102
## Helpers
110
103
104
+ This library bundles a few standard functions to easily return code that is unique for each platform. Instead of checking
105
+ and switching on the result of ` Theme.of(context).targetPlatform ` , utilize the following methods:
106
+
111
107
### Specific Platform Instance
112
108
113
109
To have a specific ` P ` -Widget utilize a specific platform theme only, such as Material or Cupertino, you can wrap
@@ -226,4 +222,4 @@ Column(
226
222
],
227
223
),
228
224
229
- ```
225
+ ```
0 commit comments