【发布时间】:2021-05-24 21:25:16
【问题描述】:
我目前对 Flutter 感到困惑和困惑。
我有一个 FutureBuilder 如下:
Widget initView(double width) {
return Container(
child: FutureBuilder(
future: fetchVehicles(),
builder:
(BuildContext context, AsyncSnapshot<List<Vehicle>> snapShotData) {
switch (snapShotData.connectionState) {
case ConnectionState.waiting:
return loadingView();
case ConnectionState.done:
return TextField();
default:
return loadingView();
}
},
),
);
}
而 fetchVehicles() 如下:
Future<List<Vehicle>> fetchVehicles() async {
List<Vehicle>vehicles = await APIService.fetchVehicles();
return vehicles;
}
调用 future 时,会显示 Loading 指示器,然后当它完成时,最终会显示 TextField。
现在,我现在的困境是,当我点击 TextField 并想要开始输入 future 的那一刻开始重新执行,从而使加载器再次显示。
这让我无法在 TextField 中输入内容。
这真是令人沮丧。我从来没有看到这会发生。
有人请帮助我。我很困惑,因为我看不出这段代码有什么问题。
这就是我在日志中看到的全部内容:
I/HwSecImmHelper( 3644): mSecurityInputMethodService is null
W/IInputConnectionWrapper( 3644): beginBatchEdit on inactive InputConnection
W/IInputConnectionWrapper( 3644): getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper( 3644): getTextAfterCursor on inactive InputConnection
W/IInputConnectionWrapper( 3644): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper( 3644): endBatchEdit on inactive InputConnection
W/IInputConnectionWrapper( 3644): beginBatchEdit on inactive InputConnection
W/IInputConnectionWrapper( 3644): endBatchEdit on inactive InputConnection
【问题讨论】: