blog

flutter-AnimationControllerを使う

インポート '';\nインポート '';\nmat として 'dart:math' をインポートします。...

Apr 27, 2020 · 1 min. read
シェア
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'dart:math' as math;
class AnimatedDemo extends StatefulWidget {
 static const String sName = 'animatedDemo';
 @override
 _AnimatedDemoState createState() => _AnimatedDemoState();
}
class _AnimatedDemoState extends State<AnimatedDemo>
 with TickerProviderStateMixin {
 AnimationController animationController;
 Animation animation;
 @override
 void initState() {
 // TODO: implement initState
 super.initState();
 animationController =
 AnimationController(vsync: this, duration: Duration(seconds: 2))
 ..addStatusListener((status) {
 if (status == AnimationStatus.completed) {
 animationController.reverse();
 } else if (status == AnimationStatus.dismissed) {
 animationController.forward();
 }
 });
 animation =
 Tween(begin: 0.0, end: 2.0 * math.pi).animate(animationController);
 animationController.forward();
 }
 @override
 void dispose() {
 // TODO: implement dispose
 super.dispose();
 animationController.dispose();
 }
 @override
 Widget build(BuildContext context) {
 return Scaffold(
 appBar: AppBar(title: Text('animated_demo')),
 body: AnimatedBuilder(
 animation: animation,
 builder: (BuildContext context, Widget child) {
 return Transform.rotate(angle: animation.value, child: child);
 },
 child: FlutterLogo(size: 60,),
 ),
 );
 }
}
Read next

iOSの開発 - 3レベルのディレクトリは、クリックすると、効果を拡大縮小する

コアコードは、このコードは、ネットワーク要求を模倣することです、その主な役割は、データモデルに値を割り当てることです。 コアコード2、このコードはセルのクリックイベント、セルの2番目のレベルの最初のレベルをクリックすると、表示または収縮の効果があります。 デモアドレスは、全体的なコードのロジックは複雑ではない、あなたの仲間を歓迎し、一緒に交換し、学ぶことができます。

Apr 27, 2020 · 3 min read