【发布时间】:2021-09-04 19:26:01
【问题描述】:
我试图在 2 秒的时间间隔内一个接一个地显示两个小部件。
在这里,我首先尝试显示文本小部件,并在两秒的时间间隔后将其更改为点小部件。
我试过了,但我做不到。我被困在如何一个接一个地返回两个小部件。
代码:
Widget _getNumberWidget(bool hasHighlight, Color color, String text) {
final textStyle = context.appThemeData.passcodeFieldStyle.numberTextStyle.textStyle.copyWith(color: color);
return Container(
height: 35,
alignment: Alignment.bottomCenter,
child: FittedBox(
fit: BoxFit.fitHeight,
child: text.isEmpty ? _getDotWidget(hasHighlight, color, text) : _showChar(hasHighlight, color, text),
),
);
}
Widget _showChar(bool hasHighlight, Color color, String text) {
final textStyle = context.appThemeData.passcodeFieldStyle.numberTextStyle.textStyle.copyWith(color: color);
AppText(
text: text,
style: context.appThemeData.passcodeFieldStyle.numberTextStyle.copyWith(textStyle: textStyle),
);
sleep(const Duration(seconds: 2));
return _getDotWidget(hasHighlight, color, text);
}
如果我返回 Apptext,那么剩余的两行代码将变为死代码。任何人都可以建议我如何做到这一点。谢谢
【问题讨论】:
标签: flutter dart future flutter-widget