cameras.isEmpty null Flutter
612
I use library image_picker: ^0.4.12 and I implement
_getImage(context, ImageSource.camera
onTap and this is the magical code
void _getImage(BuildContext context, ImageSource source){
ImagePicker.pickImage(source: source, maxWidth: 400.0).then((File image){
setState(() {
_imageFile = image;
});
Navigator.pop(context);
});
}
voila!
thanks udemy :)
Author by
Vanya Rachel
Updated on December 08, 2022Comments
-
Vanya Rachel over 1 year
Anyone can tell my fault, when I use example for camera Flutter the error was
NoSuchMethodError: The getter 'isEmpty' was called on null. Receiver : null Tried calling: isEmpty
I've implemented the permission for android and ios
-
Pankaj Kumar over 5 yearsAre you using minSdkVersion 21
-
Vanya Rachel over 5 yearsyes I use minSdkVersion 21 in build.gradle android
-
Pankaj Kumar over 5 yearsAre you using <uses-permission android:name="android.permission.CAMERA" /> permission in manifest. Not sure for flutter but when you read camera info or use camera, you need this permission.
-
Vanya Rachel over 5 yearsstill doesn't work huhu. I don't know why it's happen :(
-
Pankaj Kumar over 5 yearsJust wanted to confirm if you already enabled the Camera permission
-
Vanya Rachel over 5 yearsit's only working when I put the code on main.dart, thanks @PankajKumar
-