Closed
Description
can try this code with flutter 3.10.0 and flutter_screenutil: 5.8.1
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
MyApp({super.key});
@override
Widget build(BuildContext context) {
return ScreenUtilInit(
designSize: const Size(375, 812),
builder: (context, child) {
return const MaterialApp(
home: HomePage(),
);
});
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Flutter Tutorial'),
),
body: Column(
children: [
Center(
child: ElevatedButton(
onPressed: () {
showModalBottomSheet(
context: context,
builder: (context){
return Padding(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: const SizedBox(height: 200, child: TextField()),
);
},
);
},
child: const Text(
'showModalBottomSheet',
),
),
),
],
),
);
}
}
I test only use flutter screenutil can happend
就是当我用这个插件的时候(5.8.1最新版和5.7.0以前用的都尝试了),在3.7.11版本的flutter,是完全没问题的,但是当我升级flutter到3.10.0时,打开键盘不会触发bottomsheet的build了,导致页面无法移动被遮挡,在3.7.11是触发的,不止是bottomsheet,其他的带输入框页面似乎也有这个问题。
当使用方式二加载时不会有这个问题:
void main() async {
// Add this line
await ScreenUtil.ensureScreenSize();
runApp(MyApp());
}
...
MaterialApp(
...
builder: (ctx, child) {
ScreenUtil.init(ctx);
return Theme(
data: ThemeData(
primarySwatch: Colors.blue,
textTheme: TextTheme(bodyText2: TextStyle(fontSize: 30.sp)),
),
child: HomePage(title: 'FlutterScreenUtil Demo'),
);
},
)
Metadata
Metadata
Assignees
Labels
No labels