не работает класс вперед - PullRequest
       1

не работает класс вперед

0 голосов
/ 21 сентября 2018

Я довольно новичок, чтобы трепетать.Это не так сложно, но я потерян в этом пункте моего кода.У меня есть initState запуска анимации, когда виджет загружается после перехода к нему.В качестве обходного пути у меня есть другая анимация в конце initState, чтобы убедиться, что анимации запущены.Без этого обходного пути ни одна из анимаций не запускается, однако при перезагрузке класса / страницы анимация работает.Я включил все виджеты, которые необходимы, чтобы понять проблемы.

import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'dart:async';
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:challengeme/code/globals.dart';
import 'package:challengeme/code/widgets.dart';
import 'package:challengeme/code/navigator.dart';
import 'package:challengeme/code/AnimationSheet.dart';
import 'package:challengeme/screens/home.dart';


class completeProfile extends StatefulWidget {
 @override
 completeProfileState createState() => new completeProfileState();
}

class completeProfileState extends State<completeProfile>
    with TickerProviderStateMixin {

  AnimationSheet _animationName,  _animationLastname;   
  Animation _animation;
  Animation<double> _ResizeAnimation, _opacity;
  AnimationController _controller, _resizeBtn, _anim_controller;

  @override
  void initState() {
    super.initState();

    _controller = new AnimationController(duration: const Duration(milliseconds: 3000),vsync: this,);
    // use animations by importing them from the AnimationSheet
    _animationName = AnimationSheet(_controller, 0.00, 0.500);

    // this function is here to fire the control forward function, other wise the animations wont run
    _opacity = new CurvedAnimation(parent: _controller, curve: Curves.easeInOut)
    ..addListener((){
    setState((){
          });
    });
    _controller.forward().orCancel;


  }

  @override
  void dispose() {
    super.dispose();
    _controller.dispose();
  }


  @override
  Widget build(BuildContext context) {
    // this disables the android system back button
    return new WillPopScope(
     onWillPop: () async => false,
       child: new Scaffold(
          appBar: AppBar(
            title: Text('$pageTitle'),
            automaticallyImplyLeading: false,
            centerTitle: true,
            backgroundColor: const Color(0xFF0e1f2f),
      ),
      body: new Stack(
        fit: StackFit.expand,
        children: <Widget>[
          new Image(
            image: new AssetImage("assets/background_0.jpg"),
            fit: BoxFit.cover,
//          colorBlendMode: BlendMode.darken,
//          color: Colors.black12,
          ),
          new SingleChildScrollView(
                child: new Theme(
                  data: new ThemeData(
                    brightness: Brightness.dark,
                    inputDecorationTheme: new InputDecorationTheme(
                    // hintStyle: new TextStyle(color: Colors.blue, fontSize: 20.0),
                    fillColor: const Color(0x26ffffff),
                    filled: true,
                    contentPadding: const EdgeInsets.only(bottom: 20.0),
                    labelStyle: new TextStyle(color: Colors.white, fontSize: 16.0, fontWeight: FontWeight.w700),
                    )
                  ),
              isMaterialAppTheme: true,
              child: new Container(
                 padding: const EdgeInsets.only(left: 20.0, right: 20.0, top: 60.0),
              child: new Column(
                      children: <Widget>[
                      new Opacity(
                        opacity:  animationSheet.easeInAnimation.value ,
                        child: new Container(
                          margin: EdgeInsets.only(bottom:10.0),
                        child: new TextFormField(
                          controller: getFirstName,
                          decoration: new InputDecoration(
                              labelText: '$name', 
                          ),
                          keyboardType: TextInputType.emailAddress,
                        ),
                      ),
                      ),

Этот стек не закрыт, так как он служит только примером кода.

это класс анимации:

    import 'package:flutter/material.dart';

class AnimationSheet {
  AnimationSheet(this.controller, this.begin, this.end)

: easeInAnimation = new Tween(begin: 0.0, end: 1.0).animate(
    new CurvedAnimation(
      parent: controller,
      curve: new Interval(
       begin,
       end,
        curve: Curves.easeInOut,
      ),
    ),
  );


  final AnimationController controller;
  final double begin, end;
  final Animation<double> easeInAnimation, easeInAnimation2;


}

Суть этой проблемы здесь, я думаю:

 @override
      void initState() {
        super.initState();

        _controller = new AnimationController(duration: const Duration(milliseconds: 3000),vsync: this,);
        // use animations by importing them from the AnimationSheet
        _animationName = AnimationSheet(_controller, 0.00, 0.500);

        // this function is here to fire the control forward function, other wise the animations wont run
        _opacity = new CurvedAnimation(parent: _controller, curve: Curves.easeInOut)
        ..addListener((){
        setState((){
              });
        });
        _controller.forward().orCancel;

Понятия не имею, когда я делаю неправильно,Может быть, кто-то может сказать мне.Спасибо.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...