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?
Are you sure the ImagePicker
you are using is not the one from this package:chat_app/pickers/image_picker.dart
? Maybe there is a class name conflict and you must rename your own ImagePicker
class