李卓原

代码优化

... ... @@ -13,12 +13,13 @@ class MyApp extends StatelessWidget {
builder: (_, child) {
return MaterialApp(
debugShowCheckedModeBanner: false,
useInheritedMediaQuery: true,
title: 'First Method',
// You can use the library anywhere in the app even in theme
theme: ThemeData(
primarySwatch: Colors.blue,
textTheme: Typography.englishLike2018.apply(fontSizeFactor: 1.sp),
textTheme: Typography(platform: TargetPlatform.iOS)
.black
.apply(fontSizeFactor: 1),
),
home: child,
);
... ...
... ... @@ -98,7 +98,13 @@ class HomePageScaffold extends StatelessWidget {
return Dialog(
child: Padding(
padding: EdgeInsets.all(12.r),
child: const Text('Dialog'),
child: Column(
children: [
const Text('Dialog'),
Spacer(),
TextField(),
],
),
),
);
},
... ... @@ -124,7 +130,8 @@ class HomePageScaffold extends StatelessWidget {
context: context,
builder: (BuildContext context) {
return Container(
height: 200.w,
height: 200.w +
MediaQuery.of(context).viewInsets.bottom,
color: Colors.amber,
child: Center(
child: Column(
... ... @@ -132,10 +139,16 @@ class HomePageScaffold extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const Text('Modal BottomSheet'),
Spacer(),
TextField(),
ElevatedButton(
child: const Text('Close BottomSheet'),
onPressed: Navigator.of(context).pop,
)
),
SizedBox(
height: MediaQuery.of(context)
.viewInsets
.bottom),
],
),
),
... ...
... ... @@ -61,7 +61,7 @@ class MyThemedApp extends StatelessWidget {
return Theme(
data: ThemeData(
primarySwatch: Colors.blue,
textTheme: TextTheme(bodyText2: TextStyle(fontSize: 30.sp)),
textTheme: TextTheme(bodyMedium: TextStyle(fontSize: 30.sp)),
),
child: HomePage(title: 'FlutterScreenUtil Demo'),
);
... ...
... ... @@ -16,7 +16,7 @@ class MyApp extends StatelessWidget {
// You can use the library anywhere in the app even in theme
theme: ThemeData(
primarySwatch: Colors.blue,
textTheme: TextTheme(bodyText2: TextStyle(fontSize: 30.sp)),
textTheme: TextTheme(bodyMedium: TextStyle(fontSize: 30.sp)),
),
home: child,
);
... ...
... ... @@ -60,7 +60,7 @@ class MyThemedApp extends StatelessWidget {
return Theme(
data: ThemeData(
primarySwatch: Colors.blue,
textTheme: TextTheme(bodyText2: TextStyle(fontSize: 30.sp)),
textTheme: TextTheme(bodyMedium: TextStyle(fontSize: 30.sp)),
),
child: HomePage(title: '第二种方法(带主题)'),
);
... ...