不同屏幕之間的尺寸適配 使用插件?flutter_screenutil
flutter_screenutil
flutter 屏幕適配方案,用于調(diào)整屏幕和字體大小的flutter插件,讓你的UI在不同尺寸的屏幕上都能顯示合理的布局!
安裝
# add flutter_screenutil文章來源:http://www.zghlxwxcb.cn/news/detail-658433.html
flutter_screenutil: ^5.8.4文章來源地址http://www.zghlxwxcb.cn/news/detail-658433.html
@override
Widget build(BuildContext context) {
return ScreenUtilInit(
designSize: const Size(365, 812),
minTextAdapt: true,
splitScreenMode: true,
builder: (context, child) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Pipi',
// You can use the library anywhere in the app even in theme
theme: ThemeData(
primarySwatch: Colors.blue,
textTheme: Typography.englishLike2018.apply(fontSizeFactor: 1.sp),
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
builder: (context, widget) {
return MediaQuery(
///設(shè)置文字大小不隨系統(tǒng)設(shè)置改變
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
child: widget as Widget,
);
},
home: const MyHomePage(title: 'Pipi'),
);
});
}
dependencies: # add flutter_screenutil flutter_screenutil: ^5.8.4
到了這里,關(guān)于flutter-移動(dòng)端適配的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!