Firebase 如果图像为空或未处于抖动状态,如何放置验证器?

Firebase 如果图像为空或未处于抖动状态,如何放置验证器?,firebase,flutter,firebase-storage,Firebase,Flutter,Firebase Storage,我正在使用下面的代码选择图像,然后调用uploadFile()函数将图像上载到Flatter应用程序中的firebase存储,我应该如何使用验证器检查用户是否上载了图像,如果没有,则提示用户上载图像 Future getImage() async { File image = await ImagePicker.pickImage(source: ImageSource.gallery); if (image != null) { setState(() {

我正在使用下面的代码选择图像,然后调用
uploadFile()
函数将图像上载到Flatter应用程序中的firebase存储,我应该如何使用验证器检查用户是否上载了图像,如果没有,则提示用户上载图像

Future getImage() async {
    File image = await ImagePicker.pickImage(source: ImageSource.gallery);
  if (image != null) {
      setState(() {
        avatarImageFile = image;
        isLoading = true;

        print("cbadsbjdb");
      });
  }
    uploadFile();
  }

使用
然后
等待

大概是这样的:

await ImagePicker.pickImage(source: ImageSource.gallery)
        .then((image) async {
          if(image!=null && await image.exists()) {
            print("image selected");
            setState(() {
              _image = image;
            });
            //other code
          }
          else {
            print("image not selected");
            //other code
          }
    }).catchError((error) {
      print("Error: "+error.toString());
    });

调用此方法的函数应该是
async
使用
然后使用
等待

大概是这样的:

await ImagePicker.pickImage(source: ImageSource.gallery)
        .then((image) async {
          if(image!=null && await image.exists()) {
            print("image selected");
            setState(() {
              _image = image;
            });
            //other code
          }
          else {
            print("image not selected");
            //other code
          }
    }).catchError((error) {
      print("Error: "+error.toString());
    });
调用此方法的函数应该是
async