【问题标题】:how to controll the photo size in flutter splashscreen如何控制颤动闪屏中的照片大小
【发布时间】:2021-11-10 10:41:19
【问题描述】:

我需要知道如何控制初始屏幕上图像(gif)的大小 该属性被命名为 PhotoSize,但没有说明如何使用它

我需要图像是全宽和全高

enter image description here

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,
    ),
    );
 }
 }

【问题讨论】:

标签: flutter splash-screen


【解决方案1】:

让我为您节省时间。

你可以使用自带很多功能和支持flutter闪屏的包。

link

以下是我创建的示例代码:

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,
    );
  }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-12-26
    • 2021-05-30
    • 2019-07-15
    • 1970-01-01
    • 1970-01-01
    • 2020-12-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多