gpt4 book ai didi

flutter - 类 'bool'没有实例方法 '-'。接收方:true尝试调用:-(false)

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

我试图使用TweenAnimationBuilder<bool>,但即使有异常日志,我也真的不知道出了什么问题。在发布此问题之前,我已经厌倦了谷歌搜索,但没有帮助。
异常(exception):

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) {},
),
);
}

最佳答案

TweenAnimationBuilder<bool>尝试使用Tween<bool>,但Tween<T>不能与bool一起使用。从 Tween 文档中:

Types with special considerations

...

Types that define + and - operators to combine values (T + T → T and T - T → T) and an * operator to scale by multiplying with a double (T * double → T) can be directly used with Tween<T>.

bool不提供 +-*运算符。

关于flutter - 类 'bool'没有实例方法 '-'。接收方:true尝试调用:-(false),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64290555/

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