You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Clean codes & add features & fix bugs
Features/Bugs:
- Feature: You can select what classes needs to be rebuilt instead of rebuilding everything, if you have widget A, either addi SU mixin or add 'A' to list ScreenUtilInit.responsiveWidgets
- Feature: Using ScreenUtilInit.builder is optional (use it only when using library in theme)
- Bug: Second call to ScreenUtil.init ignores any existing values and uses the default values when not provided, use ScreenUtil.configure instead
- Bug: ScreenUtil.ensureScreenSize raises an overflow error
* Update version
* Add List of flutter widgets
* Update logic if allowing widget to being rebuilt
* Little code solidity
* Add scale factors: diagonal & diameter
* Add option for how font size should be scaled
* Update support to Dart >= 2.17.0
* Add fontSizeResolver to init + helpers
* Add ensureScreenSize to ScreenUtilInit constructor
* Fix ensureScreenSize on web
* Update Runner.rc
* Add some methods to extensions
* Update widget_test
* Remove extra deps
* Clean code
* Add ensureScreenSizeAndInit + make init sync
* Update README.md
* Update CHANGELOG.md
* Update version to 5.9.0
* Rename version
* Adding tests
* Changing version in CHANGELOG.md
---------
Co-authored-by: Mounir Bouaiche <[email protected]>
| 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~~|
| 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
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
66
### Initialize and set the fit size and font size to scale according to the system's "font size" accessibility option
59
67
60
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
72
```dart
65
73
void main() => runApp(MyApp());
@@ -74,7 +82,8 @@ class MyApp extends StatelessWidget {
74
82
designSize: const Size(360, 690),
75
83
minTextAdapt: true,
76
84
splitScreenMode: true,
77
-
builder: (context , child) {
85
+
// Use builder only if you need to use library outside ScreenUtilInit context
86
+
builder: (_ , child) {
78
87
return MaterialApp(
79
88
debugShowCheckedModeBanner: false,
80
89
title: 'First Method',
@@ -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**
0 commit comments