Giter Club home page Giter Club logo

fitter's Introduction

fitter

中文 | EN

Flutter项目的多尺寸UI适配方案

Getting Started

在项目中引入如下代码,可以达到类rem的适配效果:

import 'package:fitter/fitter.dart';

void main() {
    // maybe your old code here?
    // runApp(MyApp());

    // and just change your code as below
    InnerWidgetsFlutterBinding.ensureInitialized()
      ..attachRootWidget(new MyApp())
      ..scheduleWarmUpFrame();
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // another old code maybe
    // return new MaterialApp(

    // need to replace `MaterialApp` into `CustomMaterialApp` 
    return new CustomMaterialApp(
      home: new Scaffold(
        body: Text('Hello World!')
      ),
    );
  }
}

默认的设计分辨率为宽度375px,如果想要自定义设计分辨率,那么加一行代码:

...
void main() {
    // custom design resolution
    ViewAdapter.screenWidth = 375;
    
    InnerWidgetsFlutterBinding.ensureInitialized()
      ..attachRootWidget(new MyApp())
      ..scheduleWarmUpFrame();
}
...

Old Versions

  • 如果要支持旧版本flutter SDK, 设置引用的fitter 版本号为 ^0.1.0
  • fitter^1.0.0 版本依赖 flutter sdk 版本大于等于 1.2.0

Kown Bugs

  • UIKitView 相关的组件(如webviewvideo..) 并不能适配尺寸,原因尚未弄清楚...
  • Fitter 1.0+ 版本依赖 flutter sdk 1.2+ 版本, 低版本会报错, 如要支持1.2以下版本,请使用 0.1.x版本的 Fitter

Thanks To

思路来源于 @genius158 的文章 post。感谢!

fitter's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

fitter's Issues

'ui.Window' not found.

fitter-1.0.2/lib/viewport/view_adapter.dart:19:46: Error: Type 'ui.Window' not found.
  static MediaQueryData coposeMediaQueryData(ui.Window window) {
                                             ^^^^^^^^^













../../../flutter/.pub-cache/hosted/pub.flutter-io.cn/fitter-1.0.2/lib/viewport/custom_widgetsapp.dart:623:7: Error: The non-abstract class '_CustomWidgetsAppState' is missing implementations for these members:
 - WidgetsBindingObserver.didPushRouteInformation
Try to either

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.