Skip to content

Instantly share code, notes, and snippets.

@DK15
Created June 9, 2020 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DK15/af4f6c47eb579b169c3cb3d963a4a639 to your computer and use it in GitHub Desktop.
Save DK15/af4f6c47eb579b169c3cb3d963a4a639 to your computer and use it in GitHub Desktop.
Build failure using image_picker
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,
);
}
}
@DK15
Copy link
Author

DK15 commented Jun 9, 2020

I am unable to replicate the build failure when image_picker plugin is used. I tried a sample code using latest version of image_picker (^0.6.7+1) and flutter stable version v1.17.2 and it seems to be working fine with no issues. I am able to open camera and gallery using the plugin.

@TahaTesser
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment