![](/img/trans.png)
[英]How can i delay Visibilty anmation in flutter? like wait 2 seconds then begin animation
[英]Flutter override visibilty flag
我创建了 StatelessWidget,它由一个 Icon 和 2 个堆叠的按钮组成。
我使用 2 种方法来指定按钮的标签和可见性。 我已经成功地覆盖了子类中标签的方法,但由于某种原因,从超类调用了可见性。
更重要的是,在子类中,我在 shouldShowFirstButton() 上收到“未引用声明”警告
非常感激任何的帮助。 谢谢!
覆盖子类中的属性:
@override
String firstButtonTitleForStatus(UserClassStatus status) {
return "someOverridenLabel"; // this one is called properly
}
@override
bool shouldShowFirstButton() {
return true; // this is never called (only the one from the super class)
}
超类的标签/可见性方法:
bool shouldShowFirstButton() {
return false;
}
String firstButtonTitleForStatus(UserClassStatus status) {
switch (status) {
case UserClassStatus.unknown: ....
return "Some super string";
}
超类的构建方法:
@override
Widget build(BuildContext context) {
UserClassStatus status = someUserStatus;
return Row(
children: <Widget>[
Center(child: classStatusIcon(status)),
Padding(
padding: const EdgeInsets.fromLTRB(8, 8, 8, 8),
child: Container(
width: 100,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Visibility(
maintainSize: false,
visible: shouldShowFirstButton(),
child: MyFlatButton(
title: firstButtonTitleForStatus(status),
onPressed: () async {
handleFirstButtonPressed(
lesson, user, status, context);
}),
),
Visibility(
maintainSize: false,
visible: shouldShowSecondButton(),
child: MyFlatButton(
title: secondButtonTitleForStatus(status),
onPressed: () async {
handleSecondButtonPressed(
lesson, user, status, context);
}),
),
],
),
))
],
);
}
}
清理,android studio 重启,电脑重启。 瞧!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.