Created
January 11, 2019 20:49
-
-
Save javawolfpack/069d717593e7c00194bbd96b8e82bf19 to your computer and use it in GitHub Desktop.
Trying to make an ImageFormField
This file contains hidden or 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