如何统计颤动中打开或关闭的开关?
对于一个显示 3 种类型照片(海龟、蝴蝶和鸟类)的简单 flutter 应用程序,我为每种类型都有一个相应的开关,用于显示或隐藏该类别中的所有图片。
如何显示显示了多少个类别?例如,蝴蝶开关关闭,但乌龟和鸟类开关打开,因此仅显示乌龟和鸟类图片。
我可以为每个开关创建一个布尔值,例如 swicth1On = true 等...并计算打开的开关数量,还是有更好的解决方案?
结果字符串应该是: Text('${categoryCount} of ${项目类型数量}个类别'), ->当一个或多个开关打开时,它还必须显示一个或多个类别。 ->那么,categoryCount 就是打开的项目类型开关的数量。
谢谢
For a simple flutter app which displays 3 types of photos (turtles, butterflies and birds) I have for each type one corresponding switch which either shows or hides all pictures in the category.
How can I display how many categories are shown? eg, the butterfly switch is off, but the turtles and birds switches are on, thus displaying only turtle and bird pictures.
Can I make a bool for each switch like swicth1On = true, etc... and count the amount of switches that are on, or is there a better solution?
The resulting string should be:
Text('${categoryCount} of ${amount of item-types} categories'),
-> it also has to either show category or categories when one or more switches are toggled on.
-> categoryCount is then the amount of item-type-switches that are on.
Thx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论