Skip to content

smartbackme/KgDensity

Repository files navigation

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

  1. Create flutterbinding
class MyFlutterBinding extends WidgetsFlutterBinding with KgFlutterBinding {

  static WidgetsBinding ensureInitialized() {
    if (WidgetsBinding.instance == null) MyFlutterBinding();
    return WidgetsBinding.instance!;
  }
}
  1. MaterialApp configuration
MaterialApp(
              theme: ThemeData(),
              builder: KgDensity.initSize(),

            );
  1. Configuration before startup
    void main() {
      ///初始化
      KgDensity.initKgDensity(375);
      MyFlutterBinding.ensureInitialized();
      ///运行
      runApp(App());
    }

Note:

  1. 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()),
  1. 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

  1. 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

About

KgDensity is flutter screen adaption

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages