1

How to resolve the following errors:

  1. The await expression can only be used in an async function.Try marking the function body with async.
  2. Instance member 'getImage' can't be accessed using static access.
  3. The argument type PickedFile can't be assigned to the parameter type File.

//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",),),
    );
  }
}
molbdnilo
  • 64,751
  • 3
  • 43
  • 82
Siva A
  • 21
  • 2

2 Answers2

0

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);
Mustafa yıldiz
  • 325
  • 1
  • 8
-1

use getImage instead of pickImage for flutter version 2

Nidhi
  • 1
  • 1