|
- // import 'package:barcode_scan/barcode_scan.dart';
- import 'package:camera/camera.dart';
- import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_detail.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:get/route_manager.dart';
- import 'app.dart';
- import 'data/repository/authentication_repository.dart';
- import 'data/repository/repository.dart';
- import 'presentation/custom_widgets/widget_utils.dart';
-
- final GlobalKey<NavigatorState> globalNavigator = GlobalKey<NavigatorState>();
- // List<CameraDescription> cameras = [];
- Future<void> main() async {
- // Fetch the available cameras before initializing the app.
- // try {
- // WidgetsFlutterBinding.ensureInitialized();
- // // cameras = await availableCameras();
- // } on CameraException catch (e) {
- // print(e.description);
- // }
- WidgetsFlutterBinding.ensureInitialized();
- runApp(App(authenticationRepository: AuthenticationRepository()));
- // runApp(MaterialApp(
- // home: Scaffold(
- // appBar: AppBar(),
- // body: Container(
- // color: Colors.red,
- // // width: 100,
- // // height: 100,
- // ),
- // ),
- // ));
- }
-
- void myBackgroundMessageHandler(Map<String, dynamic> message) {
- if (message.containsKey('data')) {
- // Handle data message
- final dynamic data = message['data'];
- }
-
- if (message.containsKey('notification')) {
- // Handle notification message
- final dynamic notification = message['notification'];
- }
-
- // Or do other work.
- }
-
- Future scan(BuildContext context) async {
- print('scan QR');
- // var _aspectTolerance = 0.00;
- // var _selectedCamera = -1;
- // var _useAutoFocus = true;
- // var _autoEnableFlash = false;
- // var repository = Repository();
- // try {
- // var options = ScanOptions(
- // strings: {
- // "cancel": "Huỷ",
- // "flash_on": "Bật flash",
- // "flash_off": "Tắt flash",
- // },
- // useCamera: _selectedCamera,
- // autoEnableFlash: _autoEnableFlash,
- // android: AndroidOptions(
- // aspectTolerance: _aspectTolerance,
- // useAutoFocus: _useAutoFocus,
- // ),
- // );
- // var result = await BarcodeScanner.scan(options: options);
- // print(result.toString());
- // if (result.type == ResultType.Cancelled) {
- // print("canncel");
- // } else if (result.type == ResultType.Error) {
- // print("error");
- // } else {
- // print("show check crop");
- // _showAlertCheckCropCode(context, result.rawContent, repository);
- // }
- // } on PlatformException catch (e) {
- // print("error: ${e.message}");
- // }
- }
-
- // _showAlertCheckCropCode(BuildContext context, String cropCode, Repository repository) async {
- // Get.defaultDialog(title: "Kiểm tra thông tin lô ....", middleText: "", content: const CircularProgressIndicator());
- // try {
- // await repository.getPlotDetailByCode(cropCode, page: 1, size: 1).then((value) {
- // print("ok");
- // if (Get.isDialogOpen) Get.back();
- // Get.to(PlotDetailScreen(cropId: value.tbCropDTO?.id ?? -1, cropType: value.tbCropDTO?.type ?? -1, initialIndex: 0));
- // }).catchError((onError) {
- // Utils.showDialog(
- // title: "Không tìm thấy lô",
- // message: "Thử lại với mã tem khác?",
- // textConfirm: "Thử lại",
- // textCancel: "Huỷ",
- // onConfirm: () {
- // Get.back();
- // scan(context);
- // });
- // });
- // } catch (e) {
- // Utils.showDialog(
- // title: "Không tìm thấy lô",
- // message: "Thử lại với mã tem khác?",
- // textConfirm: "Thử lại",
- // textCancel: "Huỷ",
- // onConfirm: () {
- // Get.back();
- // scan(context);
- // });
- // }
- // }
|