flutter - 如何控制颤动闪屏中的照片大小
问题描述
我需要知道如何控制启动屏幕上图像(gif)的大小,该属性名为 PhotoSize,但没有关于如何使用它的抽取
我需要图像是全宽和全高
import 'dart:async';
import 'package:advika/screens/walkthrough/walkthrough.dart';
import 'package:advika/utils/scale_util.dart';
import 'package:flutter/material.dart';
import 'package:splashscreen/splashscreen.dart';
class Splash extends StatefulWidget {
static final String path = "/splash";
@override
_SplashState createState() => _SplashState();
}
class _SplashState extends State<Splash> {
@override
void initState() {
super.initState();
Timer(Duration(seconds: 8), () {
Navigator.pushNamedAndRemoveUntil(
context, WalkthroughScreen.path, (r) => false);
});
}
@override`enter code here`
Widget build(BuildContext context) {`enter code here`
return Container(
child: SplashScreen(
seconds: 8,
image: new Image.asset(
'assets/images/loading.gif',
fit: BoxFit.cover,
),
backgroundColor: Colors.black,
photoSize: 300,
onClick: () => print("Oops "),
loaderColor: Colors.white,
),
);
}
}
解决方案
让我为您节省时间。
您可以使用带有许多功能并支持颤振闪屏的软件包。
包链接
下面是我创建的示例代码:
import 'package:flutter/material.dart';
import 'package:splashscreen/splashscreen.dart';
class Splash_Screen extends StatefulWidget {
Splash_Screen({Key key}) : super(key: key);
@override
_Splash_ScreenState createState() => _Splash_ScreenState();
}
class _Splash_ScreenState extends State<Splash_Screen> {
@override
Widget build(BuildContext context) {
return SplashScreen(
seconds: 6,
navigateAfterSeconds: HomeScreen(), // screen you want to navigate to
title: new Text(
'Stack Overflow',
textAlign: TextAlign.center,
style: new TextStyle(
fontWeight: FontWeight.bold,
fontSize: 24.0,
color: Colors.blue,
),
),
image: new Image.asset('assets/images/so.png'),
loadingText: Text('Loading'),
backgroundColor: Colors.white54,
styleTextUnderTheLoader: new TextStyle(),
photoSize: 100.0,
loaderColor: Colors.blue,
);
}
}