GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — KgDensity/README-zh.md at main · smartbackme/KgDensity

Expand file tree

/

README-zh.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
113 lines (64 loc) · 2.03 KB
/

README-zh.md

Copy path

File metadata and controls

113 lines (64 loc) · 2.03 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

kg_density

kg_density 是一个极简的屏幕适配方案,可以快速的帮助已经开发好的项目适配屏幕

开始集成

dependencies:
  kg_density: ^0.0.1

以下机型来自 iphone5s

登录适配之前

登录适配之后

图表页面适配之前

图表页面适配之后

其他页面适配之前

其他页面适配之后

使用方法:

  1. 创建 FlutterBinding
class MyFlutterBinding extends WidgetsFlutterBinding with KgFlutterBinding {

  static WidgetsBinding ensureInitialized() {
    if (WidgetsBinding.instance == null) MyFlutterBinding();
    return WidgetsBinding.instance!;
  }
}
  1. MaterialApp 配置
MaterialApp(
              ///定义主题
              theme: ThemeData(),
              builder: KgDensity.initSize(),

            );
  1. 启动前的配置
    void main() {
      ///初始化
      KgDensity.initKgDensity(375);
      MyFlutterBinding.ensureInitialized();
      ///运行
      runApp(App());
    }

注意说明:

  1. KgDensity.initSize(builder: ??)

为了方便其他builder配置,代码中专门增加其他builder

使用方法

    builder: KgDensity.initSize(builder: EasyLoading.init()),
  1. KgDensity.initKgDensity(375)

数字配置的是按照设计稿件的最窄边来配置的

若不使用KgDensity 进行适配,请不要init

  1. 正确获取size
    MediaQuery.of(context).size

请不要使用 window.physicalSize,MediaQueryData.fromWindow(window)

本代码库参考其原理与部分代码,重构而成,感谢 https://github.com/niezhiyang/flutter_autosize_screen

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.