fitter 1.0.2

  • Readme
  • Changelog
  • Installing
  • 63

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。感谢!

[0.0.1] - 2019.7.2

  • Initial release
    • add custom Material and WidgetApp class
    • add viewConfiguration

[0.0.2] - 2019.7.2

  • Fix bugs
    • remove old logics

[0.0.3] - 2019.7.2

  • Update readme
    • add showcase

[0.0.4] - 2019.7.2

  • update readme
    • add thanks to genius158

[0.1.0] - 2019.7.4

  • support old version
    • support flutter <= 1.1.9
    • support custom design resolution

[1.0.0] - 2019.7.4

  • add dependency
    • add flutter sdk version dependency

[1.0.1] - 2019.7.4

  • support custom
    • support custom design resolution
    • update Readme

[1.0.2] - 2019.7.9

  • update readme
    • update readme, fix some word errors
    • add cn readme, and set default

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  fitter: ^1.0.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:fitter/fitter.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
38
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
68
Overall:
Weighted score of the above. [more]
63
Learn more about scoring.

We analyzed this package on Dec 7, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.6

Health suggestions

Fix lib/viewport/custom_widgetsapp.dart. (-0.50 points)

Analysis of lib/viewport/custom_widgetsapp.dart reported 1 hint:

line 3 col 8: Unused import: 'dart:ui'.

Format lib/fitter.dart.

Run flutter format to format lib/fitter.dart.

Format lib/viewport/view_adapter.dart.

Run flutter format to format lib/viewport/view_adapter.dart.

Maintenance issues and suggestions

Homepage URL doesn't exist. (-20 points)

At the time of the analysis the homepage field https://doc.bytedance.net/docs/357/1201/9422/ was unreachable.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and fitter.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

The package description is too short. (-2 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test