100日後にFlutter生活:7日目:アニメーションでつまずく。(スルー力発動)
引き続き、Flutterモバイルアプリ開発バイブルを読み進めてます。
が… アニメーションしない…
コードは、なんどか確認したけど、原因わからず… 一晩寝たら、何かわかるかも?何故か直るかも?
と思ったけど、解決せず。
今の実力では、問題解決ができないということやな…
とりあえず、分からない部分はスルーして進みます。
import 'package:flutter/animation.dart'; import 'package:flutter/material.dart'; class LogoAnimationScreen extends StatefulWidget{ @override _LogoAnimationState createState() => _LogoAnimationState(); } class _LogoAnimationState extends State<LogoAnimationScreen> with SingleTickerProviderStateMixin { //追加 AnimationController controller; Animation<double> animation; @override void initState() { super.initState(); controller = AnimationController(duration: Duration(seconds: 2), vsync: this) ..addListener(() { setState(() {}); }); animation = Tween<double>(begin: 10, end: 300).animate(controller); } @override void dispose() { controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) => Scaffold( appBar: AppBar( title: Text('あにめ') ), body: Center( child: Container( margin: EdgeInsets.symmetric(vertical: 10), height: animation.value, width: animation.value, child: FlutterLogo(), ) ) ); }