Reputation: 156
I want to read Qr codes from picture files in flutter without using the firebase ML kit.
So far I was able to create the image picker but don't know what to do next.
Dependency: image_picker: ^0.8.4+1
scan.dart:
File? _image;
Container(
child: Column(
children: [
ElevatedButton.icon(
style: ElevatedButton.styleFrom(
primary: Theme.of(context).buttonColor),
onPressed: () async => pickImage(),
icon: Icon(Icons.image),
label: Text("Choose an Image from gallery"),
)
],
),
);
Future<void> pickImage() async {
await Permission.storage.request();
var status = await Permission.storage.status;
if (status.isGranted) {
final pickedFile =
await ImagePicker().pickImage(source: ImageSource.gallery);
if (pickedFile != null) {
setState(
() {
this._image = File(pickedFile.path);
},
);
}
}
}
Upvotes: 4
Views: 14488
Reputation: 17732
Use this package. You can pass the file and read the qr as expected.
Upvotes: 1