Skip to content

Instantly share code, notes, and snippets.

@javawolfpack
Created January 11, 2019 20:50
Show Gist options
  • Save javawolfpack/a1c273a83671fabc548934d7b0e4b916 to your computer and use it in GitHub Desktop.
Save javawolfpack/a1c273a83671fabc548934d7b0e4b916 to your computer and use it in GitHub Desktop.
Simple attempt at ImageFormField
class ImageFormState extends FormFieldState<File> {
File _image;
Future getImage() async {
var image = await ImagePicker.pickImage(source: ImageSource.camera);
this._image= image;
}
@override
Widget build(BuildContext context) {
return _image == null
? new RaisedButton(
onPressed: () {
getImage();
},
child: Text('Select Image'),
):
new Image.file(_image);
}
}
class ImageFormField extends FormField<File> {
@override
FormFieldState<File> createState() => ImageFormState();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment