这个断言现在跟着我因为某种原因使用不同的代码,搜索它,发现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.
Run Code Online (Sandbox Code Playgroud)
`
当我意外地使用 (parent: 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();
}
Run Code Online (Sandbox Code Playgroud)
本来应该是这样的:
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();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1572 次 |
| 最近记录: |