Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR DART

future as a parameter with async in flutter

FloatingActionButton(
  onPressed: () => getImageFromCam(index),
  tooltip: 'Pick Image',
  child: Icon(Icons.add_a_photo),
);

...

Future<void> getImageFromCam(int index) async {
  // Do whatever you want with `index`.
  final image = await ImagePicker.pickImage(source: ImageSource.camera);
  setState(() => _image = image);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #future #parameter #async #flutter
ADD COMMENT
Topic
Name
5+4 =