I have ran into a problem concerning my Flutter app , to use select picture from gallery in Flutter and pickImage
is underlined and had this "Instance member 'pickImage' can't be accessed using static access
." error. How to fix this error.
This is my code
class _CreateBlogState extends State<CreateBlog> {
late String authorName, title, description;
late File selectedImage;
BlogCrudMethods blogCrudMethods = new BlogCrudMethods();
Future getImage() async {
var image = await ImagePicker.pickImage(source: ImageSource.gallery);
setState(() {
selectedImage = image as File;
});
}
You need to create a ImagePicker
instance to use pickImage
while it is not static method.
await ImagePicker().pickImage(source: ImageSource.gallery);