flutter multiple async functions code example
Example 1: 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);
}
Example 2: dart language asynchronous ??
import 'dart:async';
void main() {
final myFuture = Future(() {
print("Hello from the future!");
return true;
});
print("Done!");
}