当我尝试使用uploadcare 上传图片时。上传图片后,我不会收到进一步的回复。也许我遗漏了一些东西,但我一直在关注 uploadcare 的文档。
uploadcare 身份验证的初始化。
@override
void initState() {
super.initState();
_uploadcareClient = UploadcareClient.withSimpleAuth(
publicKey: DotEnv().env['UPLOADCARE_PUBLIC_KEY'],
privateKey: DotEnv().env['UPLOADCARE_PRIVATE_KEY'],
apiVersion: 'v0.5',
);
}
我按照如下步骤上传图片
Future _onUpload() async {
final file = await showModalBottomSheet<File>(
context: context,
builder: (context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
ListTile(
title: Text('Pick image from gallery'),
onTap: () async => Navigator.pop(
context,
await ImagePicker.pickImage(
source: ImageSource.gallery,
),
),
),
ListTile(
title: Text('Pick image from camera'),
onTap: () async => Navigator.pop(
context,
await ImagePicker.pickImage(
source: ImageSource.camera,
),
),
),
ListTile(
title: Text('Pick video from gallery'),
onTap: () async => Navigator.pop(
context,
await ImagePicker.pickVideo(
source: ImageSource.gallery,
),
),
),
ListTile(
title: Text('Pick video from camera'),
onTap: () async => Navigator.pop(
context,
await ImagePicker.pickVideo(
source: ImageSource.camera,
),
),
),
],
);
});
if (file != null) {
Navigator.push(
context,
MaterialPageRoute(
fullscreenDialog: true,
builder: (context) => UploadScreen(
file: file,
uploadcareClient: _uploadcareClient,
),
));
}
}
上传流程: