Flutter 振作精神';价值';在null上调用了接收方:空/尝试调用:值
我正在360度设置图像动画,我编写代码并初始化一些属性代码如下:Flutter 振作精神';价值';在null上调用了接收方:空/尝试调用:值,flutter,Flutter,我正在360度设置图像动画,我编写代码并初始化一些属性代码如下: import 'package:flutter/material.dart'; import 'dart:math' as math; class BasicAnimations extends StatefulWidget { @override _BasicAnimationsState createState() => _BasicAnimationsState(); } class _BasicAnima
import 'package:flutter/material.dart';
import 'dart:math' as math;
class BasicAnimations extends StatefulWidget {
@override
_BasicAnimationsState createState() => _BasicAnimationsState();
}
class _BasicAnimationsState extends State<BasicAnimations>
with SingleTickerProviderStateMixin {
Animation<double> _animation;
AnimationController _animationController;
@override
void initState() {
_animationController = AnimationController(duration: Duration(milliseconds: 1500) ,vsync: this);
_animation = Tween<double>(begin: 0, end: 2 * math.pi).animate(_animationController);
_animationController.forward();
super.initState();
}
@override
void dispose() {
_animationController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Basic Animations"),
),
有什么解决办法吗?提前感谢:)写下以下内容:
AnimationController _animationController = AnimationController();
您需要先实例化它
AnimationController
,然后调用它,就像您通常使用TextEditingControllerd和其他控制器一样。我运行您的代码及其工作:)
AnimationController _animationController = AnimationController();