问题描述
我在初始屏幕中使用的GIF大小没有全屏显示。
我想在整个屏幕上显示此GIT。
请帮助我或以任何方式建议我如何在全屏上显示它。
import 'package:flutter/material.dart';
import 'package:moms_kitchen/login_page.dart';
import 'package:splashscreen/splashscreen.dart';
void main() {
runApp(new MaterialApp(
debugShowCheckedModeBanner: false,home: new MyApp(),));
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return Center(
child: SplashScreen(
seconds: 6,backgroundColor: Colors.white,image: new Image.asset('assets/splash1.gif'),loaderColor: Colors.white,photoSize: 250,navigateAfterSeconds: MainScreen(),),);
}
}
class MainScreen extends StatefulWidget {
@override
_MainScreenState createState() => _MainScreenState();
}
class _MainScreenState extends State<MainScreen> {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Mom's Kitchen",theme: ThemeData(
primarySwatch: Colors.blue,visualDensity: VisualDensity.adaptivePlatformDensity,fontFamily: 'LeonSans'),home: LoginPage(),debugShowCheckedModeBanner: false,);
}
}
解决方法
从这里
backgroundColor: Colors.white,image: new Image.asset('assets/splash1.gif'),loaderColor: Colors.white,photoSize: 250,
您将高度设置为250。
要获取设备屏幕的高度,您可以通过以下方式获取
var height=MediaQuery.of(context).size.height* 1;
然后使用高度作为照片大小
,尝试类似的方法可能会有所帮助
child: Container(
width: MediaQuery.of(context).size.width,height: MediaQuery.of(context).size.height,
,
将SplashScreen
小部件包装在SafeArea
中。
一个小部件,它通过足够的填充来插入其子级,以避免操作系统的入侵。
例如,这将使孩子缩进足够长的距离,以避免屏幕顶部的状态栏。
然后将image
参数和设备尺寸包装在Container
中。
SafeArea(
child: SplashScreen(
...
image: Container(
child: Image.asset('assets/splash1.gif'),width: MediaQuery.of(context).size.width,),