我使用setEnabledSystemUIOverlays隐藏状态栏和虚拟按钮栏。
但屏幕顶部和底部有空白(如图所示):
有谁知道如何解决它?
这是我的代码:
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
SystemChrome.setEnabledSystemUIOverlays([]);
runApp(new MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: "Test",
home: new MyHomePage(title: "Test"),
);
}
}
class MyHomePage extends StatelessWidget {
final String title;
MyHomePage({Key key, this.title}) : super(key: key);
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text(title),
),
body: new Container(
color: Colors.red,
),
);
}
}
答案 0 :(得分:2)
答案 1 :(得分:2)
这对我来说很完美:
@override
Widget build(BuildContext context) {
// To make this screen full screen.
// It will hide status bar and notch.
SystemChrome.setEnabledSystemUIOverlays([]);
// full screen image for splash screen.
return Container(
child: new Image.asset('assets/splash.png', fit: BoxFit.fill));
}
}
导入此
import 'package:flutter/services.dart';
答案 2 :(得分:0)
设置resizeToAvoidBottomPadding:对Scaffold为false。
return Scaffold(
resizeToAvoidBottomPadding: false,
);
答案 3 :(得分:0)
// resizeToAvoidBottomInset: false
不适合我。Container.height = Get.height
// 设置 max height
Container.child.image.fit = BoxFit.fill
// 用这个flutter 2.2.0
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:lottie/lottie.dart';
import '../controllers/splash_controller.dart';
class SplashScreenView extends GetView<SplashController> {
final SplashController c = Get.find();
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
/// key! fix full screen
height: Get.height,
///
child: Lottie.asset(
/// image file:
AppConfig.splash1,
/// key! fix full screen
fit: BoxFit.fill,
///
controller: c.animationController,
frameRate: FrameRate(60),
repeat: true,
///
delegates: LottieDelegates(
text: (initialText) => 'test',
),
onLoaded: (composition) {
c.animationController..duration = composition.duration;
},
),
),
/// not work
// resizeToAvoidBottomInset: false,
backgroundColor: Colors.white,
);
}
}