【发布时间】:2022-01-22 10:23:29
【问题描述】:
对不起,我是新手。
我创建了一个按钮,它应该运行以下函数(我想,这也应该打开文件资源管理器)但它不起作用。 Button 在那里,但如果按下它,则不会发生任何其他事情。
Padding newPadding() {
return new Padding(
padding: const EdgeInsets.only(top: 50.0, bottom: 20.0),
child: ElevatedButton(
onPressed:_openFileExplorer,
child: const Text("Open File picker"),
),
);
}
FilePickerResult? result = await FilePicker.platform.pickFiles();
if (result != null) {
PlatformFile file = result.files.first;
print(file.path);
}
else {
// User canceled the picker
}
}
我忘记了什么?
【问题讨论】: