i am trying to make a full screen flutter app.
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
));
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: green),
useMaterial3: true
),
home: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
color: Colors.red,
),
);
}
}
it hide the status bar but still taking space as black.The red color container not taking the space of status bar.
2
Answers
Please try it using the following way :
I also have a fullscreen app, this is what my code looks like:
(Make sure to not use SafeArea() widget)
Try to use SystemChrom.setEnabledSystemUiMode inside your build method, not on main(). Also, set
extendBodyBehindAppBar
to true.