I am using image_picker 0.6.7+17 library in order to take an image using the phone camera.
I am using an android device and not an ios device.
It seems like that getImage method is not defined, I took this exact code from the docs:
final picker = ImagePicker();
Future getImage() async {
final pickedFile = await picker.getImage(source: ImageSource.camera);
}
I am getting this error:
lib/pickers/image_picker.dart:17:37: Error: The method 'getImage' isn't defined for the class
'ImagePicker'.
- 'ImagePicker' is from 'package:chat_app/pickers/image_picker.dart'
('lib/pickers/image_picker.dart').
Try correcting the name to the name of an existing method, or defining a method named 'getImage'.
final pickedFile = await picker.getImage(source: ImageSource.camera);
^^^^^^^^
What I have done so far:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.0
cloud_firestore: 0.13.5
firebase_auth: 0.16.1
image_picker: ^0.6.7+17
Added android:requestLegacyExternalStorage="true" to the AndroidManifest.xml file
Also Imported import 'package:image_picker/image_picker.dart' to use this library
What could be the problem?
You are trying to use an old API with a plugin version that specifies to use the new API. Old API
File image = await ImagePicker.pickImage(...)
New API
final _picker = ImagePicker();
.
.
.
PickedFile image = await _picker.getImage(...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With