[英]Flutter firebase_ml_vision errors with async function, getImage and pickedFile
How to resolve the following errors:如何解决以下错误:
//Code Below //代码如下
import 'package:firebase_ml_vision/firebase_ml_vision.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
void main() async {
runApp(Home());
}
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
@override
Widget build(BuildContext context) {
final imageFile = await ImagePicker.getImage(
source: ImageSource.camera,
);
final image = FirebaseVisionImage.fromFile(imageFile);
return Scaffold(
appBar: AppBar(title: Text("Mystify",),),
);
}
}
I face the same problem and did this.我面临同样的问题并做到了这一点。
await Future.delayed(new Duration(milliseconds: 1000))
.whenComplete(() => () async {
File foo = File(pickedFile.path);
final image = FirebaseVisionImage.fromFile(foo);
对于颤振版本 2,使用 getImage 而不是 pickImage
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.