I got a problem in imagepicker
which is pick image is red underlined which mean undefined class.
anyone can give the solution?
here is my code:
class _homepageState extends State<homepage> {
String? _path = null;
void _showPhotoLibrary() async {
final file = await ImagePicker.pickImage(source: ImageSource.gallery);
setState(() {
_path = file!.path;
});
void _showCamera() async {
final cameras = await availableCameras();
final camera = cameras.first;
final result = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => TakePicturePage(camera: camera)));
setState(() {
_path = result;
});
}
2
Answers
Try to initialize
ImagePicker
like thisThen you can access
pickImage