我试图使用TweenAnimationBuilder<bool>
,但即使有异常日志,我也真的不知道出了什么问题。在发布此问题之前,我已经厌倦了谷歌搜索,但这没有帮助。
例外:
Class 'bool' has no instance method '-'.
Receiver: true
Tried calling: -(false)
The relevant error-causing widget was TweenAnimationBuilder<bool>
代码:
@override
Widget build(BuildContext context) {
return TweenAnimationBuilder<bool>(
duration: Duration(seconds: 2),
tween: Tween<bool>(begin: false, end: true),
builder: (BuildContext context, bool tween, Widget child) {
print(tween.toString());
return Visibility(visible: showNavBar, child: child);
},
child: BottomNavigationBar(
selectedItemColor: Colors.green,
unselectedItemColor: Colors.black,
items: [
BottomNavigationBarItem(icon: Icon(Icons.home), label: "Home"),
BottomNavigationBarItem(icon: Icon(Icons.explore), label: "Home"),
BottomNavigationBarItem(
icon: Icon(Icons.library_books), label: "Home"),
BottomNavigationBarItem(icon: Icon(Icons.settings), label: "Home")
],
onTap: (index) {},
),
);
}
答案 0 :(得分:3)
TweenAnimationBuilder<bool>
尝试使用Tween<bool>
,但是Tween<T>
不能与bool
一起使用。从Tween
文档中:
有特殊考虑的类型
...
定义
+
和-
运算符以组合值(T + T → T
和T - T → T
)和*
运算符以乘以双倍(T * double → T
)可以直接与Tween<T>
一起使用。
bool
不提供+
,-
和*
运算符。