| defaultConfig { | defaultConfig { | ||||
| // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). | ||||
| applicationId "com.example.farm_tpf" | applicationId "com.example.farm_tpf" | ||||
| minSdkVersion 16 | |||||
| minSdkVersion 18 | |||||
| targetSdkVersion 28 | targetSdkVersion 28 | ||||
| versionCode flutterVersionCode.toInteger() | versionCode flutterVersionCode.toInteger() | ||||
| versionName flutterVersionName | versionName flutterVersionName |
| additional functionality it is fine to subclass or reimplement | additional functionality it is fine to subclass or reimplement | ||||
| FlutterApplication and put your custom class here. --> | FlutterApplication and put your custom class here. --> | ||||
| <uses-permission android:name="android.permission.INTERNET"/> | <uses-permission android:name="android.permission.INTERNET"/> | ||||
| <uses-permission android:name="android.permission.CAMERA" /> | |||||
| <application | <application | ||||
| android:name="io.flutter.app.FlutterApplication" | android:name="io.flutter.app.FlutterApplication" | ||||
| android:label="farm_tpf" | android:label="farm_tpf" |
| buildscript { | buildscript { | ||||
| ext.kotlin_version = '1.3.50' | |||||
| ext.kotlin_version = '1.3.61' | |||||
| repositories { | repositories { | ||||
| google() | google() | ||||
| jcenter() | jcenter() |
| PODS: | PODS: | ||||
| - barcode_scan (0.0.1): | |||||
| - Flutter | |||||
| - MTBBarcodeScanner | |||||
| - SwiftProtobuf | |||||
| - Flutter (1.0.0) | - Flutter (1.0.0) | ||||
| - MTBBarcodeScanner (5.0.11) | |||||
| - path_provider_linux (0.0.1): | - path_provider_linux (0.0.1): | ||||
| - Flutter | - Flutter | ||||
| - shared_preferences (0.0.1): | - shared_preferences (0.0.1): | ||||
| - Flutter | - Flutter | ||||
| - shared_preferences_web (0.0.1): | - shared_preferences_web (0.0.1): | ||||
| - Flutter | - Flutter | ||||
| - SwiftProtobuf (1.11.0) | |||||
| DEPENDENCIES: | DEPENDENCIES: | ||||
| - barcode_scan (from `.symlinks/plugins/barcode_scan/ios`) | |||||
| - Flutter (from `Flutter`) | - Flutter (from `Flutter`) | ||||
| - path_provider_linux (from `.symlinks/plugins/path_provider_linux/ios`) | - path_provider_linux (from `.symlinks/plugins/path_provider_linux/ios`) | ||||
| - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`) | - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`) | ||||
| - shared_preferences_macos (from `.symlinks/plugins/shared_preferences_macos/ios`) | - shared_preferences_macos (from `.symlinks/plugins/shared_preferences_macos/ios`) | ||||
| - shared_preferences_web (from `.symlinks/plugins/shared_preferences_web/ios`) | - shared_preferences_web (from `.symlinks/plugins/shared_preferences_web/ios`) | ||||
| SPEC REPOS: | |||||
| trunk: | |||||
| - MTBBarcodeScanner | |||||
| - SwiftProtobuf | |||||
| EXTERNAL SOURCES: | EXTERNAL SOURCES: | ||||
| barcode_scan: | |||||
| :path: ".symlinks/plugins/barcode_scan/ios" | |||||
| Flutter: | Flutter: | ||||
| :path: Flutter | :path: Flutter | ||||
| path_provider_linux: | path_provider_linux: | ||||
| :path: ".symlinks/plugins/shared_preferences_web/ios" | :path: ".symlinks/plugins/shared_preferences_web/ios" | ||||
| SPEC CHECKSUMS: | SPEC CHECKSUMS: | ||||
| barcode_scan: a5c27959edfafaa0c771905bad0b29d6d39e4479 | |||||
| Flutter: 0e3d915762c693b495b44d77113d4970485de6ec | Flutter: 0e3d915762c693b495b44d77113d4970485de6ec | ||||
| MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb | |||||
| path_provider_linux: 4d630dc393e1f20364f3e3b4a2ff41d9674a84e4 | path_provider_linux: 4d630dc393e1f20364f3e3b4a2ff41d9674a84e4 | ||||
| shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d | shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d | ||||
| shared_preferences_linux: afefbfe8d921e207f01ede8b60373d9e3b566b78 | shared_preferences_linux: afefbfe8d921e207f01ede8b60373d9e3b566b78 | ||||
| shared_preferences_macos: f3f29b71ccbb56bf40c9dd6396c9acf15e214087 | shared_preferences_macos: f3f29b71ccbb56bf40c9dd6396c9acf15e214087 | ||||
| shared_preferences_web: 141cce0c3ed1a1c5bf2a0e44f52d31eeb66e5ea9 | shared_preferences_web: 141cce0c3ed1a1c5bf2a0e44f52d31eeb66e5ea9 | ||||
| SwiftProtobuf: f889fe5772f90ef7d7b8aac352d1fddf39650713 | |||||
| PODFILE CHECKSUM: c34e2287a9ccaa606aeceab922830efb9a6ff69a | PODFILE CHECKSUM: c34e2287a9ccaa606aeceab922830efb9a6ff69a | ||||
| archiveVersion = 1; | archiveVersion = 1; | ||||
| classes = { | classes = { | ||||
| }; | }; | ||||
| objectVersion = 46; | |||||
| objectVersion = 50; | |||||
| objects = { | objects = { | ||||
| /* Begin PBXBuildFile section */ | /* Begin PBXBuildFile section */ | ||||
| 1BA1D19EF353DFCE335E0C1F /* Pods-Runner.release.xcconfig */, | 1BA1D19EF353DFCE335E0C1F /* Pods-Runner.release.xcconfig */, | ||||
| 95FEBA268448B96856A798E7 /* Pods-Runner.profile.xcconfig */, | 95FEBA268448B96856A798E7 /* Pods-Runner.profile.xcconfig */, | ||||
| ); | ); | ||||
| name = Pods; | |||||
| path = Pods; | path = Pods; | ||||
| sourceTree = "<group>"; | sourceTree = "<group>"; | ||||
| }; | }; | ||||
| buildActionMask = 2147483647; | buildActionMask = 2147483647; | ||||
| files = ( | files = ( | ||||
| ); | ); | ||||
| inputPaths = ( | |||||
| "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", | |||||
| "${PODS_ROOT}/../Flutter/Flutter.framework", | |||||
| "${BUILT_PRODUCTS_DIR}/shared_preferences/shared_preferences.framework", | |||||
| inputFileListPaths = ( | |||||
| "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", | |||||
| ); | ); | ||||
| name = "[CP] Embed Pods Frameworks"; | name = "[CP] Embed Pods Frameworks"; | ||||
| outputPaths = ( | |||||
| "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", | |||||
| "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences.framework", | |||||
| outputFileListPaths = ( | |||||
| "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", | |||||
| ); | ); | ||||
| runOnlyForDeploymentPostprocessing = 0; | runOnlyForDeploymentPostprocessing = 0; | ||||
| shellPath = /bin/sh; | shellPath = /bin/sh; | ||||
| ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ||||
| CLANG_ENABLE_MODULES = YES; | CLANG_ENABLE_MODULES = YES; | ||||
| CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; | ||||
| DEVELOPMENT_TEAM = C3DTD2JH94; | |||||
| ENABLE_BITCODE = NO; | ENABLE_BITCODE = NO; | ||||
| FRAMEWORK_SEARCH_PATHS = ( | FRAMEWORK_SEARCH_PATHS = ( | ||||
| "$(inherited)", | "$(inherited)", | ||||
| "$(PROJECT_DIR)/Flutter", | "$(PROJECT_DIR)/Flutter", | ||||
| ); | ); | ||||
| INFOPLIST_FILE = Runner/Info.plist; | INFOPLIST_FILE = Runner/Info.plist; | ||||
| LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; | |||||
| LD_RUNPATH_SEARCH_PATHS = ( | |||||
| "$(inherited)", | |||||
| "@executable_path/Frameworks", | |||||
| ); | |||||
| LIBRARY_SEARCH_PATHS = ( | LIBRARY_SEARCH_PATHS = ( | ||||
| "$(inherited)", | "$(inherited)", | ||||
| "$(PROJECT_DIR)/Flutter", | "$(PROJECT_DIR)/Flutter", | ||||
| MTL_ENABLE_DEBUG_INFO = NO; | MTL_ENABLE_DEBUG_INFO = NO; | ||||
| SDKROOT = iphoneos; | SDKROOT = iphoneos; | ||||
| SUPPORTED_PLATFORMS = iphoneos; | SUPPORTED_PLATFORMS = iphoneos; | ||||
| SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; | |||||
| SWIFT_COMPILATION_MODE = wholemodule; | |||||
| SWIFT_OPTIMIZATION_LEVEL = "-O"; | |||||
| TARGETED_DEVICE_FAMILY = "1,2"; | TARGETED_DEVICE_FAMILY = "1,2"; | ||||
| VALIDATE_PRODUCT = YES; | VALIDATE_PRODUCT = YES; | ||||
| }; | }; | ||||
| ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ||||
| CLANG_ENABLE_MODULES = YES; | CLANG_ENABLE_MODULES = YES; | ||||
| CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; | ||||
| DEVELOPMENT_TEAM = C3DTD2JH94; | |||||
| ENABLE_BITCODE = NO; | ENABLE_BITCODE = NO; | ||||
| FRAMEWORK_SEARCH_PATHS = ( | FRAMEWORK_SEARCH_PATHS = ( | ||||
| "$(inherited)", | "$(inherited)", | ||||
| "$(PROJECT_DIR)/Flutter", | "$(PROJECT_DIR)/Flutter", | ||||
| ); | ); | ||||
| INFOPLIST_FILE = Runner/Info.plist; | INFOPLIST_FILE = Runner/Info.plist; | ||||
| LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; | |||||
| LD_RUNPATH_SEARCH_PATHS = ( | |||||
| "$(inherited)", | |||||
| "@executable_path/Frameworks", | |||||
| ); | |||||
| LIBRARY_SEARCH_PATHS = ( | LIBRARY_SEARCH_PATHS = ( | ||||
| "$(inherited)", | "$(inherited)", | ||||
| "$(PROJECT_DIR)/Flutter", | "$(PROJECT_DIR)/Flutter", | ||||
| ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ||||
| CLANG_ENABLE_MODULES = YES; | CLANG_ENABLE_MODULES = YES; | ||||
| CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; | ||||
| DEVELOPMENT_TEAM = C3DTD2JH94; | |||||
| ENABLE_BITCODE = NO; | ENABLE_BITCODE = NO; | ||||
| FRAMEWORK_SEARCH_PATHS = ( | FRAMEWORK_SEARCH_PATHS = ( | ||||
| "$(inherited)", | "$(inherited)", | ||||
| "$(PROJECT_DIR)/Flutter", | "$(PROJECT_DIR)/Flutter", | ||||
| ); | ); | ||||
| INFOPLIST_FILE = Runner/Info.plist; | INFOPLIST_FILE = Runner/Info.plist; | ||||
| LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; | |||||
| LD_RUNPATH_SEARCH_PATHS = ( | |||||
| "$(inherited)", | |||||
| "@executable_path/Frameworks", | |||||
| ); | |||||
| LIBRARY_SEARCH_PATHS = ( | LIBRARY_SEARCH_PATHS = ( | ||||
| "$(inherited)", | "$(inherited)", | ||||
| "$(PROJECT_DIR)/Flutter", | "$(PROJECT_DIR)/Flutter", |
| </array> | </array> | ||||
| <key>UIViewControllerBasedStatusBarAppearance</key> | <key>UIViewControllerBasedStatusBarAppearance</key> | ||||
| <false/> | <false/> | ||||
| <!-- Camera Permission --> | |||||
| <key>NSCameraUsageDescription</key> | |||||
| <string>Camera permission is required for barcode scanning.</string> | |||||
| </dict> | </dict> | ||||
| </plist> | </plist> |
| class WidgetToast extends StatelessWidget { | class WidgetToast extends StatelessWidget { | ||||
| String message; | String message; | ||||
| WidgetToast({@required this.message}); | |||||
| Color color = Colors.greenAccent; | |||||
| WidgetToast({@required this.message, this.color}); | |||||
| @override | @override | ||||
| Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
| padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0), | padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0), | ||||
| decoration: BoxDecoration( | decoration: BoxDecoration( | ||||
| borderRadius: BorderRadius.circular(25.0), | borderRadius: BorderRadius.circular(25.0), | ||||
| color: Colors.greenAccent, | |||||
| color: color, | |||||
| ), | ), | ||||
| child: Row( | child: Row( | ||||
| mainAxisSize: MainAxisSize.min, | mainAxisSize: MainAxisSize.min, |
| import 'dart:io' show Platform; | |||||
| import 'package:barcode_scan/barcode_scan.dart'; | |||||
| import 'package:farm_tpf/presentation/custom_widgets/widget_toast.dart'; | |||||
| import 'package:farm_tpf/presentation/screens/home/home.dart'; | |||||
| import 'package:flutter/material.dart'; | |||||
| import 'package:flutter/services.dart'; | |||||
| import 'package:fluttertoast/fluttertoast.dart'; | |||||
| class ScanBarcodeScreen extends StatefulWidget { | |||||
| @override | |||||
| _ScanBarcodeScreenState createState() => _ScanBarcodeScreenState(); | |||||
| } | |||||
| class _ScanBarcodeScreenState extends State<ScanBarcodeScreen> { | |||||
| ScanResult scanResult; | |||||
| var _aspectTolerance = 0.00; | |||||
| var _selectedCamera = -1; | |||||
| var _useAutoFocus = true; | |||||
| var _autoEnableFlash = false; | |||||
| final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>(); | |||||
| FlutterToast flutterToast; | |||||
| @override | |||||
| // ignore: type_annotate_public_apis | |||||
| initState() { | |||||
| super.initState(); | |||||
| flutterToast = FlutterToast(context); | |||||
| scan(); | |||||
| } | |||||
| @override | |||||
| Widget build(BuildContext context) { | |||||
| return Scaffold( | |||||
| key: _scaffoldKey, | |||||
| appBar: AppBar( | |||||
| title: Text("Quét mã QR"), | |||||
| ), | |||||
| body: Center( | |||||
| child: scanResult == null ? Container() : Text(scanResult?.rawContent), | |||||
| ), | |||||
| ); | |||||
| } | |||||
| Future scan() async { | |||||
| 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); | |||||
| setState(() { | |||||
| scanResult = result; | |||||
| if (1 != 1) { | |||||
| Navigator.of(context).pop(); | |||||
| Navigator.of(context) | |||||
| .push(MaterialPageRoute(builder: (_) => HomePage())); | |||||
| } else { | |||||
| flutterToast.showToast( | |||||
| child: | |||||
| WidgetToast(message: "Mã QR không đúng", color: Colors.red)); | |||||
| Navigator.of(context).pop(); | |||||
| } | |||||
| }); | |||||
| } on PlatformException catch (e) { | |||||
| var result = ScanResult( | |||||
| type: ResultType.Error, | |||||
| format: BarcodeFormat.unknown, | |||||
| ); | |||||
| if (e.code == BarcodeScanner.cameraAccessDenied) { | |||||
| setState(() { | |||||
| result.rawContent = 'Vui lòng cấp quyền truy cập camera'; | |||||
| }); | |||||
| } else { | |||||
| result.rawContent = 'Vui lòng cấp quyền truy cập camera.'; | |||||
| } | |||||
| setState(() { | |||||
| scanResult = result; | |||||
| }); | |||||
| flutterToast.showToast( | |||||
| child: WidgetToast( | |||||
| message: "Vui lòng cấp quyền truy cập camera.", | |||||
| color: Colors.red)); | |||||
| Navigator.of(context).pop(); | |||||
| } | |||||
| } | |||||
| } |
| void setdDrawerListArray() { | void setdDrawerListArray() { | ||||
| drawerList = <DrawerList>[ | drawerList = <DrawerList>[ | ||||
| DrawerList( | |||||
| index: DrawerIndex.ScanBarcode, | |||||
| labelName: "Quét mã QR", | |||||
| icon: Icon(Icons.scanner)), | |||||
| DrawerList( | DrawerList( | ||||
| index: DrawerIndex.Home, | index: DrawerIndex.Home, | ||||
| labelName: 'Trang chủ', | |||||
| labelName: 'Danh sách lô', | |||||
| icon: Icon(Icons.home), | icon: Icon(Icons.home), | ||||
| ), | ), | ||||
| DrawerList( | DrawerList( | ||||
| } | } | ||||
| } | } | ||||
| enum DrawerIndex { Home, Setting } | |||||
| enum DrawerIndex { ScanBarcode, Home, Setting } | |||||
| class DrawerList { | class DrawerList { | ||||
| DrawerList({ | DrawerList({ |
| import 'package:farm_tpf/presentation/screens/home/home.dart'; | import 'package:farm_tpf/presentation/screens/home/home.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/profile/sc_update_profile.dart'; | import 'package:farm_tpf/presentation/screens/profile/sc_update_profile.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/scan_barcode/sc_scan_barcode.dart'; | |||||
| import 'package:farm_tpf/utils/const_color.dart'; | import 'package:farm_tpf/utils/const_color.dart'; | ||||
| import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
| setState(() { | setState(() { | ||||
| screenView = UpdateProfileScreen(); | screenView = UpdateProfileScreen(); | ||||
| }); | }); | ||||
| } else if (drawerIndex == DrawerIndex.ScanBarcode) { | |||||
| Navigator.of(context) | |||||
| .push(MaterialPageRoute(builder: (_) => ScanBarcodeScreen())); | |||||
| // setState(() { | |||||
| // screenView = ScanBarcodeScreen(); | |||||
| // }); | |||||
| } else { | } else { | ||||
| //do in your way...... | //do in your way...... | ||||
| } | } |
| url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
| source: hosted | source: hosted | ||||
| version: "2.4.1" | version: "2.4.1" | ||||
| barcode_scan: | |||||
| dependency: "direct main" | |||||
| description: | |||||
| name: barcode_scan | |||||
| url: "https://pub.dartlang.org" | |||||
| source: hosted | |||||
| version: "3.0.1" | |||||
| bloc: | bloc: | ||||
| dependency: transitive | dependency: transitive | ||||
| description: | description: | ||||
| url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
| source: hosted | source: hosted | ||||
| version: "3.0.13" | version: "3.0.13" | ||||
| protobuf: | |||||
| dependency: transitive | |||||
| description: | |||||
| name: protobuf | |||||
| url: "https://pub.dartlang.org" | |||||
| source: hosted | |||||
| version: "1.0.1" | |||||
| provider: | provider: | ||||
| dependency: transitive | dependency: transitive | ||||
| description: | description: |
| fluttertoast: ^6.0.1 | fluttertoast: ^6.0.1 | ||||
| pattern_formatter: ^1.0.2 | pattern_formatter: ^1.0.2 | ||||
| rxdart: ^0.23.0 | rxdart: ^0.23.0 | ||||
| barcode_scan: ^3.0.1 | |||||
| dev_dependencies: | dev_dependencies: | ||||
| flutter_test: | flutter_test: |