mobile_scanner
mobile_scanner copied to clipboard
I need save qrcode scan
I need save qrcode scan, example I scanned a qrcode I wanted to have the freedom to show the scanned qrcode or save it in an api
I am working on this feature and will let you know when it's finished.
Thank you for this plugin - excellent work - @DiegoLimeiradaSilva please note that adding "please" and "thank you" is much appreciated for the author's kind efforts.
I asked a question and forgot about the ? but thank you very much for your attention. a great plugin
I've implemented basic local saving facility using SharedPreferences. Using which U can store the qr data locally and retrive it whenever we want.
import 'dart:convert';
class Todo {
String? description;
// String ?currentTime;
Todo(this.description);
// Todo(this.description, this.currentTime);
Todo.fromJson(Map<String, dynamic> json) {
description = json["description"];
// currentTime = json["date-time"];
}
static Map<String, dynamic> toJson(Todo todo) =>
{'description': todo.description};
// {'description': todo.description, "date-time": todo.currentTime};
static String encode(List<Todo> todos) => json.encode(
todos.map<Map<String, dynamic>>((todo) => Todo.toJson(todo)).toList(),
);
static List<Todo> decode(String todos) =>
(json.decode(todos) as List<dynamic>)
.map<Todo>((item) => Todo.fromJson(item))
.toList();
}
this is what I'm doing when saving the info from qr
void _persistPreference(String text) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
if (!text.toLowerCase().contains('not yet scanned')) {
if (prefs.containsKey('history')) {
String? hist = prefs.getString('history');
List<Todo> todoCurrent = Todo.decode(hist!);
globals.todos = todoCurrent;
globals.todos.add(Todo(text));
// globals.todos.add(Todo(text, DateTime.now().toString()));
prefs.setString('history', Todo.encode(globals.todos));
} else {
globals.todos.add(Todo(text));
// globals.todos.add(Todo(text, DateTime.now().toString()));
prefs.setString('history', Todo.encode(globals.todos));
}
}
}
and this function presents it on other screen as history
SharedPreferences? prefs;
Future<void> initializePreference() async {
prefs = await SharedPreferences.getInstance();
if (prefs!.containsKey('history')) {
String? hist = prefs?.getString('history');
List<Todo> todoCurrent = Todo.decode(hist!);
globals.todos = todoCurrent;
}
}
é isso que estou fazendo ao salvar as informações do qr
void _persistPreference(String text) async { SharedPreferences prefs = await SharedPreferences.getInstance(); if (!text.toLowerCase().contains('not yet scanned')) { if (prefs.containsKey('history')) { String? hist = prefs.getString('history'); List<Todo> todoCurrent = Todo.decode(hist!); globals.todos = todoCurrent; globals.todos.add(Todo(text)); // globals.todos.add(Todo(text, DateTime.now().toString())); prefs.setString('history', Todo.encode(globals.todos)); } else { globals.todos.add(Todo(text)); // globals.todos.add(Todo(text, DateTime.now().toString())); prefs.setString('history', Todo.encode(globals.todos)); } } }
e esta função o apresenta em outra tela como histórico
SharedPreferences? prefs; Future<void> initializePreference() async { prefs = await SharedPreferences.getInstance(); if (prefs!.containsKey('history')) { String? hist = prefs?.getString('history'); List<Todo> todoCurrent = Todo.decode(hist!); globals.todos = todoCurrent; } }
I need to save the image used for the qrcode reading process
Okay. I thought the other way. Lets see what can be done.
Hi! Do we have any update of feature save image QR? Please up your answer if have any update Thanks
With version 3.0.0-beta.4 you can retrieve the scanned image like so: https://github.com/juliansteenbakker/mobile_scanner/blob/master/example/lib/barcode_scanner_returning_image.dart
Please note that this is still a beta so there can be breaking changes in the near future