I am getting a error in the image picker plugin. Have tried all the resources from stack overflow and am really stuck with this from past two days.
Whenevr I am trying to upload any file, the console is popping up errors and nothing is happening Have tried editing those gradle files and also those tried flutter clean after then have restared the app several times. But nothing happens
Error Log:
[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method pickImage on channel plugins.flutter.io/image_picker)
E/flutter ( 9799): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:157:7)
E/flutter ( 9799): <asynchronous suspension>
E/flutter ( 9799): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:332:12)
E/flutter ( 9799): #2 MethodChannelImagePicker.pickImagePath (package:image_picker_platform_interface/src/method_channel/method_channel_image_picker.dart:62:21)
My code:
import 'package:image_picker/image_picker.dart';
import 'package:flutter/material.dart';
import 'dart:io';
class Upload extends StatefulWidget {
@override
_UploadState createState() => _UploadState();
}
class _UploadState extends State<Upload> {
File _image;
final picker = ImagePicker();
Future getImage() async {
final pickedFile = await picker.getImage(source: ImageSource.camera);
setState(() {
if (pickedFile != null) {
_image = File(pickedFile.path);
} else {
print('No image selected.');
}
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: _image == null ? Text('No image selected.') : Image.file(_image),
),
floatingActionButton: FloatingActionButton(
onPressed: getImage,
tooltip: 'Pick Image',
child: Icon(Icons.add_a_photo),
),
);
}
}
other warnings:
Note: C:\Users\user\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\firebase_core_web-0.1.1+2\android\src\main\java\io\flutter\plugins\firebase_core_web\FirebaseCoreWebPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\user\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\firebase_core-0.4.5\android\src\main\java\io\flutter\plugins\firebase\core\FirebaseCorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\user\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\firebase_auth-0.14.0+9\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
C:\Users\user\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\firebase_storage-3.1.6\android\src\main\java\io\flutter\plugins\firebase\storage\FirebaseStoragePlugin.java:31: warning: [deprecation] PluginRegistry in io.flutter.plugin.common has been deprecated
use the latest version of Image_Picker
pickVideo and pickImage is deprecated, Use getVideo and getImage instead
and getVideo and getImage are not static methods so create an instance of ImagePicker and then try to call it
use this code