Showing
1 changed file
with
27 additions
and
16 deletions
@@ -38,28 +38,36 @@ dependencies: | @@ -38,28 +38,36 @@ dependencies: | ||
38 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 38 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
39 | ``` | 39 | ``` |
40 | 40 | ||
41 | -### Property | ||
42 | - | ||
43 | -| Property | Type | Default Value | Description | | ||
44 | -| --------------- |--------------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------| | ||
45 | -| deviceSize | Size | null | The size of the physical device | | ||
46 | -| designSize | Size | Size(360,690) | The size of the device screen in the design draft, in dp | | ||
47 | -| builder | Function | null | Return widget that uses the library in a property (ex: MaterialApp's theme) | | ||
48 | -| child | Widget | null | A part of builder that its dependencies/properties don't use the library | | ||
49 | -| rebuildFactor | Function | *default* | Returns whether to rebuild or not when screen metrics changes. | | ||
50 | -| orientation | Orientation | portrait | screen orientation | | ||
51 | -| splitScreenMode | bool | false | support for split screen | | ||
52 | -| minTextAdapt | bool | false | Whether to adapt the text according to the minimum of width and height | | ||
53 | -| context | BuildContext | null | Get physical device data if not provided, by MediaQuery.of(context) | | ||
54 | -| useInheritedMediaQuery | bool | false | Recommended use `false` avoid rebuild very frequently <br/><br/> ~~Set this to true for Flutter 3.10 to avoid keyboard overlay on TextField~~ | | 41 | +### Properties |
42 | + | ||
43 | +| Property | Type | Default Value | Description | | ||
44 | +| ---------------- |--------------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------| | ||
45 | +| designSize | Size | Size(360,690) | The size of the device screen in the design draft, in dp | | ||
46 | +| builder | Function | null | Return widget that uses the library in a property (ex: MaterialApp's theme) | | ||
47 | +| child | Widget | null | A part of builder that its dependencies/properties don't use the library | | ||
48 | +| rebuildFactor | Function | *default* | Function that take old and new screen metrics and returns whether to rebuild or not when changes. | | ||
49 | +| splitScreenMode | bool | false | support for split screen | | ||
50 | +| minTextAdapt | bool | false | Whether to adapt the text according to the minimum of width and height | | ||
51 | +| context | BuildContext | null | Get physical device data if not provided, by MediaQuery.of(context) | | ||
52 | +| fontSizeResolver | Function | *default* | Function that specify how font size should be adapted. Default is that font size scale with width of screen. | | ||
53 | +| reponsiveWidgets | Iterable<String> | null | List/Set of widget names that should be included in rebuilding tree. (See [How flutter_screenutil marks a widget needs build](#rebuild-list)) | | ||
55 | 54 | ||
56 | **Note : You must either provide builder, child or both.** | 55 | **Note : You must either provide builder, child or both.** |
57 | 56 | ||
57 | +### Rebuild list | ||
58 | +Starting from version 5.9.0, ScreenUtilInit won't rebuild the whole widget tree, instead it will mark widget needs build only if: | ||
59 | +- Widget is not a flutter widget (widgets are available in [Flutter Docs](https://docs.flutter.dev/reference/widgets)) | ||
60 | +- Widget does not start with underscore (`_`) | ||
61 | +- Widget does not declare `SU` mixin | ||
62 | +- `reponsiveWidgets` does not contains widget name | ||
63 | + | ||
64 | +If you have a widget that uses the library and doesn't meet these options you can either add `SU` mixin or add widget name in responsiveWidgets list. | ||
65 | + | ||
58 | ### Initialize and set the fit size and font size to scale according to the system's "font size" accessibility option | 66 | ### Initialize and set the fit size and font size to scale according to the system's "font size" accessibility option |
59 | 67 | ||
60 | Please set the size of the design draft before use, the width and height of the design draft. | 68 | Please set the size of the design draft before use, the width and height of the design draft. |
61 | 69 | ||
62 | -#### The first way (You must use it once in your app) | 70 | +#### The first way (You should use it once in your app) |
63 | 71 | ||
64 | ```dart | 72 | ```dart |
65 | void main() => runApp(MyApp()); | 73 | void main() => runApp(MyApp()); |
@@ -74,7 +82,8 @@ class MyApp extends StatelessWidget { | @@ -74,7 +82,8 @@ class MyApp extends StatelessWidget { | ||
74 | designSize: const Size(360, 690), | 82 | designSize: const Size(360, 690), |
75 | minTextAdapt: true, | 83 | minTextAdapt: true, |
76 | splitScreenMode: true, | 84 | splitScreenMode: true, |
77 | - builder: (context , child) { | 85 | + // Use builder only if you need to use library outside ScreenUtilInit context |
86 | + builder: (_ , child) { | ||
78 | return MaterialApp( | 87 | return MaterialApp( |
79 | debugShowCheckedModeBanner: false, | 88 | debugShowCheckedModeBanner: false, |
80 | title: 'First Method', | 89 | title: 'First Method', |
@@ -169,6 +178,8 @@ class _HomePageState extends State<HomePage> { | @@ -169,6 +178,8 @@ class _HomePageState extends State<HomePage> { | ||
169 | } | 178 | } |
170 | ``` | 179 | ``` |
171 | 180 | ||
181 | +**Note: calling ScreenUtil.init second time, any non-provided parameter will not be replaced with default value. Use ScreenUtil.configure instead** | ||
182 | + | ||
172 | ### API | 183 | ### API |
173 | 184 | ||
174 | #### Pass the dp size of the design draft | 185 | #### Pass the dp size of the design draft |
-
Please register or login to post a comment