Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 完成动画时,如何将小部件及其功能传递给main.dart?_Android_Flutter_Flutter Animation - Fatal编程技术网

Android 完成动画时,如何将小部件及其功能传递给main.dart?

Android 完成动画时,如何将小部件及其功能传递给main.dart?,android,flutter,flutter-animation,Android,Flutter,Flutter Animation,我是个新手。在main.dart文件中,我有一个徽标,当我运行应用程序时,徽标会淡入屏幕并进入屏幕顶部。为此,我使用了两个动画控制器 在welcome.dart文件中,有两个按钮(登录和注册)的代码,一个动画控制器用于淡入该按钮的动画 我需要表明,当标志完成动画,显示在屏幕上的按钮淡入动画 我尝试的是将adListener放入徽标动画,当徽标动画完成时,启动按钮动画。但它不起作用 这是我的密码- 主飞镖 import 'package:flutter/material.dart'; import

我是个新手。在main.dart文件中,我有一个徽标,当我运行应用程序时,徽标会淡入屏幕并进入屏幕顶部。为此,我使用了两个动画控制器

在welcome.dart文件中,有两个按钮(登录和注册)的代码,一个动画控制器用于淡入该按钮的动画

我需要表明,当标志完成动画,显示在屏幕上的按钮淡入动画

我尝试的是将adListener放入徽标动画,当徽标动画完成时,启动按钮动画。但它不起作用

这是我的密码-

主飞镖

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'welcome.dart';

void main() {
  runApp(MyApp());

  SystemChrome.setSystemUIOverlayStyle(
    SystemUiOverlayStyle(
        statusBarColor: Colors.transparent,
        statusBarBrightness: Brightness.light),
  );




}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: ('SplashScreeen'),
      home: MySplashScreen(title: 'SplashScreen'),
    );
  }
}

