颤振网中的初始屏幕



在各自的文件夹中有Android和ios启动画面,我们可以更改。颤振网有启动画面吗?我在加载网页之前看到白屏。我们怎样才能改变这一点?这是初始屏幕还是加载等待时间?

您现在看到的白屏是因为加载时间



为使用初始屏幕所做的

我先启动我的初始屏幕,然后在init方法中

我正在使用计时器,一旦计时器结束

我正在呼叫另一个页面

主飞镖

import 'package:flutter/material.dart';
import 'src/splash_screen.dart';
main() {
runApp(App());
}
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'AppName',
theme: ThemeData(
primaryColor: Colors.white,
backgroundColor: Colors.white,
primaryIconTheme: new IconThemeData(color: Colors.black),
),
home: SplashScreen());
}
}

splash_screen.飞镖

import "package:flutter/material.dart";
import 'dart:async';
import 'login/login.dart';
class SplashScreen extends StatefulWidget {
_SplashScreenState createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
@override
void initState() {
super.initState();
new Timer(new Duration(milliseconds: 1000), () { // set your desired delay time here
Navigator.of(context).pushReplacement(
new MaterialPageRoute(builder: (context) => new LoginScreen()));
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: Container(
alignment: Alignment.center,
child: Image.asset(fullLogoPng,
width: MediaQuery.of(context).size.width / 1.5,
fit: BoxFit.scaleDown),
),
);
}
}

带动画的 Spash 屏幕

主飞镖

import 'package:flutter/material.dart';
import 'src/splash_screen.dart';
main() {
runApp(App());
}
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
color: Colors.white,
debugShowCheckedModeBanner: false,
theme: ThemeData(
primaryColor: Colors.purple,
primarySwatch: Colors.purple,
fontFamily: 'FIRSNEUE'),
home: SplashScreen());
}
}

启动画面.dart

import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class SplashScreen extends StatefulWidget {
@override
SplashScreenState createState() => new SplashScreenState();
}
class SplashScreenState extends State<SplashScreen>
with SingleTickerProviderStateMixin {
var _visible = true;
AnimationController animationController;
Animation<double> animation;
startTime() async {
var _duration = new Duration(seconds: 3);  //SetUp duration here
return new Timer(_duration, navigationPage);
}
void navigationPage() {
Navigator.of(context).pushReplacementNamed(HOME_SCREEN);
}
@override
void initState() {
super.initState();
animationController = new AnimationController(
vsync: this, duration: new Duration(seconds: 2));
animation =
new CurvedAnimation(parent: animationController, curve: Curves.easeOut);
animation.addListener(() => this.setState(() {}));
animationController.forward();
setState(() {
_visible = !_visible;
});
startTime();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
fit: StackFit.expand,
children: <Widget>[
new Column(
mainAxisAlignment: MainAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Padding(padding: EdgeInsets.only(bottom: 30.0),child:new 
Image.asset('assets/img.png',height: 25.0,fit: BoxFit.scaleDown,))

],),
new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Image.asset(
'assets/logo.png',
width: animation.value * 250,
height: animation.value * 250,
),
],
),
],
),
);
}
}

当您的应用程序打开时,本机应用程序加载 Flutter 会有一小段时间。默认情况下,在此期间,本机应用会显示白色初始屏幕。

您可以使用包含使用此包的丰富文档的flutter_native_splash来更改此设置。

你不需要阅读休息文本,只需flutter_native_splash。

从设置此软件包的启动画面开始,它带有一些参数,如background_imagecolorimage启动画面等,可用于修改启动画面。

我的flutter_native_splash.yaml文件(在根目录上(包含

flutter_native_splash:
color: "#FFFFFF" #backgound color
image: assets/images/splash.png

只需在终端上运行即可生成初始屏幕。

flutter pub run flutter_native_splash:create

使用此初始屏幕 一个启动画面包,用于任何颤振应用程序的介绍,易于进行大量定制

相关内容

  • 没有找到相关文章

最新更新