我无法解决颤动闪屏中的尺寸问题

问题描述

我在初始屏幕中使用的GIF大小没有全屏显示。

splash screen

我想在整个屏幕上显示此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,),

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...