class MySplashScreen extends StatefulWidget {
  MySplashScreen({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MySplashScreenState createState() => _MySplashScreenState();
}

class _MySplashScreenState extends State<MySplashScreen>
    with TickerProviderStateMixin {

  AnimationController fadeAnimationLogoController;
  AnimationController moveUpAnimationLogoController;
  Animation<double> fadeAnimationLogo;
  Animation<Offset> moveUpAnimationLogo;

  initState(){

super.initState();

fadeAnimationLogoController = AnimationController(duration: Duration(milliseconds: 1500),vsync: this);
moveUpAnimationLogoController = AnimationController(duration: Duration(milliseconds: 1000),vsync: this,);
fadeAnimationLogo =CurvedAnimation(parent: fadeAnimationLogoController, curve: Curves.easeIn);
moveUpAnimationLogo = Tween<Offset>(begin: Offset(0,0),end: Offset(0, -0.2),).animate(moveUpAnimationLogoController);

fadeAnimationLogoController.forward();


fadeAnimationLogoController.addListener((){

if(fadeAnimationLogo.status == AnimationStatus.completed){

  moveUpAnimationLogoController.forward();
}



});


  }




  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      child: FadeTransition (
        opacity: fadeAnimationLogo,
        child: SlideTransition(
          position: moveUpAnimationLogo,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Image(
              image: AssetImage('assets/images/csrhuntlogo.png'),
              height: 300,
              width: 300,
            ),
            Text(
              ('C S R  H U N T'),
              style: TextStyle(
                fontFamily: 'League Spartan',
                height: 1,
                fontSize: 34,
                color: Colors.black,
                decoration: TextDecoration.none,
              ),
            ),
            Text(
              ('FIND     PLAY     EARN'),
              style: TextStyle(
                fontFamily: 'Montserrat',
                height: 1,
                fontSize: 15,
                color: Colors.black,
                decoration: TextDecoration.none,
              ),
            ),
          ],
        ),
      ),
      ),
    );

  }

}
导入“包装:颤振/材料.省道”;
导入“包:flifter/services.dart”;
输入“welcome.dart”;
void main(){
runApp(MyApp());
SystemChrome.SetSystemTimeOverlayStyle(
系统样式(
statusBarColor:Colors.transparent,
状态正确性:亮度、亮度、,
);
}
类MyApp扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
返回材料PP(
标题:('SplashScreeen'),
主页:MySplashScreen(标题:“SplashScreen”),
);
}
}
类mysplashsscreen扩展StatefulWidget{
mysplashsscreen({Key,this.title}):super(Key:Key);
最后的字符串标题;
@凌驾
_MySplashScreenState createState()=>\u MySplashScreenState();
}
类_mysplashscrenstate扩展状态
使用TickerProviderStateMixin{
动画控制器fadeAnimationLogoController;
AnimationController moveUpAnimationLogoController;
动画fadeAnimationLogo;
动画移动动画标识;
initState(){
super.initState();
fadeAnimationLogoController=AnimationController(持续时间:持续时间(毫秒:1500),vsync:this);
moveUpAnimationLogoController=AnimationController(持续时间:持续时间(毫秒:1000),vsync:this,);
fadeAnimationLogo=CurvedAnimation(父级:fadeAnimationLogoController,曲线:Curves.easeIn);
moveUpAnimationLogo=Tween(开始:偏移(0,0),结束:偏移(0,-0.2),).animate(moveUpAnimationLogoController);
fadeAnimationLogoController.forward();
fadeAnimationLogoController.addListener((){
如果(fadeAnimationLogo.status==AnimationStatus.completed){
moveUpAnimationLogoController.forward();
}
});
}
@凌驾
小部件构建(构建上下文){
返回容器(
颜色:颜色,白色,
孩子:FadeTransition(
不透明度:fadeAnimationLogo,
子:幻灯片转换(
位置:moveUpAnimationLogo,
子:列(
mainAxisAlignment:mainAxisAlignment.center,
儿童:[
形象(
图像:AssetImage('assets/images/csrhuntlogo.png'),
身高:300,
宽度:300,
),
正文(
("C S R H U N T"),,
样式:TextStyle(
fontFamily:“斯巴达联盟”,
身高:1,,
尺码:34,
颜色:颜色,黑色,
装饰:textEdition.none,
),
),
正文(
(“找到游戏赢取”),
样式:TextStyle(
fontFamily:“蒙特塞拉特”,
身高:1,,
尺寸:15,
颜色:颜色,黑色,
装饰:textEdition.none,
),
),
],
),
),
),
);
}
}
欢迎,达特

import 'package:flutter/material.dart';


class Welcome extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: ('WelcomeScreen'),
      home: WelcomeScreen(title: 'WelcomeScreen'),
    );
  }
}

