| PODS: | |||||
| - camera_avfoundation (0.0.1): | |||||
| - Flutter | |||||
| - Firebase/CoreOnly (10.3.0): | |||||
| - FirebaseCore (= 10.3.0) | |||||
| - Firebase/Messaging (10.3.0): | |||||
| - Firebase/CoreOnly | |||||
| - FirebaseMessaging (~> 10.3.0) | |||||
| - firebase_core (2.7.1): | |||||
| - Firebase/CoreOnly (= 10.3.0) | |||||
| - Flutter | |||||
| - firebase_messaging (14.2.6): | |||||
| - Firebase/Messaging (= 10.3.0) | |||||
| - firebase_core | |||||
| - Flutter | |||||
| - FirebaseCore (10.3.0): | |||||
| - FirebaseCoreInternal (~> 10.0) | |||||
| - GoogleUtilities/Environment (~> 7.8) | |||||
| - GoogleUtilities/Logger (~> 7.8) | |||||
| - FirebaseCoreInternal (10.9.0): | |||||
| - "GoogleUtilities/NSData+zlib (~> 7.8)" | |||||
| - FirebaseInstallations (10.9.0): | |||||
| - FirebaseCore (~> 10.0) | |||||
| - GoogleUtilities/Environment (~> 7.8) | |||||
| - GoogleUtilities/UserDefaults (~> 7.8) | |||||
| - PromisesObjC (~> 2.1) | |||||
| - FirebaseMessaging (10.3.0): | |||||
| - FirebaseCore (~> 10.0) | |||||
| - FirebaseInstallations (~> 10.0) | |||||
| - GoogleDataTransport (~> 9.2) | |||||
| - GoogleUtilities/AppDelegateSwizzler (~> 7.8) | |||||
| - GoogleUtilities/Environment (~> 7.8) | |||||
| - GoogleUtilities/Reachability (~> 7.8) | |||||
| - GoogleUtilities/UserDefaults (~> 7.8) | |||||
| - nanopb (< 2.30910.0, >= 2.30908.0) | |||||
| - Flutter (1.0.0) | |||||
| - flutter_image_compress (1.0.0): | |||||
| - Flutter | |||||
| - Mantle | |||||
| - SDWebImage | |||||
| - SDWebImageWebPCoder | |||||
| - flutter_local_notifications (0.0.1): | |||||
| - Flutter | |||||
| - fluttertoast (0.0.2): | |||||
| - Flutter | |||||
| - Toast | |||||
| - FMDB (2.7.5): | |||||
| - FMDB/standard (= 2.7.5) | |||||
| - FMDB/standard (2.7.5) | |||||
| - GoogleDataTransport (9.2.2): | |||||
| - GoogleUtilities/Environment (~> 7.7) | |||||
| - nanopb (< 2.30910.0, >= 2.30908.0) | |||||
| - PromisesObjC (< 3.0, >= 1.2) | |||||
| - GoogleUtilities/AppDelegateSwizzler (7.11.1): | |||||
| - GoogleUtilities/Environment | |||||
| - GoogleUtilities/Logger | |||||
| - GoogleUtilities/Network | |||||
| - GoogleUtilities/Environment (7.11.1): | |||||
| - PromisesObjC (< 3.0, >= 1.2) | |||||
| - GoogleUtilities/Logger (7.11.1): | |||||
| - GoogleUtilities/Environment | |||||
| - GoogleUtilities/Network (7.11.1): | |||||
| - GoogleUtilities/Logger | |||||
| - "GoogleUtilities/NSData+zlib" | |||||
| - GoogleUtilities/Reachability | |||||
| - "GoogleUtilities/NSData+zlib (7.11.1)" | |||||
| - GoogleUtilities/Reachability (7.11.1): | |||||
| - GoogleUtilities/Logger | |||||
| - GoogleUtilities/UserDefaults (7.11.1): | |||||
| - GoogleUtilities/Logger | |||||
| - image_picker_ios (0.0.1): | |||||
| - Flutter | |||||
| - libwebp (1.2.4): | |||||
| - libwebp/demux (= 1.2.4) | |||||
| - libwebp/mux (= 1.2.4) | |||||
| - libwebp/webp (= 1.2.4) | |||||
| - libwebp/demux (1.2.4): | |||||
| - libwebp/webp | |||||
| - libwebp/mux (1.2.4): | |||||
| - libwebp/demux | |||||
| - libwebp/webp (1.2.4) | |||||
| - Mantle (2.2.0): | |||||
| - Mantle/extobjc (= 2.2.0) | |||||
| - Mantle/extobjc (2.2.0) | |||||
| - nanopb (2.30909.0): | |||||
| - nanopb/decode (= 2.30909.0) | |||||
| - nanopb/encode (= 2.30909.0) | |||||
| - nanopb/decode (2.30909.0) | |||||
| - nanopb/encode (2.30909.0) | |||||
| - package_info (0.0.1): | |||||
| - Flutter | |||||
| - path_provider_foundation (0.0.1): | |||||
| - Flutter | |||||
| - FlutterMacOS | |||||
| - PromisesObjC (2.2.0) | |||||
| - SDWebImage (5.15.6): | |||||
| - SDWebImage/Core (= 5.15.6) | |||||
| - SDWebImage/Core (5.15.6) | |||||
| - SDWebImageWebPCoder (0.11.0): | |||||
| - libwebp (~> 1.0) | |||||
| - SDWebImage/Core (~> 5.15) | |||||
| - shared_preferences_foundation (0.0.1): | |||||
| - Flutter | |||||
| - FlutterMacOS | |||||
| - sqflite (0.0.2): | |||||
| - Flutter | |||||
| - FMDB (>= 2.7.5) | |||||
| - Toast (4.0.0) | |||||
| - video_player_avfoundation (0.0.1): | |||||
| - Flutter | |||||
| DEPENDENCIES: | |||||
| - camera_avfoundation (from `.symlinks/plugins/camera_avfoundation/ios`) | |||||
| - firebase_core (from `.symlinks/plugins/firebase_core/ios`) | |||||
| - firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`) | |||||
| - Flutter (from `Flutter`) | |||||
| - flutter_image_compress (from `.symlinks/plugins/flutter_image_compress/ios`) | |||||
| - flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`) | |||||
| - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`) | |||||
| - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`) | |||||
| - package_info (from `.symlinks/plugins/package_info/ios`) | |||||
| - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/ios`) | |||||
| - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/ios`) | |||||
| - sqflite (from `.symlinks/plugins/sqflite/ios`) | |||||
| - video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/ios`) | |||||
| SPEC REPOS: | |||||
| trunk: | |||||
| - Firebase | |||||
| - FirebaseCore | |||||
| - FirebaseCoreInternal | |||||
| - FirebaseInstallations | |||||
| - FirebaseMessaging | |||||
| - FMDB | |||||
| - GoogleDataTransport | |||||
| - GoogleUtilities | |||||
| - libwebp | |||||
| - Mantle | |||||
| - nanopb | |||||
| - PromisesObjC | |||||
| - SDWebImage | |||||
| - SDWebImageWebPCoder | |||||
| - Toast | |||||
| EXTERNAL SOURCES: | |||||
| camera_avfoundation: | |||||
| :path: ".symlinks/plugins/camera_avfoundation/ios" | |||||
| firebase_core: | |||||
| :path: ".symlinks/plugins/firebase_core/ios" | |||||
| firebase_messaging: | |||||
| :path: ".symlinks/plugins/firebase_messaging/ios" | |||||
| Flutter: | |||||
| :path: Flutter | |||||
| flutter_image_compress: | |||||
| :path: ".symlinks/plugins/flutter_image_compress/ios" | |||||
| flutter_local_notifications: | |||||
| :path: ".symlinks/plugins/flutter_local_notifications/ios" | |||||
| fluttertoast: | |||||
| :path: ".symlinks/plugins/fluttertoast/ios" | |||||
| image_picker_ios: | |||||
| :path: ".symlinks/plugins/image_picker_ios/ios" | |||||
| package_info: | |||||
| :path: ".symlinks/plugins/package_info/ios" | |||||
| path_provider_foundation: | |||||
| :path: ".symlinks/plugins/path_provider_foundation/ios" | |||||
| shared_preferences_foundation: | |||||
| :path: ".symlinks/plugins/shared_preferences_foundation/ios" | |||||
| sqflite: | |||||
| :path: ".symlinks/plugins/sqflite/ios" | |||||
| video_player_avfoundation: | |||||
| :path: ".symlinks/plugins/video_player_avfoundation/ios" | |||||
| SPEC CHECKSUMS: | |||||
| camera_avfoundation: 82dc5597033fe2dcdcca6e41f7e464d0855e74ad | |||||
| Firebase: f92fc551ead69c94168d36c2b26188263860acd9 | |||||
| firebase_core: 1ae9f9aa76e6e1edc14fb181637ad466fd6c6fa4 | |||||
| firebase_messaging: f8c01f8b540feb4196e8dbe45ae17534747d779d | |||||
| FirebaseCore: 988754646ab3bd4bdcb740f1bfe26b9f6c0d5f2a | |||||
| FirebaseCoreInternal: d2b4acb827908e72eca47a9fd896767c3053921e | |||||
| FirebaseInstallations: c58489c9caacdbf27d1da60891a87318e20218e0 | |||||
| FirebaseMessaging: e345b219fd15d325f0cf2fef28cb8ce00d851b3f | |||||
| Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a | |||||
| flutter_image_compress: 5a5e9aee05b6553048b8df1c3bc456d0afaac433 | |||||
| flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743 | |||||
| fluttertoast: eb263d302cc92e04176c053d2385237e9f43fad0 | |||||
| FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a | |||||
| GoogleDataTransport: 8378d1fa8ac49753ea6ce70d65a7cb70ce5f66e6 | |||||
| GoogleUtilities: 9aa0ad5a7bc171f8bae016300bfcfa3fb8425749 | |||||
| image_picker_ios: 58b9c4269cb176f89acea5e5d043c9358f2d25f8 | |||||
| libwebp: f62cb61d0a484ba548448a4bd52aabf150ff6eef | |||||
| Mantle: c5aa8794a29a022dfbbfc9799af95f477a69b62d | |||||
| nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431 | |||||
| package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62 | |||||
| path_provider_foundation: c68054786f1b4f3343858c1e1d0caaded73f0be9 | |||||
| PromisesObjC: 09985d6d70fbe7878040aa746d78236e6946d2ef | |||||
| SDWebImage: d47d81bea8a77187896b620dc79c3c528e8906b9 | |||||
| SDWebImageWebPCoder: 295a6573c512f54ad2dd58098e64e17dcf008499 | |||||
| shared_preferences_foundation: 986fc17f3d3251412d18b0265f9c64113a8c2472 | |||||
| sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904 | |||||
| Toast: 91b396c56ee72a5790816f40d3a94dd357abc196 | |||||
| video_player_avfoundation: 6d971a232d72e6ee25368378d48a079dea01f1cf | |||||
| PODFILE CHECKSUM: a75497545d4391e2d394c3668e20cfb1c2bbd4aa | |||||
| COCOAPODS: 1.12.1 |
| import 'package:farm_tpf/presentation/screens/login/login_page.dart'; | import 'package:farm_tpf/presentation/screens/login/login_page.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/scan_qr/cubit/scan_qr_code_cubit.dart'; | |||||
| import 'package:farm_tpf/presentation/screens/tabbar/tabbar.dart'; | import 'package:farm_tpf/presentation/screens/tabbar/tabbar.dart'; | ||||
| import 'package:farm_tpf/routes/route_name.dart'; | import 'package:farm_tpf/routes/route_name.dart'; | ||||
| import 'package:farm_tpf/routes/routes.dart'; | import 'package:farm_tpf/routes/routes.dart'; | ||||
| repository: authenticationRepository, | repository: authenticationRepository, | ||||
| ), | ), | ||||
| ), | ), | ||||
| // BlocProvider( | |||||
| // create: (_) => LoginCubit(), | |||||
| // ), | |||||
| BlocProvider( | |||||
| create: (_) => ScanQrCodeCubit(), | |||||
| ), | |||||
| // BlocProvider( | // BlocProvider( | ||||
| // create: (_) => NotificationBloc(Repository()), | // create: (_) => NotificationBloc(Repository()), | ||||
| // ), | // ), | ||||
| splitScreenMode: true, | splitScreenMode: true, | ||||
| builder: (BuildContext context, Widget? child) { | builder: (BuildContext context, Widget? child) { | ||||
| return GetMaterialApp( | return GetMaterialApp( | ||||
| title: 'Trang Trai Bo', | |||||
| title: 'LaFarm', | |||||
| debugShowCheckedModeBanner: false, | debugShowCheckedModeBanner: false, | ||||
| onGenerateRoute: Routes.buildRoutes, | onGenerateRoute: Routes.buildRoutes, | ||||
| initialRoute: RouteName.splash, | initialRoute: RouteName.splash, |
| } | } | ||||
| //Action | //Action | ||||
| Future<void> createAction(Function(dynamic) onSuccess, Function(dynamic) onError, | |||||
| {required String apiAddAction, required String paramActivity, required String activityAction, required List<String> filePaths}) async { | |||||
| Future<void> createAction( | |||||
| Function(dynamic) onSuccess, | |||||
| Function(dynamic) onError, { | |||||
| required String apiAddAction, | |||||
| required String paramActivity, | |||||
| required String activityAction, | |||||
| required List<String> filePaths, | |||||
| }) async { | |||||
| var formData = FormData(); | var formData = FormData(); | ||||
| filePaths.forEach((f) { | filePaths.forEach((f) { | ||||
| formData.files.add(MapEntry("images", MultipartFile.fromFileSync(f))); | formData.files.add(MapEntry("images", MultipartFile.fromFileSync(f))); | ||||
| }); | }); | ||||
| formData.fields.add(MapEntry(paramActivity, activityAction)); | formData.fields.add(MapEntry(paramActivity, activityAction)); | ||||
| // Convert FormData to a Map for better printing | |||||
| Map<String, dynamic> formDataMap = | |||||
| formData.fields.fold(<String, dynamic>{}, (Map<String, dynamic> previousValue, field) => previousValue..[field.key] = field.value); | |||||
| // Print the FormData content | |||||
| print('FormData: $formDataMap'); | |||||
| try { | try { | ||||
| await dio.post("${ConstCommon.baseUrl}/$apiAddAction", data: formData).then((value) { | await dio.post("${ConstCommon.baseUrl}/$apiAddAction", data: formData).then((value) { | ||||
| onSuccess(value.data); | onSuccess(value.data); | ||||
| formData.files.add(MapEntry("images", MultipartFile.fromFileSync(f))); | formData.files.add(MapEntry("images", MultipartFile.fromFileSync(f))); | ||||
| }); | }); | ||||
| formData.fields.add(MapEntry(paramActivity, activityAction)); | formData.fields.add(MapEntry(paramActivity, activityAction)); | ||||
| print('FormData: $formData'); | |||||
| try { | try { | ||||
| await dio.post("${ConstCommon.baseUrl}/$apiUpdateAction", data: formData).then((value) { | await dio.post("${ConstCommon.baseUrl}/$apiUpdateAction", data: formData).then((value) { | ||||
| onSuccess(value.data); | onSuccess(value.data); |
| import 'dart:developer'; | |||||
| import 'package:bloc/bloc.dart'; | |||||
| import 'package:equatable/equatable.dart'; | |||||
| import 'package:farm_tpf/data/repository/repository.dart'; | |||||
| import 'package:farm_tpf/utils/utils.dart'; | |||||
| import 'package:flutter/material.dart'; | |||||
| import 'package:get/get.dart'; | |||||
| import 'package:qr_code_scanner/qr_code_scanner.dart'; | |||||
| import '../../../custom_widgets/widget_utils.dart'; | |||||
| import '../../plot_detail/sc_plot_detail.dart'; | |||||
| part 'scan_qr_code_state.dart'; | |||||
| class ScanQrCodeCubit extends Cubit<ScanQrCodeState> { | |||||
| ScanQrCodeCubit() : super(ScanQrCodeInitial()); | |||||
| late BuildContext context; | |||||
| final GlobalKey qrKey = GlobalKey(debugLabel: 'QR'); | |||||
| QRViewController? controllerQR; | |||||
| bool _enableHandleCodeByCamera = true; | |||||
| RxBool isFlashOn = false.obs; | |||||
| RxBool isLoading = false.obs; | |||||
| RxBool isStatusStudent = true.obs; | |||||
| final repository = Repository(); | |||||
| void init() {} | |||||
| void dispose() { | |||||
| controllerQR?.dispose(); | |||||
| } | |||||
| void onQRViewCreated(QRViewController controller) { | |||||
| controllerQR = controller; | |||||
| controller.scannedDataStream.listen((scanData) { | |||||
| if (_enableHandleCodeByCamera) { | |||||
| if (scanData.code != null && scanData.code!.isNotEmpty) { | |||||
| requestScanQRCode(scanData.code ?? ''); | |||||
| } | |||||
| } | |||||
| }); | |||||
| controller.pauseCamera(); | |||||
| controller.resumeCamera(); | |||||
| } | |||||
| Future<void> requestScanQRCode(String cropCode) async { | |||||
| Get.back(); | |||||
| // Get.defaultDialog( | |||||
| // title: "Kiểm tra thông tin lô ....", | |||||
| // middleText: "", | |||||
| // content: const CircularProgressIndicator(), | |||||
| // ); | |||||
| try { | |||||
| UtilWidget.showLoading(); | |||||
| await repository.getPlotDetailByCode(cropCode, page: 1, size: 1).then((value) { | |||||
| print("ok"); | |||||
| UtilWidget.hideLoading(); | |||||
| Get.to( | |||||
| PlotDetailScreen( | |||||
| cropId: value.tbCropDTO?.id ?? -1, | |||||
| cropType: value.tbCropDTO?.type ?? -1, | |||||
| initialIndex: 0, | |||||
| ), | |||||
| ); | |||||
| }).catchError((onError) { | |||||
| UtilWidget.hideLoading(); | |||||
| 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) { | |||||
| UtilWidget.hideLoading(); | |||||
| 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); | |||||
| }, | |||||
| ); | |||||
| } | |||||
| } | |||||
| } |
| part of 'scan_qr_code_cubit.dart'; | |||||
| abstract class ScanQrCodeState extends Equatable { | |||||
| const ScanQrCodeState(); | |||||
| @override | |||||
| List<Object> get props => []; | |||||
| } | |||||
| class ScanQrCodeInitial extends ScanQrCodeState {} |
| class RequestAttendance { | |||||
| List<AttendanceStudents>? students; | |||||
| String? type; | |||||
| RequestAttendance({this.students, this.type}); | |||||
| RequestAttendance.fromJson(Map<String, dynamic> json) { | |||||
| if (json['students'] != null) { | |||||
| students = <AttendanceStudents>[]; | |||||
| json['students'].forEach((v) { | |||||
| students!.add(AttendanceStudents.fromJson(v)); | |||||
| }); | |||||
| } | |||||
| type = json['type']; | |||||
| } | |||||
| Map<String, dynamic> toJson() { | |||||
| final data = <String, dynamic>{}; | |||||
| if (students != null) { | |||||
| data['students'] = students!.map((v) => v.toJson()).toList(); | |||||
| } | |||||
| data['type'] = type; | |||||
| return data; | |||||
| } | |||||
| } | |||||
| class AttendanceStudents { | |||||
| String? studentId; | |||||
| String? code; | |||||
| bool? status; | |||||
| String? description; | |||||
| String? parentId; | |||||
| String? leaveStatus; | |||||
| AttendanceStudents({this.studentId, this.code, this.status, this.description, this.parentId, this.leaveStatus}); | |||||
| AttendanceStudents.fromJson(Map<String, dynamic> json) { | |||||
| studentId = json['student_id']; | |||||
| code = json['code']; | |||||
| status = json['status']; | |||||
| description = json['description']; | |||||
| parentId = json['parent_id']; | |||||
| leaveStatus = json['leave_status']; | |||||
| } | |||||
| Map<String, dynamic> toJson() { | |||||
| final data = <String, dynamic>{}; | |||||
| data['student_id'] = studentId; | |||||
| data['code'] = code; | |||||
| data['status'] = status; | |||||
| data['description'] = description; | |||||
| data['leave_status'] = leaveStatus; | |||||
| return data; | |||||
| } | |||||
| } |
| import 'package:flutter/material.dart'; | |||||
| import 'package:get/get.dart'; | |||||
| import 'package:qr_code_scanner/qr_code_scanner.dart'; | |||||
| import 'cubit/scan_qr_code_cubit.dart'; | |||||
| class ScanQRCodeSPage extends StatefulWidget { | |||||
| ScanQRCodeSPage({ | |||||
| Key? key, | |||||
| }) : super(key: key); | |||||
| @override | |||||
| State<ScanQRCodeSPage> createState() => _ScanQRCodeSPageState(); | |||||
| } | |||||
| class _ScanQRCodeSPageState extends State<ScanQRCodeSPage> { | |||||
| var bloc = ScanQrCodeCubit(); | |||||
| @override | |||||
| void initState() { | |||||
| super.initState(); | |||||
| bloc.init(); | |||||
| } | |||||
| @override | |||||
| void dispose() { | |||||
| super.dispose(); | |||||
| bloc.dispose(); | |||||
| } | |||||
| @override | |||||
| Widget build(BuildContext context) { | |||||
| bloc.context = context; | |||||
| return Scaffold( | |||||
| body: Column( | |||||
| children: [ | |||||
| Expanded( | |||||
| child: Stack( | |||||
| children: [ | |||||
| QRView( | |||||
| key: bloc.qrKey, | |||||
| onQRViewCreated: bloc.onQRViewCreated, | |||||
| overlay: QrScannerOverlayShape( | |||||
| borderColor: Colors.grey.shade300, | |||||
| borderRadius: 16.0, | |||||
| borderWidth: 4.0, | |||||
| cutOutSize: Get.width / 3 * 2, | |||||
| ), | |||||
| ), | |||||
| Column( | |||||
| crossAxisAlignment: CrossAxisAlignment.start, | |||||
| children: [ | |||||
| SizedBox(height: MediaQuery.of(context).padding.top + 20.0), | |||||
| // Padding( | |||||
| // padding: EdgeInsets.only(left: 20.0), | |||||
| // child: AppButton( | |||||
| // width: 48.0.sp, | |||||
| // height: 48.0.sp, | |||||
| // outlinedBorder: RoundedRectangleBorder( | |||||
| // borderRadius: BorderRadius.circular(26.0.sp), | |||||
| // ), | |||||
| // onPressed: Get.back, | |||||
| // backgroundColor: (ThemeConstants.appColors[ColorConstants.gray900] as Color).withOpacity(0.4), | |||||
| // rightWidget: AppSvg24px( | |||||
| // AppImages.basicClose, | |||||
| // color: ThemeConstants.appColors[ColorConstants.white], | |||||
| // ), | |||||
| // ), | |||||
| // ), | |||||
| ], | |||||
| ), | |||||
| // Obx(() => bloc.isLoading.value ? const AppLoading() : const SizedBox.shrink()), | |||||
| ], | |||||
| ), | |||||
| ), | |||||
| ], | |||||
| ), | |||||
| ); | |||||
| } | |||||
| } |
| import 'dart:io'; | |||||
| import 'package:farm_tpf/data/repository/repository.dart'; | |||||
| import 'package:flutter/material.dart'; | |||||
| import 'package:flutter/src/foundation/key.dart'; | |||||
| import 'package:flutter/src/widgets/framework.dart'; | |||||
| import 'package:get/get.dart'; | |||||
| import 'package:qr_code_scanner/qr_code_scanner.dart'; | |||||
| import '../../custom_widgets/widget_utils.dart'; | |||||
| import '../plot_detail/sc_plot_detail.dart'; | |||||
| class ScanQrPage extends StatefulWidget { | |||||
| const ScanQrPage({Key? key}) : super(key: key); | |||||
| @override | |||||
| State<ScanQrPage> createState() => _ScanQrPageState(); | |||||
| } | |||||
| class _ScanQrPageState extends State<ScanQrPage> { | |||||
| Barcode? result; | |||||
| QRViewController? controller; | |||||
| final GlobalKey qrKey = GlobalKey(debugLabel: 'QR'); | |||||
| // In order to get hot reload to work we need to pause the camera if the platform | |||||
| // is android, or resume the camera if the platform is iOS. | |||||
| @override | |||||
| void reassemble() { | |||||
| super.reassemble(); | |||||
| if (Platform.isAndroid) { | |||||
| controller!.pauseCamera(); | |||||
| } | |||||
| controller!.resumeCamera(); | |||||
| } | |||||
| @override | |||||
| Widget build(BuildContext context) { | |||||
| return Scaffold( | |||||
| body: SafeArea( | |||||
| child: Column( | |||||
| children: <Widget>[ | |||||
| Expanded(flex: 4, child: _buildQrView(context)), | |||||
| Expanded( | |||||
| flex: 1, | |||||
| child: FittedBox( | |||||
| fit: BoxFit.contain, | |||||
| child: Column( | |||||
| mainAxisAlignment: MainAxisAlignment.spaceEvenly, | |||||
| children: <Widget>[ | |||||
| if (result != null) Text('Barcode Type') else const Text('Scan a code'), | |||||
| Row( | |||||
| mainAxisAlignment: MainAxisAlignment.center, | |||||
| crossAxisAlignment: CrossAxisAlignment.center, | |||||
| children: <Widget>[ | |||||
| Container( | |||||
| margin: const EdgeInsets.all(8), | |||||
| child: ElevatedButton( | |||||
| onPressed: () async { | |||||
| await controller?.toggleFlash(); | |||||
| setState(() {}); | |||||
| }, | |||||
| child: FutureBuilder( | |||||
| future: controller?.getFlashStatus(), | |||||
| builder: (context, snapshot) { | |||||
| return Text('Flash: ${snapshot.data}'); | |||||
| }, | |||||
| )), | |||||
| ), | |||||
| Container( | |||||
| margin: const EdgeInsets.all(8), | |||||
| child: ElevatedButton( | |||||
| onPressed: () async { | |||||
| await controller?.flipCamera(); | |||||
| setState(() {}); | |||||
| }, | |||||
| child: FutureBuilder( | |||||
| future: controller?.getCameraInfo(), | |||||
| builder: (context, snapshot) { | |||||
| if (snapshot.data != null) { | |||||
| return Text('Camera facing '); | |||||
| } else { | |||||
| return const Text('loading'); | |||||
| } | |||||
| }, | |||||
| )), | |||||
| ) | |||||
| ], | |||||
| ), | |||||
| Row( | |||||
| mainAxisAlignment: MainAxisAlignment.center, | |||||
| crossAxisAlignment: CrossAxisAlignment.center, | |||||
| children: <Widget>[ | |||||
| Container( | |||||
| margin: const EdgeInsets.all(8), | |||||
| child: ElevatedButton( | |||||
| onPressed: () async { | |||||
| await controller?.pauseCamera(); | |||||
| }, | |||||
| child: const Text('pause', style: TextStyle(fontSize: 20)), | |||||
| ), | |||||
| ), | |||||
| Container( | |||||
| margin: const EdgeInsets.all(8), | |||||
| child: ElevatedButton( | |||||
| onPressed: () async { | |||||
| await controller?.resumeCamera(); | |||||
| }, | |||||
| child: const Text('resume', style: TextStyle(fontSize: 20)), | |||||
| ), | |||||
| ) | |||||
| ], | |||||
| ), | |||||
| ], | |||||
| ), | |||||
| ), | |||||
| ) | |||||
| ], | |||||
| ), | |||||
| ), | |||||
| ); | |||||
| } | |||||
| Widget _buildQrView(BuildContext context) { | |||||
| // For this example we check how width or tall the device is and change the scanArea and overlay accordingly. | |||||
| var scanArea = (MediaQuery.of(context).size.width < 400 || MediaQuery.of(context).size.height < 400) ? 150.0 : 300.0; | |||||
| // To ensure the Scanner view is properly sizes after rotation | |||||
| // we need to listen for Flutter SizeChanged notification and update controller | |||||
| return QRView( | |||||
| key: qrKey, | |||||
| onQRViewCreated: _onQRViewCreated, | |||||
| overlay: QrScannerOverlayShape(borderColor: Colors.red, borderRadius: 10, borderLength: 30, borderWidth: 10, cutOutSize: scanArea), | |||||
| onPermissionSet: (ctrl, p) => _onPermissionSet(context, ctrl, p), | |||||
| ); | |||||
| } | |||||
| void _onQRViewCreated(QRViewController controller) { | |||||
| setState(() { | |||||
| this.controller = controller; | |||||
| }); | |||||
| controller.scannedDataStream.listen((scanData) { | |||||
| setState(() { | |||||
| result = scanData; | |||||
| }); | |||||
| }); | |||||
| } | |||||
| void _onPermissionSet(BuildContext context, QRViewController ctrl, bool p) { | |||||
| if (!p) { | |||||
| ScaffoldMessenger.of(context).showSnackBar( | |||||
| const SnackBar(content: Text('no Permission')), | |||||
| ); | |||||
| } | |||||
| } | |||||
| @override | |||||
| void dispose() { | |||||
| controller?.dispose(); | |||||
| super.dispose(); | |||||
| } | |||||
| } |
| import 'package:farm_tpf/presentation/screens/notification/update_count_noti_bloc.dart'; | import 'package:farm_tpf/presentation/screens/notification/update_count_noti_bloc.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/plot/sc_plot.dart'; | import 'package:farm_tpf/presentation/screens/plot/sc_plot.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_detail.dart'; | import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_detail.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/scan_qr/scan_qr_page.dart'; | |||||
| import 'package:farm_tpf/utils/NotificationsBloc.dart'; | import 'package:farm_tpf/utils/NotificationsBloc.dart'; | ||||
| import 'package:farm_tpf/utils/const_color.dart'; | import 'package:farm_tpf/utils/const_color.dart'; | ||||
| import 'package:farm_tpf/utils/const_common.dart'; | import 'package:farm_tpf/utils/const_common.dart'; | ||||
| import 'package:get/get.dart'; | import 'package:get/get.dart'; | ||||
| import '../../../main.dart'; | import '../../../main.dart'; | ||||
| import '../scan_qr/scan_qr_code_page.dart'; | |||||
| class TabbarScreen extends StatefulWidget { | class TabbarScreen extends StatefulWidget { | ||||
| static Route route() { | static Route route() { | ||||
| onTap: () { | onTap: () { | ||||
| //Open scan qr code when tap icon in tabbar | //Open scan qr code when tap icon in tabbar | ||||
| if (index == 2) { | if (index == 2) { | ||||
| changeTabbar.changeIndex(changeTabbar.index); | |||||
| Get.to(() => ScanQRCodeSPage()); | |||||
| // changeTabbar.changeIndex(changeTabbar.index); | |||||
| // scan(context); | // scan(context); | ||||
| } else { | } else { | ||||
| changeTabbar.changeIndex(itemsTabbar[index].index); | changeTabbar.changeIndex(itemsTabbar[index].index); |
| url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
| source: hosted | source: hosted | ||||
| version: "1.2.1" | version: "1.2.1" | ||||
| qr_code_scanner: | |||||
| dependency: "direct main" | |||||
| description: | |||||
| name: qr_code_scanner | |||||
| url: "https://pub.dartlang.org" | |||||
| source: hosted | |||||
| version: "1.0.1" | |||||
| quiver: | quiver: | ||||
| dependency: transitive | dependency: transitive | ||||
| description: | description: |
| # file_picker: ^5.2.5 | # file_picker: ^5.2.5 | ||||
| flutter_cache_manager: any | flutter_cache_manager: any | ||||
| hive: ^2.1.0 | hive: ^2.1.0 | ||||
| qr_code_scanner: ^1.0.1 | |||||
| mime: ^1.0.3 | mime: ^1.0.3 | ||||
| flutter_image_compress: ^1.1.3 | flutter_image_compress: ^1.1.3 |