gpt4 book ai didi

flutter - 动画失败断言 flutter

转载 作者:行者123 更新时间:2023-12-03 13:30:22 24 4
gpt4 key购买 nike

这个断言现在跟着我因为某种原因使用不同的代码,搜索它,发现flutter团队现在还没有解决它,我们有什么可以做的吗?

v`I/flutter ( 5598): Another exception was thrown: 
'package:flutter/src/animation/animations.dart': Failed assertion: line
376 pos 15: 'parent != null': is not true.
I/chatty ( 5598): uid=10085(com.example.gam3ity_aa) 1.ui identical 21
lines
I/flutter ( 5598): Another exception was thrown:
'package:flutter/src/animation/animations.dart': Failed assertion: line
376 pos 15: 'parent != null': is not true.
I/flutter ( 5598): Another exception was thrown:
'package:flutter/src/animation/animations.dart': Failed assertion: line
376 pos 15: 'parent != null': is not true.
I/chatty ( 5598): uid=10085(com.example.gam3ity_aa) 1.ui identical 10
lines
I/flutter ( 5598): Another exception was thrown:
'package:flutter/src/animation/animations.dart': Failed assertion: line
376 pos 15: 'parent != null': is not true.
I/flutter ( 5598): Another exception was thrown:
'package:flutter/src/animation/animations.dart': Failed assertion: line
376 pos 15: 'parent != null': is not true.
I/chatty ( 5598): uid=10085(com.example.gam3ity_aa) 1.ui identical 8
lines
I/flutter ( 5598): Another exception was thrown:
'package:flutter/src/animation/animations.dart': Failed assertion: line
376
pos 15: 'parent != null': is not true.

`

最佳答案

当我不小心用(父级:null)创建了一个 Tween 对象时发生了这种情况

  @override
void initState() {
_animation = Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: null, // <---------------- This line should be an AnimationController
curve: widget.curve,
reverseCurve: widget.reverseCurve ?? widget.curve,
));
super.initState();
}
它应该是这样的:
  AnimationController _animationController;
Animation _animation;

@override
void initState() {
_animationController = AnimationController(
duration: Duration(milliseconds: 500),
reverseDuration: Duration(milliseconds: 1000),
vsync: this,
value: 1.0
);
_animation = Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: _animationController,
curve: widget.curve,
reverseCurve: widget.reverseCurve ?? widget.curve,
));
super.initState();
}

关于flutter - 动画失败断言 flutter ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57079918/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com