class WelcomeScreen extends StatefulWidget {
  WelcomeScreen({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _WelcomeScreenState createState() => _WelcomeScreenState();
}

class _WelcomeScreenState extends State<WelcomeScreen>
    with SingleTickerProviderStateMixin {
  AnimationController fadeAnimationWelcomeController;
  Animation<double> fadeAnimationWelcome;

  @override
  void initState() {
    fadeAnimationWelcomeController = AnimationController(
      vsync: this,
      duration: Duration(milliseconds: 2000),
    );
    fadeAnimationWelcome = CurvedAnimation(
        parent: fadeAnimationWelcomeController, curve: Curves.easeIn);
    super.initState();

    fadeAnimationWelcomeController.forward();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      child: FadeTransition(
        opacity: fadeAnimationWelcome,
        child: Stack(
          children: <Widget>[
            Positioned(
              top: 590,
              left: 20,
              child: SizedBox(
                width: 350.0,
                height: 50.0,
                child: RaisedButton(
                  color: new Color.fromRGBO(255, 213, 0, 1.0),
                  textColor: Colors.black,
                  onPressed: () {},
                  child: Text(
                    'log in',
                    style: TextStyle(
                      height: 1,
                      fontSize: 25,
                      fontFamily: 'League Spartan',
                    ),
                  ),
                  shape: RoundedRectangleBorder(
                    borderRadius: new BorderRadius.circular(18.0),
                    side: BorderSide(color: Colors.transparent),
                  ),
                ),
              ),
            ),
            Positioned(
              bottom: 50,
              left: 20,
              child: SizedBox(
                width: 350.0,
                height: 50.0,
                child: RaisedButton(
                  color: new Color.fromRGBO(255, 213, 0, 1.0),
                  textColor: Colors.black,
                  onPressed: () {},
                  child: Text(
                    'Sign up',
                    style: TextStyle(
                      height: 1,
                      fontSize: 25,
                      fontFamily: 'League Spartan',
                    ),
                  ),
                  shape: RoundedRectangleBorder(
                    borderRadius: new BorderRadius.circular(18.0),
                    side: BorderSide(color: Colors.transparent),
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
导入“包装:颤振/材料.省道”;
类欢迎扩展无状态小部件{
@凌驾
小部件构建(构建上下文){
返回材料PP(
标题:('WelcomeScreen'),
主页:WelcomeScreen(标题:“WelcomeScreen”),
);
}
}
类WelcomeScreen扩展StatefulWidget{
WelcomeScreen({Key,this.title}):super(Key:Key);
最后的字符串标题;
@凌驾
_WelcomeScreenState createState()=>\u WelcomeScreenState();
}
类_WelcomeScreenState扩展状态
使用SingleTickerProviderStateMixin{
动画控制器fadeAnimationWelcomeController;
动画fadeAnimationWelcome;
@凌驾
void initState(){
fadeAnimationWelcomeController=动画控制器(
vsync:这个,,
持续时间:持续时间(毫秒:2000),
);
fadeAnimationWelcome=曲线动画(
父对象:fadeAnimationWelcomeController,曲线:Curves.easeIn);
super.initState();
fadeAnimationWelcomeController.forward();
}
@凌驾
小部件构建(构建上下文){
返回容器(
颜色:颜色,白色,
孩子:FadeTransition(
不透明度:fadeAnimationWelcome,
子:堆栈(
儿童:[
定位(
排名:590,
左:20,,
孩子:大小盒子(
宽度:350.0,
身高:50.0,
孩子:升起按钮(
颜色:新颜色。来自RGBO(255213,0,1.0),
textColor:Colors.black,
按下:(){},
子:文本(
“登录”,
样式:TextStyle(
身高:1,,
尺寸:25,
fontFamily:“斯巴达联盟”,
),
),
形状:圆形矩形边框(
边界半径:新边界半径。圆形(18.0),
侧边:边框侧边(颜色:颜色。透明),
),
),
),
),
定位(
底数:50,
左:20,,
孩子:大小盒子(
宽度:350.0,
身高:50.0,
孩子:升起按钮(
颜色:新颜色。来自RGBO(255213,0,1.0),
textColor:Colors.black,
按下:(){},
子:文本(
moveUpAnimationLogoController.addListener(() {
      if (moveUpAnimationLogo.status == AnimationStatus.completed) {
        //moveUpAnimationLogoController.forward();
        setState(() {
          showWelcome = true;
        });
      }
    });

showWelcome
              ? Expanded(
                  child: WelcomeScreen(
                    title: "test",
                  ),
                )
              : Container(),    
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  runApp(MyApp());

  SystemChrome.setSystemUIOverlayStyle(
    SystemUiOverlayStyle(
        statusBarColor: Colors.transparent,
        statusBarBrightness: Brightness.light),
  );
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: ('SplashScreeen'),
      home: MySplashScreen(title: 'SplashScreen'),
    );
  }
}

class MySplashScreen extends StatefulWidget {
  MySplashScreen({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MySplashScreenState createState() => _MySplashScreenState();
}

class _MySplashScreenState extends State<MySplashScreen>
    with TickerProviderStateMixin {
  AnimationController fadeAnimationLogoController;
  AnimationController moveUpAnimationLogoController;
  Animation<double> fadeAnimationLogo;
  Animation<Offset> moveUpAnimationLogo;
  bool showWelcome = false;

  initState() {
    super.initState();

    fadeAnimationLogoController =
        AnimationController(duration: Duration(seconds: 5), vsync: this);
    moveUpAnimationLogoController = AnimationController(
      duration: Duration(seconds: 5),
      vsync: this,
    );
    fadeAnimationLogo = CurvedAnimation(
        parent: fadeAnimationLogoController, curve: Curves.easeIn);
    moveUpAnimationLogo = Tween<Offset>(
      begin: Offset(0, 0),
      end: Offset(0, -0.2),
    ).animate(moveUpAnimationLogoController);

    fadeAnimationLogoController.forward();

    fadeAnimationLogoController.addListener(() {
      if (fadeAnimationLogo.status == AnimationStatus.completed) {
        moveUpAnimationLogoController.forward();
      }
    });

    moveUpAnimationLogoController.addListener(() {
      if (moveUpAnimationLogo.status == AnimationStatus.completed) {
        //moveUpAnimationLogoController.forward();
        setState(() {
          showWelcome = true;
        });
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: <Widget>[
          Container(
            color: Colors.white,
            child: FadeTransition(
              opacity: fadeAnimationLogo,
              child: SlideTransition(
                position: moveUpAnimationLogo,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Image(
                      image: AssetImage('assets/images/csrhuntlogo.png'),
                      height: 300,
                      width: 300,
                    ),
                    Text(
                      ('C S R  H U N T'),
                      style: TextStyle(
                        fontFamily: 'League Spartan',
                        height: 1,
                        fontSize: 34,
                        color: Colors.black,
                        decoration: TextDecoration.none,
                      ),
                    ),
                    Text(
                      ('FIND     PLAY     EARN'),
                      style: TextStyle(
                        fontFamily: 'Montserrat',
                        height: 1,
                        fontSize: 15,
                        color: Colors.black,
                        decoration: TextDecoration.none,
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ),
          showWelcome
              ? Expanded(
                  child: WelcomeScreen(
                    title: "test",
                  ),
                )
              : Container(),
        ],
      ),
    );
  }
}

class WelcomeScreen extends StatefulWidget {
  WelcomeScreen({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _WelcomeScreenState createState() => _WelcomeScreenState();
}

class _WelcomeScreenState extends State<WelcomeScreen>
    with SingleTickerProviderStateMixin {
  AnimationController fadeAnimationWelcomeController;
  Animation<double> fadeAnimationWelcome;

  @override
  void initState() {
    fadeAnimationWelcomeController = AnimationController(
      vsync: this,
      duration: Duration(milliseconds: 2000),
    );
    fadeAnimationWelcome = CurvedAnimation(
        parent: fadeAnimationWelcomeController, curve: Curves.easeIn);
    super.initState();

    fadeAnimationWelcomeController.forward();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      child: FadeTransition(
        opacity: fadeAnimationWelcome,
        child: Stack(
          children: <Widget>[
            Positioned(
              top: 590,
              left: 20,
              child: SizedBox(
                width: 350.0,
                height: 50.0,
                child: RaisedButton(
                  color: new Color.fromRGBO(255, 213, 0, 1.0),
                  textColor: Colors.black,
                  onPressed: () {},
                  child: Text(
                    'log in',
                    style: TextStyle(
                      height: 1,
                      fontSize: 25,
                      fontFamily: 'League Spartan',
                    ),
                  ),
                  shape: RoundedRectangleBorder(
                    borderRadius: new BorderRadius.circular(18.0),
                    side: BorderSide(color: Colors.transparent),
                  ),
                ),
              ),
            ),
            Positioned(
              bottom: 50,
              left: 20,
              child: SizedBox(
                width: 350.0,
                height: 50.0,
                child: RaisedButton(
                  color: new Color.fromRGBO(255, 213, 0, 1.0),
                  textColor: Colors.black,
                  onPressed: () {},
                  child: Text(
                    'Sign up',
                    style: TextStyle(
                      height: 1,
                      fontSize: 25,
                      fontFamily: 'League Spartan',
                    ),
                  ),
                  shape: RoundedRectangleBorder(
                    borderRadius: new BorderRadius.circular(18.0),
                    side: BorderSide(color: Colors.transparent),
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}