import 'package:flutter/material.dart';
import 'login_page.dart';
import 'sign_in.dart';
import 'package:image_picker/image_picker.dart';
import 'package:firebase_ml_vision/firebase_ml_vision.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
class FirstScreen extends StatelessWidget {
var myDatabase = Firestore.instance;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Center(child: Text('IT Interns are the best!!')),
),
backgroundColor: Colors.white,
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Welcome to Krea\'s Official App!',
textAlign: TextAlign.center,
style: TextStyle(
fontWeight: FontWeight.w800,
fontSize: 40.0,
color: Colors.black),
),
SizedBox(height: 30.0),
Container(
child: Image.asset('assets/krea.png'),
),
SizedBox(
height: 50.0,
width: 250.0,
child: Divider(color: Colors.blueAccent),
),
Icon(
Icons.face,
size: 120,
),
Text(
'Akshay Jain',
style: TextStyle(
fontSize: 40.0,
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
Text(
'Krea_StudentLife_Level_100',
style: TextStyle(
fontSize: 18.0,
color: Colors.black,
fontWeight: FontWeight.normal,
letterSpacing: 1.0,
),
),
SizedBox(height: 20.0),
RaisedButton(
onPressed: () {
ImagePicker.getImage(source: ImageSource.camera)
.then((photo) {
BarcodeDetector detector = FirebaseVision.instance
.barcodeDetector(BarcodeDetectorOptions(
barcodeFormats: BarcodeFormat.qrCode));
detector
.detectInImage(FirebaseVisionImage.fromFile(photo))
.then((barcodes) {
if (barcodes.length > 0) {
var barcode = barcodes[0]; // Pick first barcode
myDatabase.collection("qr_codes").add({
"raw_data": barcode.rawValue,
"time": new DateTime.now().millisecondsSinceEpoch
}).then((_) {
print("One document added.");
});
showDialog(
context: context,
builder: (context) {
return new AlertDialog(
title: new Text("QR Code Contents"),
content: new Text(barcode.rawValue),
actions: <Widget>[
new FlatButton(
onPressed: () {
Navigator.of(context).pop();
},
child: new Text("OK"))
],
);
});
}
});
});
},
child: new Text("Capture QR Code")),
FloatingActionButton.extended(
onPressed: () {
signOutGoogle();
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) {
return LoginPage();
}), ModalRoute.withName('/'));
},
backgroundColor: Colors.blue,
icon: Icon(Icons.lock),
label: Text('Sign Out'),
),
],
),
),
);
}
}
The error we are getting is that on line 62 it says that Instance member 'getImage' can't be accessed using static access. which is where the whole code fails. It seems to be a package issue but because of the getImage line, the QR codes are not being processed.