Created
January 11, 2019 20:50
-
-
Save javawolfpack/a1c273a83671fabc548934d7b0e4b916 to your computer and use it in GitHub Desktop.
Simple attempt at ImageFormField
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
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