📜  未来作为颤振中的异步参数 - Dart 代码示例

📅  最后修改于: 2022-03-11 14:48:08.489000             🧑  作者: Mango

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

...

Future getImageFromCam(int index) async {
  // Do whatever you want with `index`.
  final image = await ImagePicker.pickImage(source: ImageSource.camera);
  setState(() => _image = image);
}