Created
June 9, 2020 11:19
-
-
Save DK15/af4f6c47eb579b169c3cb3d963a4a639 to your computer and use it in GitHub Desktop.
Build failure using image_picker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:image_picker/image_picker.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
home: MyHomePage(title: 'Flutter Demo Home Page'), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
MyHomePage({Key key, this.title}) : super(key: key); | |
final String title; | |
@override | |
_MyHomePageState createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(widget.title), | |
), | |
body: Center( | |
child: RaisedButton( | |
child: Text('Tap'), | |
onPressed: () { | |
_selectOptions(); | |
}, | |
)), | |
); | |
} | |
Future<void> _selectOptions() { | |
return showDialog( | |
context: context, | |
builder: (BuildContext context) { | |
return AlertDialog( | |
content: new SingleChildScrollView( | |
child: new ListBody( | |
children: <Widget>[ | |
GestureDetector( | |
child: new Text('Take a picture'), | |
onTap: openCamera, | |
), | |
Padding( | |
padding: EdgeInsets.all(8.0), | |
), | |
GestureDetector( | |
child: new Text('Select from gallery'), | |
onTap: openGallery, | |
), | |
], | |
), | |
), | |
); | |
}); | |
} | |
void openCamera() async { | |
var picture = await ImagePicker.pickImage( | |
source: ImageSource.camera, | |
); | |
} | |
void openGallery() async { | |
var gallery = await ImagePicker.pickImage( | |
source: ImageSource.gallery, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am unable to replicate the build failure when
image_picker
plugin is used. I tried a sample code using latest version ofimage_picker
(^0.6.7+1) and flutter stable versionv1.17.2
and it seems to be working fine with no issues. I am able to open camera and gallery using the plugin.