Flutter Web FilePicker浏览器在UBUNTU上崩溃或无错误关闭



我想在web平台上使用flutter文件选择器。当我调用方法"pickFiles"App关闭无错误

FilePickerResult? result = await FilePicker.platform.pickFiles(
type: FileType.custom,
);
print(result?.files.first.bytes);
if (result?.files.first != null) {
print(result?.files.first.bytes);
} else {
throw "Cancelled File Picker";
}

我想这只会发生在ubuntu上。

和扑动医生:

[✓] Flutter (Channel stable, 3.0.1, on Ubuntu 20.04.3 LTS 5.13.0-44-generic, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc2)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 4.1)
[✓] VS Code
[✓] Connected device (2 available)
[✓] HTTP Host Availability

我也有同样的问题!暂时我决定使用另一个包

flutter_dropzone: ^3.0.5

他帮我把一些文件放到应用程序中。

onTap: () async {
bool fileUploaded = false;
double pourcentageUploaded = 0;
await showDialog(
context: context,
builder: (context) => Dialog(
child: StatefulBuilder(
builder: (context, setstate) => AnimatedContainer(
duration: Duration(seconds: 2),
color: fileUploaded
? Colors.green
: Colors.transparent,
height: 200,
width: 500,
child: Stack(
children: [
DropzoneView(
onDrop: (value) async {
fileUploaded = !fileUploaded;
do {
pourcentageUploaded += 0.0000000004;
print(pourcentageUploaded);
setstate(() {});
} while (pourcentageUploaded < 1);
pourcentageUploaded = 0.4;
setstate(() {});
},
),
Center(
child: Text(fileUploaded
? 'Telechargement...'
: 'Veuillez glisser le document ici'),
),
Container(
child: Container(
decoration: BoxDecoration(
color: Colors.transparent),
height: 50,
width: 500,
child: Center(
child: AnimatedContainer(
duration: Duration(seconds: 1),
color: Colors.yellow[100],
height: 50,
width: pourcentageUploaded * 500,
),
),
),
)
],
),
),
),
));

最新更新