Additional information
TODO: Tell users more about the package: where to find more information, how to contribute to the package, how to file issues, what response they can expect from the package authors, and more.
kg_density
Is a minimalist screen adaptation scheme, which can quickly help the developed project to adapt the screen
Getting started
dependencies:
kg_density: ^0.0.1
The following models are from the iPhone 5S
Before login adaptation
After login adaptation
Before chart page adaptation
After chart page adaptation
Before other pages fit
After other pages are adapted
Usage
- Create flutterbinding
class MyFlutterBinding extends WidgetsFlutterBinding with KgFlutterBinding {
static WidgetsBinding ensureInitialized() {
if (WidgetsBinding.instance == null) MyFlutterBinding();
return WidgetsBinding.instance!;
}
}
- MaterialApp configuration
MaterialApp(
theme: ThemeData(),
builder: KgDensity.initSize(),
);
- Configuration before startup
void main() {
///初始化
KgDensity.initKgDensity(375);
MyFlutterBinding.ensureInitialized();
///运行
runApp(App());
}
Note:
- KgDensity.initSize(builder: ??)
In order to facilitate the configuration of other builders, other builders are specially added to the code
usage method
builder: KgDensity.initSize(builder: EasyLoading.init()),
- KgDensity.initKgDensity(375)
Digital configuration is configured according to the narrowest side of the design manuscript
If you do not use kgdensity for adaptation, do not use init
- Get size correctly
MediaQuery.of(context).size
Please do not use window physicalSize,MediaQueryData. fromWindow(window)
Additional information
This code base is reconstructed with reference to its principle and part of the code. Thank you https://github.com/niezhiyang/flutter_autosize_screen