I'm new to Flutter and would love some help with an error.
While using the image_picker package, I noticed that I'm getting a value of null returned when I try to select an image from ios photo gallery. (Specifically, [VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: [firebase_storage/object-not-found] No object exists at the desired reference.)
I read the package documentation where it says this is a known issue and to try it on a real device. I tried it on my real device an only got the desired result once. Can someone please shed some light on this? Below, I have provided the necessary code and a look and my flutter doctor. Thanks in advance!
P.S. To be clear, I am trying to test this on my physical ios device(iPhone 14 Pro Max), as I am aware of the issue with the ios Simulator and the image_picker package.
Please let me know if I need to provide more information to resolve this issue!
String? photoUrl = " ";
File? image;
Future pickImage() async {
try {
final image = await ImagePicker()
.pickImage(source: ImageSource.gallery, requestFullMetadata: false);
if (image == null) return;
Reference ref = FirebaseStorage.instance.ref().child("profilepic.jpg");
await ref.putFile(File(image.path));
await ref.getDownloadURL().then((value) {print(value); setState(() {
photoUrl = value;
});});
} on PlatformException catch (e) {
debugPrint('Failed to pick image: $e');
}
}
profilePic() {
final Size size = MediaQuery.of(context).size;
return SizedBox(
height: size.height * 0.185,
width: double.infinity,
child: Column(children: [
const Spacer(),
photoUrl != null
?
GestureDetector(
onTap: () {
pickImage();
},
child: Container(
height: 120,
width: 160,
decoration: const BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.all(
Radius.circular(20),
),
),
child: const Icon(
Icons.person,
size: 50,
color: Colors.white,
),
),
):Image.network(photoUrl!),
],
),
);
}
[✓] Flutter (Channel stable, 3.7.0, on macOS 12.6.1 21G217 darwin-arm64, locale en-US) • Flutter version 3.7.0 on channel stable at /Users/myronsp/Developer/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision b06b8b2710 (9 days ago), 2023-01-23 16:55:55 -0800 • Engine revision b24591ed32 • Dart version 2.19.0 • DevTools version 2.20.1
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at /Users/myronsp/Library/Android/sdk • Platform android-33, build-tools 33.0.0 • ANDROID_HOME = /Users/myronsp/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.15 0-b2043.56-8887301) • All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.2) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 14C18 • CocoaPods version 1.11.3
[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: