中文 | EN
UI Responsive fitting approach according to screent width!
Include codes below, and it works:
your app will automatically scale itself like rem
does in web...
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!')
),
);
}
}
The default design resolution is width of 375 pixels, If you wanna custom design resolution, just add a line:
...
void main() {
// custom design resolution
ViewAdapter.screenWidth = 375;
InnerWidgetsFlutterBinding.ensureInitialized()
..attachRootWidget(new MyApp())
..scheduleWarmUpFrame();
}
...
- If wanna support old version flutter sdk, please set
fitter
version^0.1.0
fitter
version^1.0.0
required flutter sdk version to be above1.2.0
UIKitView
components(likewebview
orvideo
..) doesn't work as expected, and I'm not really clear about the reason now yet...- Depend on
flutter sdk
1.2+ version, error occurs on below versions, If wanna support old version flutter sdk, please setfitter
version^0.1.0
Strong inspired by @genius158 and his post.