From 875f930da46a9ddac5367ec6db8d7acf0a58b1e3 Mon Sep 17 00:00:00 2001 From: error500 Date: Tue, 25 Jan 2022 13:42:34 +0600 Subject: [PATCH] migrate initial --- lib/core/base/base_service.dart | 4 +- lib/core/entity/Category.dart | 8 +- lib/core/entity/Goods.dart | 22 +- lib/core/entity/Service.dart | 19 +- lib/core/entity/Voucher.dart | 24 +- lib/core/logger.dart | 16 +- lib/core/models/auth_response.dart | 14 +- lib/core/models/calc_model.dart | 4 +- lib/core/models/check_data.dart | 8 +- lib/core/models/check_image_modal.dart | 4 +- lib/core/models/check_item.dart | 4 +- lib/core/models/choice.dart | 2 +- lib/core/models/dialog_models.dart | 14 +- lib/core/models/dict_dao.dart | 2 +- lib/core/models/message.dart | 2 +- lib/core/models/money.dart | 4 +- lib/core/models/product_dao.dart | 8 +- lib/core/models/response.dart | 4 +- lib/core/models/setting_model.dart | 6 +- lib/core/models/smena.dart | 8 +- lib/core/models/user.dart | 14 +- lib/core/router.dart | 28 +-- lib/core/services/ApiService.dart | 6 +- lib/core/services/DataService.dart | 90 +++---- lib/core/services/DbService.dart | 8 +- lib/core/services/authentication_service.dart | 20 +- lib/core/services/dialog_service.dart | 34 +-- lib/core/services/navigator_service.dart | 16 +- lib/core/utilsParse.dart | 2 +- lib/main.dart | 57 +++-- lib/redux/actions/calc_actions.dart | 3 +- lib/redux/actions/kassa_actions.dart | 26 +- lib/redux/actions/user_actions.dart | 20 +- lib/redux/state/calc_state.dart | 4 +- lib/redux/state/kassa_state.dart | 8 +- lib/redux/state/setting_state.dart | 22 +- lib/redux/state/user_state.dart | 52 ++-- lib/redux/store.dart | 34 +-- lib/views/check/image_show_container.dart | 59 ++--- lib/views/history/history_view.dart | 10 +- lib/views/home/components/bottom_bar.dart | 7 +- lib/views/home/components/header_title.dart | 10 +- lib/views/home/components/popup_menu.dart | 2 +- lib/views/home/home_view.dart | 32 +-- lib/views/home/tabs/AdditionalTab.dart | 44 ++-- lib/views/home/tabs/CalculatorTab.dart | 8 +- lib/views/home/tabs/KassaTab.dart | 28 +-- .../tabs/kassaView/CatalogBottomSheet.dart | 54 ++-- .../tabs/kassaView/ProductAddBottomSheet.dart | 10 +- lib/views/info_kkm/info_kkm_view.dart | 4 +- lib/views/lockscreen/passcodescreen.dart | 6 +- lib/views/login/login_view.dart | 42 ++-- lib/views/payment/payment_view.dart | 52 ++-- lib/views/qr_view/qr_view.dart | 2 +- .../settings/component/setting_item.dart | 12 +- lib/views/settings/printer/PrinterTest.dart | 159 +++++------- .../printer/views/PrinterEncoding.dart | 8 +- .../printer/views/PrinterPaperSize.dart | 8 +- .../settings/printer/views/PrinterSelect.dart | 170 +------------ lib/views/settings/setting_printer_view.dart | 20 +- lib/views/settings/settings_view.dart | 6 +- lib/views/start_up/start_up_view.dart | 7 +- lib/widgets/components/ProductListItem.dart | 12 +- .../calculator/calculator-button.dart | 4 +- .../calculator/calculator-buttons.dart | 2 +- .../components/calculator/calculator-row.dart | 2 +- .../components/calculator/calculator.dart | 31 +-- .../components/calculator/number-display.dart | 2 +- lib/widgets/dialog_manager.dart | 14 +- lib/widgets/fields/aman_icon_button.dart | 10 +- .../fields/aman_icon_button_horizontal.dart | 9 +- lib/widgets/fields/busy_button.dart | 8 +- lib/widgets/fields/busy_button_icon.dart | 14 +- lib/widgets/fields/input_field.dart | 36 +-- lib/widgets/fields/note_text.dart | 6 +- lib/widgets/fields/text_link.dart | 4 +- pubspec.lock | 237 ++++++++++-------- pubspec.yaml | 66 ++--- 78 files changed, 843 insertions(+), 995 deletions(-) diff --git a/lib/core/base/base_service.dart b/lib/core/base/base_service.dart index 03b422c..9024501 100644 --- a/lib/core/base/base_service.dart +++ b/lib/core/base/base_service.dart @@ -3,9 +3,9 @@ import 'package:logger/logger.dart'; import '../logger.dart'; class BaseService { - Logger log; + late Logger log; - BaseService({String title}) { + BaseService({String? title}) { this.log = getLogger( title ?? this.runtimeType.toString(), ); diff --git a/lib/core/entity/Category.dart b/lib/core/entity/Category.dart index f816f3a..a87e331 100644 --- a/lib/core/entity/Category.dart +++ b/lib/core/entity/Category.dart @@ -5,10 +5,10 @@ const String Category_columnName = 'name'; const String Category_columnAppCompanyId = 'app_company_id'; class Category { - int id; - int parentIn; - String name; - int appCompanyId; + int? id; + int? parentIn; + String name = ''; + int? appCompanyId; Map toMap() { var map = { diff --git a/lib/core/entity/Goods.dart b/lib/core/entity/Goods.dart index 6d0f31d..71addd3 100644 --- a/lib/core/entity/Goods.dart +++ b/lib/core/entity/Goods.dart @@ -13,17 +13,17 @@ const String Goog_columnOkei = 'okei'; const String Goog_columnDiscount = 'discount'; class Good { - int id; - int articul; - String name; - double price; - int categoryId; - String ean; - int appCompanyId; - String description; - double showPrice; - int okei; - double discount; + int? id; + int articul = -1; + String name = ''; + double price = -1; + int categoryId = -1; + String? ean; + int? appCompanyId; + String? description; + double? showPrice; + int? okei; + double? discount; Map toMap() { var map = { diff --git a/lib/core/entity/Service.dart b/lib/core/entity/Service.dart index 1226a93..5936b0e 100644 --- a/lib/core/entity/Service.dart +++ b/lib/core/entity/Service.dart @@ -14,16 +14,15 @@ const String Service_columnDiscount = 'discount'; class Service { - int id; - int articul; - String name; - double price; - String ean; - int appCompanyId; - String description; - double showPrice; - String okei; - double discount; + int? id; + int articul = -1; + String name = ''; + double price = -1; + int? appCompanyId; + String? description; + double? showPrice; + String? okei; + double? discount; Map toMap() { var map = { diff --git a/lib/core/entity/Voucher.dart b/lib/core/entity/Voucher.dart index 8b6740a..0f52599 100644 --- a/lib/core/entity/Voucher.dart +++ b/lib/core/entity/Voucher.dart @@ -16,16 +16,16 @@ const String VoucherTypeReturnPay = 'returnPay'; const String VoucherTypeReport = 'report'; class Voucher { - int id; - String name; - double total; - String data; - String base64Data; - DateTime dateTime; - int appCompanyId; - int kassaId; - String type; - String url; + int? id; + String? name; + double? total; + String? data; + String? base64Data; + DateTime? dateTime; + int? appCompanyId; + int? kassaId; + String? type; + String? url; Voucher(); @@ -35,7 +35,7 @@ class Voucher { Voucher_columnTotal: total, Voucher_columnData: data, Voucher_columnBase64Data: base64Data, - Voucher_columnDateTime: dateTime.toIso8601String(), + Voucher_columnDateTime: dateTime?.toIso8601String(), Voucher_columnKassaId: kassaId, Voucher_columnAppCompanyId: appCompanyId, Voucher_columnType: type, @@ -47,7 +47,7 @@ class Voucher { return map; } - Voucher.fromMap(Map map) { + Voucher.fromMap(Map map) { id = map[Voucher_columnId]; name = map[Voucher_columnName]; total = map[Voucher_columnTotal]?.toDouble(); diff --git a/lib/core/logger.dart b/lib/core/logger.dart index 01ec262..220141b 100644 --- a/lib/core/logger.dart +++ b/lib/core/logger.dart @@ -14,13 +14,13 @@ class SimpleLogPrinter extends LogPrinter { var error = event.error?.toString() ?? ''; var color = PrettyPrinter.levelColors[level]; var emoji = PrettyPrinter.levelEmojis[level]; - String stack; + String? stack; if (event.stackTrace == null) { stack = formatStackTrace(StackTrace.current, 2); } else { - stack = formatStackTrace(event.stackTrace, 1); + stack = formatStackTrace(event.stackTrace!, 1); } - print(color(' $emoji $message $error -> $stack ')); + print(color!(' $emoji $message $error -> $stack ')); return []; } @@ -33,9 +33,9 @@ class SimpleLogPrinter extends LogPrinter { } } - String formatStackTrace(StackTrace stackTrace, int methodPosition) { + String? formatStackTrace(StackTrace stackTrace, int methodPosition) { - var lines = stackTrace.toString()?.split('\n'); + var lines = stackTrace.toString().split('\n'); var formatted = []; var count = 0; for (var line in lines) { @@ -62,7 +62,7 @@ class SimpleLogPrinter extends LogPrinter { if (match == null) { return false; } - return match.group(2).startsWith('package:logger'); + return match.group(2)!.startsWith('package:logger'); } bool _discardWebStacktraceLine(String line) { @@ -70,8 +70,8 @@ class SimpleLogPrinter extends LogPrinter { if (match == null) { return false; } - return match.group(1).startsWith('packages/logger') || - match.group(1).startsWith('dart-sdk/lib'); + return match.group(1)!.startsWith('packages/logger') || + match.group(1)!.startsWith('dart-sdk/lib'); } } diff --git a/lib/core/models/auth_response.dart b/lib/core/models/auth_response.dart index d255f4d..310f23d 100644 --- a/lib/core/models/auth_response.dart +++ b/lib/core/models/auth_response.dart @@ -2,9 +2,9 @@ import '../utilsParse.dart'; import 'user.dart'; class AuthResponse { - final AuthBody body; - final int status; - final bool operation; + final AuthBody? body; + final int? status; + final bool? operation; AuthResponse( {this.body, this.status, this.operation}); @@ -19,10 +19,10 @@ class AuthResponse { } class AuthBody { - final List email; - final List password; - final String message; - final User user; + final List? email; + final List? password; + final String? message; + final User? user; AuthBody({this.message, this.user, this.email, this.password}); factory AuthBody.fromJson(Map json) { return AuthBody( diff --git a/lib/core/models/calc_model.dart b/lib/core/models/calc_model.dart index eb35ee4..cd85cda 100644 --- a/lib/core/models/calc_model.dart +++ b/lib/core/models/calc_model.dart @@ -1,9 +1,9 @@ class CalcModel { String num1; - String num2; + String? num2; bool closed; String operation; - CalcModel({this.num1, this.num2, this.operation, this.closed = false}); + CalcModel({required this.num1, this.num2, required this.operation, this.closed = false}); @override String toString() { diff --git a/lib/core/models/check_data.dart b/lib/core/models/check_data.dart index 954fd69..9b9ac02 100644 --- a/lib/core/models/check_data.dart +++ b/lib/core/models/check_data.dart @@ -1,9 +1,9 @@ import 'package:aman_kassa_flutter/core/models/check_item.dart'; class CheckData { - final String type; - num card; - final List items; + final String ?type; + num? card; + final List? items; CheckData({this.type, this.card, this.items}); static CheckData fromJson(Map json) { @@ -17,6 +17,6 @@ class CheckData { { 'type': type, 'card': card, - 'items': items.map((e) => e.toJson()).toList() + 'items': items?.map((e) => e.toJson()).toList() }; } \ No newline at end of file diff --git a/lib/core/models/check_image_modal.dart b/lib/core/models/check_image_modal.dart index 9ff93be..7eb062f 100644 --- a/lib/core/models/check_image_modal.dart +++ b/lib/core/models/check_image_modal.dart @@ -1,6 +1,6 @@ class CheckImageModal { - final String base64Data; - final String textData; + final String? base64Data; + final String? textData; CheckImageModal({this.base64Data, this.textData}); static CheckImageModal fromJson(Map json) { diff --git a/lib/core/models/check_item.dart b/lib/core/models/check_item.dart index 1793081..2159585 100644 --- a/lib/core/models/check_item.dart +++ b/lib/core/models/check_item.dart @@ -3,8 +3,8 @@ class CheckItem { final num cnt; final num price; final int articul; - final String excise; - CheckItem({this.name, this.cnt, this.price, this.articul, this.excise}); + final String? excise; + CheckItem({required this.name, required this.cnt, required this.price, required this.articul, this.excise}); static CheckItem fromJson(Map json) { return CheckItem( diff --git a/lib/core/models/choice.dart b/lib/core/models/choice.dart index 9a28e7e..59ba99b 100644 --- a/lib/core/models/choice.dart +++ b/lib/core/models/choice.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; class Choice { - const Choice({this.title, this.icon, this.command}); + const Choice({required this.title, required this.icon, required this.command}); final String command; final String title; final IconData icon; diff --git a/lib/core/models/dialog_models.dart b/lib/core/models/dialog_models.dart index bc7a325..a775f29 100644 --- a/lib/core/models/dialog_models.dart +++ b/lib/core/models/dialog_models.dart @@ -4,13 +4,13 @@ class DialogRequest { final String title; final String description; final String buttonTitle; - final String cancelTitle; - final String formatType; + final String? cancelTitle; + final String? formatType; DialogRequest( - {@required this.title, - @required this.description, - @required this.buttonTitle, + {required this.title, + required this.description, + required this.buttonTitle, this.cancelTitle, this.formatType}); } @@ -18,13 +18,13 @@ class DialogRequest { class DialogResponse { //final String fieldOne; //final String fieldTwo; - final String responseText; + final String? responseText; final bool confirmed; DialogResponse({ //this.fieldOne, //this.fieldTwo, this.responseText, - this.confirmed, + required this.confirmed, }); } diff --git a/lib/core/models/dict_dao.dart b/lib/core/models/dict_dao.dart index a54a7f2..9c040e9 100644 --- a/lib/core/models/dict_dao.dart +++ b/lib/core/models/dict_dao.dart @@ -1,5 +1,5 @@ class DictDao { final int id; final String name; - DictDao({ this.id, this.name}); + DictDao({ required this.id, required this.name}); } \ No newline at end of file diff --git a/lib/core/models/message.dart b/lib/core/models/message.dart index 0c5aeaf..ed0b6a6 100644 --- a/lib/core/models/message.dart +++ b/lib/core/models/message.dart @@ -1,7 +1,7 @@ class Message { final String message; - Message({this.message}); + Message({required this.message}); static Message fromJson(Map data) => Message(message : data['message']); diff --git a/lib/core/models/money.dart b/lib/core/models/money.dart index d377b35..20bfa90 100644 --- a/lib/core/models/money.dart +++ b/lib/core/models/money.dart @@ -1,5 +1,5 @@ class Money { - final num total; + final num? total; final bool loading; - Money({this.total, this.loading}); + Money({this.total, required this.loading}); } diff --git a/lib/core/models/product_dao.dart b/lib/core/models/product_dao.dart index 2e7dd26..6400aee 100644 --- a/lib/core/models/product_dao.dart +++ b/lib/core/models/product_dao.dart @@ -6,11 +6,11 @@ class ProductDao { final num price; num count; num total; - final Good good; - final Service service; - final String excise; + final Good? good; + final Service? service; + final String? excise; - ProductDao( {this.name, this.price, this.count, this.total, this.good, this.service, this.excise }); + ProductDao( {required this.name, required this.price, required this.count, required this.total, this.good, this.service, this.excise }); } \ No newline at end of file diff --git a/lib/core/models/response.dart b/lib/core/models/response.dart index 01907d9..9141b22 100644 --- a/lib/core/models/response.dart +++ b/lib/core/models/response.dart @@ -1,9 +1,9 @@ class Response { - final T body; + final T? body; final int status; final bool operation; - Response({this.body, this.operation, this.status}); + Response({this.body, required this.operation, required this.status}); factory Response.fromJson(Map data, Function parser) { return Response( diff --git a/lib/core/models/setting_model.dart b/lib/core/models/setting_model.dart index 6c4dd1e..efdefbd 100644 --- a/lib/core/models/setting_model.dart +++ b/lib/core/models/setting_model.dart @@ -1,6 +1,6 @@ class SettingModel { const SettingModel({this.name, this.type, this.address}); - final String type; - final String name; - final String address; + final String? type; + final String? name; + final String? address; } \ No newline at end of file diff --git a/lib/core/models/smena.dart b/lib/core/models/smena.dart index 519df1e..4cd8170 100644 --- a/lib/core/models/smena.dart +++ b/lib/core/models/smena.dart @@ -1,8 +1,8 @@ class Smena { - final int id; - final DateTime startedAt; - final DateTime endedAt; - final String message; + final int? id; + final DateTime? startedAt; + final DateTime? endedAt; + final String? message; Smena({this.id, this.startedAt, this.endedAt, this.message}); diff --git a/lib/core/models/user.dart b/lib/core/models/user.dart index 03ea279..9b84289 100644 --- a/lib/core/models/user.dart +++ b/lib/core/models/user.dart @@ -1,15 +1,15 @@ class User { - final String name; - final String email; - final String fullName; - final String token; - int appCompanyId; - int kassaId; + final String? name; + final String? email; + final String? fullName; + final String? token; + int? appCompanyId; + int? kassaId; User({this.email, this.fullName, this.name, this.token, this.appCompanyId, this.kassaId}); - static User fromJson(Map json) { + static User? fromJson(Map json) { return json != null ? User ( name: json['name'], diff --git a/lib/core/router.dart b/lib/core/router.dart index 1eadcf6..c395744 100644 --- a/lib/core/router.dart +++ b/lib/core/router.dart @@ -19,66 +19,66 @@ Route generateRoute(RouteSettings settings) { case LoginViewRoute: LoginModel model = settings.arguments as LoginModel; return _getPageRoute( - routeName: settings.name, + routeName: settings.name!, viewToShow: LoginView(loginModel: model,), ); case HomeViewRoute: return _getPageRoute( - routeName: settings.name, + routeName: settings.name!, viewToShow: HomeView(), ); case PaymentViewRoute: PaymentModel model = settings.arguments as PaymentModel; return _getPageRoute( - routeName: settings.name, + routeName: settings.name!, viewToShow: PaymentView(model: model), ); case HistoryViewRoute: return _getPageRoute( - routeName: settings.name, + routeName: settings.name!, viewToShow: HistoryView(), ); case InfoKkmViewRoute: return _getPageRoute( - routeName: settings.name, + routeName: settings.name!, viewToShow: InfoKkmView(), ); case SettingsViewRoute: return _getPageRoute( - routeName: settings.name, + routeName: settings.name!, viewToShow: SettingView(), ); case QrViewRoute: ImageShowModel data = settings.arguments as ImageShowModel; return _getPageRoute( - routeName: settings.name, + routeName: settings.name!, viewToShow: QrView(data), ); case ImageShowRoute: ImageShowModel data = settings.arguments as ImageShowModel; //return SlideRightRoute(widget: ImageShowContainer(data)); return _getPageRoute( - routeName: settings.name, + routeName: settings.name!, viewToShow: ImageShowContainer(data), ); case SettingsPrinterRoute: return _getPageRoute( - routeName: settings.name, + routeName: settings.name!, viewToShow: SettingPrinterView(), ); case SettingsPrinterBTRoute: return _getPageRoute( - routeName: settings.name, + routeName: settings.name!, viewToShow: PrinterSelectView(), ); case SettingsPrinterEncodingRoute: return _getPageRoute( - routeName: settings.name, + routeName: settings.name!, viewToShow: PrinterEncodingView(), ); case SettingsPrinterPaperRoute: return _getPageRoute( - routeName: settings.name, + routeName: settings.name!, viewToShow: PrinterPaperView(), ); default: @@ -90,7 +90,7 @@ Route generateRoute(RouteSettings settings) { } } -PageRoute _getPageRoute({String routeName, Widget viewToShow}) { +PageRoute _getPageRoute({required String routeName, required Widget viewToShow}) { return MaterialPageRoute( settings: RouteSettings( name: routeName, @@ -100,7 +100,7 @@ PageRoute _getPageRoute({String routeName, Widget viewToShow}) { class SlideRightRoute extends PageRouteBuilder { final Widget widget; - SlideRightRoute({this.widget}) + SlideRightRoute({required this.widget}) : super( pageBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation) { diff --git a/lib/core/services/ApiService.dart b/lib/core/services/ApiService.dart index 2d67aa9..d31fd44 100644 --- a/lib/core/services/ApiService.dart +++ b/lib/core/services/ApiService.dart @@ -39,7 +39,7 @@ class ApiService extends BaseService { }; String response = await requestFormData('/authenticate', requestBody, statusCheck: statusCheck ); AuthResponse aman = AuthResponse.fromJson(json.decode(response)); - return aman.body; + return aman.body!; } Future authenticateToken(String token, { bool statusCheck = true}) async { @@ -48,7 +48,7 @@ class ApiService extends BaseService { }; String response = await requestFormData('/activate_token', requestBody, statusCheck: statusCheck ); AuthResponse aman = AuthResponse.fromJson(json.decode(response)); - return aman.body; + return aman.body!; } Future> isActive(String token) async { @@ -167,7 +167,7 @@ class ApiService extends BaseService { new Future.delayed(const Duration(milliseconds: 1000), (){ _dialogService.showDialog(description: 'Необходимо пройти повторную авторизацию'); - UserState state = Redux.store.state.userState; + UserState state = Redux.store!.state.userState!; _navigatorService.replace(LoginViewRoute, arguments: LoginModel(authType: state.authenticateType, login: state.login, password: state.password )); }); diff --git a/lib/core/services/DataService.dart b/lib/core/services/DataService.dart index 33b2f41..355685e 100644 --- a/lib/core/services/DataService.dart +++ b/lib/core/services/DataService.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'dart:ffi'; import 'package:aman_kassa_flutter/core/base/base_service.dart'; import 'package:aman_kassa_flutter/core/entity/Category.dart'; @@ -25,7 +26,8 @@ class DataService extends BaseService { final ApiService _api = locator(); final DbService _db = locator(); - Future> getCategoriesByParentId({int parentId}) async { + Future> getCategoriesByParentId( + {int? parentId}) async { List> list = await _db.queryRowsWithWhere( Category_tableName, '$Category_columnParentIn = ?', [parentId ?? 0]); return list.map((e) => Category.fromMap(e)).toList(); @@ -36,35 +38,38 @@ class DataService extends BaseService { return list.map((e) => Service.fromMap(e)).toList(); } - Future> getGoodsByCategoryId({int categoryId}) async { + Future> getGoodsByCategoryId({int? categoryId}) async { List> list = await _db.queryRowsWithWhere( Goog_tableName, '$Goog_columnCategoryId = ?', [categoryId ?? 0]); return list.map((e) => Good.fromMap(e)).toList(); } - Future> getGoodsByBarcode ({ String barcode}) async { - List> list = await _db.queryRowsWithWhere(Goog_tableName, ' $Goog_columnEan = ?', [barcode]); + Future> getGoodsByBarcode({required String barcode}) async { + List> list = await _db + .queryRowsWithWhere(Goog_tableName, ' $Goog_columnEan = ?', [barcode]); return list.map((e) => Good.fromMap(e)).toList(); } CheckData _transformProductsToCheckData( - {String paymentType, String tradeType, List items}) { + {String? paymentType, + String? tradeType, + required List items}) { List itemsList = []; int iterator = 1; num summ = 0.0; items.forEach((el) { int articul = iterator; if (el.service != null) { - articul = el.service.articul; + articul = el.service!.articul; } else if (el.good != null) { - articul = el.good.articul; + articul = el.good!.articul; } itemsList.add(CheckItem( - name: el.name ?? 'Позиция №$iterator', - cnt: el.count, - price: el.price, - articul: articul, - excise: el.excise, + name: el.name, + cnt: el.count, + price: el.price, + articul: articul, + excise: el.excise, )); summ += el.total; iterator++; @@ -77,7 +82,9 @@ class DataService extends BaseService { } CheckData _transformCalcModelToCheckData( - {String paymentType, String tradeType, List items}) { + {String? paymentType, + String? tradeType, + required List items}) { List itemsList = []; int iterator = 1; num summ = 0.0; @@ -85,7 +92,7 @@ class DataService extends BaseService { int articul = iterator; CheckItem item = CheckItem( name: 'Позиция $iterator', - cnt: el.num2 != null ? double.parse(el.num2) : 1.0, + cnt: el.num2 != null ? double.parse(el.num2!) : 1.0, price: double.parse(el.num1), articul: articul); @@ -111,13 +118,13 @@ class DataService extends BaseService { * type */ Future insertVoucher( - {@required User user, - String data, - String base64Data, - @required String name, + {required User user, + String? data, + String? base64Data, + required String name, double total = 0.0, String type = VoucherTypePayment, - String url}) { + String? url}) async { assert(user != null); assert(name != null); Voucher voucher = Voucher() @@ -133,21 +140,18 @@ class DataService extends BaseService { log.i( 'save to db appCompanyId: ${user.appCompanyId}, kassaId: ${user.kassaId}'); _db.insert(Voucher_tableName, voucher.toMap()); - return null; } - - - Future> sellOrReturn( - {String paymentType, - String tradeType, - String token, - List kassaItems, - List calcItems, - String operationType, - String mode}) async { + Future?> sellOrReturn( + {String? paymentType, + String? tradeType, + required String token, + required List kassaItems, + required List calcItems, + required String operationType, + required String mode}) async { try { - String data; + String data = ""; if (mode == SettingModeKassa) { CheckData checkData = _transformProductsToCheckData( paymentType: paymentType, tradeType: tradeType, items: kassaItems); @@ -166,18 +170,20 @@ class DataService extends BaseService { // log.i('response status: ${response.status}'); // log.i('response operation: ${response.operation}'); if (response.status == 200 && response.operation == true) { - User user = Redux.store.state.userState.user; + User user = Redux.store!.state.userState!.user!; //check compare - String check = response?.body['check']; - var checkText = response?.body['check_text']; - CheckImageModal imageModal = new CheckImageModal( base64Data: check, textData: checkText !=null ? jsonEncode(checkText) : null ); + String check = response.body['check']; + var checkText = response.body['check_text']; + CheckImageModal imageModal = new CheckImageModal( + base64Data: check, + textData: checkText != null ? jsonEncode(checkText) : null); // journal analyze - dynamic journal = response?.body['journal']; + dynamic journal = response.body['journal']; int checkNum = journal['check_num']; var summ = journal['summ']; // short url - String url = response?.body['link']; + String url = response.body['link']; // total double total = summ != null ? double.parse(summ.toString()) : 0.0; @@ -201,9 +207,9 @@ class DataService extends BaseService { } Future checkDbFill(User user) async { - int serviceCount = await _db.queryRowCount(Service_tableName); + int serviceCount = await _db.queryRowCount(Service_tableName) ?? 0; if (serviceCount == 0) { - int goodCount = await _db.queryRowCount(Goog_tableName); + int goodCount = await _db.queryRowCount(Goog_tableName) ?? 0; if (goodCount == 0) { await getDataFromServer(user); } else { @@ -217,9 +223,10 @@ class DataService extends BaseService { Future getDataFromServer(User user) async { log.i('Get Data from server'); try { - String token = user.token; + String token = user.token!; Response goods = await _api.getGoodsFromServer(token); - if(goods.operation==false && [401,402,403,412].contains(goods.status)){ + if (goods.operation == false && + [401, 402, 403, 412].contains(goods.status)) { log.i('session is closed'); return false; } @@ -230,7 +237,6 @@ class DataService extends BaseService { await _db.deleteAll(Service_tableName); log.i('All tables cleaned'); - if (goods.body.isNotEmpty) { for (var key in goods.body.keys) { Good row = Good.fromJson(goods.body[key]); diff --git a/lib/core/services/DbService.dart b/lib/core/services/DbService.dart index 58ca19e..c1f5221 100644 --- a/lib/core/services/DbService.dart +++ b/lib/core/services/DbService.dart @@ -19,13 +19,13 @@ class DbService extends BaseService { static final DbService instance = DbService._privateConstructor(); // only have a single app-wide reference to the database - static Database _database; + static Database? _database; Future get database async { - if (_database != null) return _database; + if (_database != null) return _database!; // lazily instantiate the db the first time it is accessed _database = await _initDatabase(); - return _database; + return _database!; } // this opens the database (and creates it if it doesn't exist) @@ -136,7 +136,7 @@ class DbService extends BaseService { // All of the methods (insert, query, update, delete) can also be done using // raw SQL commands. This method uses a raw query to give the row count. - Future queryRowCount(String table) async { + Future queryRowCount(String table) async { Database db = await instance.database; return Sqflite.firstIntValue( await db.rawQuery('SELECT COUNT(*) FROM $table')); diff --git a/lib/core/services/authentication_service.dart b/lib/core/services/authentication_service.dart index bf2403b..87176a5 100644 --- a/lib/core/services/authentication_service.dart +++ b/lib/core/services/authentication_service.dart @@ -10,18 +10,18 @@ import 'ApiService.dart'; class AuthenticationService extends BaseService { final ApiService _api; - AuthenticationService({ApiService api}) : _api = api; + AuthenticationService({required ApiService api}) : _api = api; - User _currentUser; - User get currentUser => _currentUser; + User? _currentUser; + User? get currentUser => _currentUser; - Future loginWithEmail({ - @required String email, - @required String password, + Future loginWithEmail({ + required String email, + required String password, }) async { try { - AuthBody result = await _api.authenticate(email, password); - if (result.user != null) { + AuthBody? result = await _api.authenticate(email, password); + if (result!=null && result.user != null) { _currentUser = result.user; } return result; @@ -32,7 +32,7 @@ class AuthenticationService extends BaseService { Future isUserLoggedIn(String token) async { Response session = await _api.isActive(token); - if ("OK" == session.body.message) { + if ("OK" == session.body?.message) { //_session = session; return true; } @@ -40,7 +40,7 @@ class AuthenticationService extends BaseService { } Future logout(String token) async { - Response session = await _api.logout(token); + Response session = await _api.logout(token); if ("logout" == session.body.message) { return true; } diff --git a/lib/core/services/dialog_service.dart b/lib/core/services/dialog_service.dart index aaedcf4..731327e 100644 --- a/lib/core/services/dialog_service.dart +++ b/lib/core/services/dialog_service.dart @@ -5,11 +5,11 @@ import 'package:flutter/cupertino.dart'; class DialogService { GlobalKey _dialogNavigationKey = GlobalKey(); - Function(DialogRequest) _showDialogListener; - Function(DialogRequest) _showDialogInputListener; - Completer _dialogCompleter; + Function(DialogRequest)? _showDialogListener; + Function(DialogRequest)? _showDialogInputListener; + Completer? _dialogCompleter; - Completer get completer => this._dialogCompleter; + Completer? get completer => this._dialogCompleter; GlobalKey get dialogNavigationKey => _dialogNavigationKey; @@ -23,53 +23,53 @@ class DialogService { /// Calls the dialog listener and returns a Future that will wait for dialogComplete. Future showDialog({ String title = 'Aman Касса', - String description, + required String description, String buttonTitle = 'Ok', }) { _dialogCompleter = Completer(); - _showDialogListener(DialogRequest( + _showDialogListener!(DialogRequest( title: title, description: description, buttonTitle: buttonTitle, )); - return _dialogCompleter.future; + return _dialogCompleter!.future; } /// Shows a confirmation dialog Future showConfirmationDialog( - {String title, - String description, + {required String title, + required String description, String confirmationTitle = 'Ok', String cancelTitle = 'Cancel'}) { _dialogCompleter = Completer(); - _showDialogListener(DialogRequest( + _showDialogListener!(DialogRequest( title: title, description: description, buttonTitle: confirmationTitle, cancelTitle: cancelTitle)); - return _dialogCompleter.future; + return _dialogCompleter!.future; } Future showConfirmationDialogInput( {String title = ' Aman Касса', - String description, + required String description, String confirmationTitle = 'Ok', String cancelTitle = 'Cancel', - String formatType}) { + String? formatType}) { _dialogCompleter = Completer(); - _showDialogInputListener(DialogRequest( + _showDialogInputListener!(DialogRequest( title: title, description: description, buttonTitle: confirmationTitle, cancelTitle: cancelTitle, formatType: formatType)); - return _dialogCompleter.future; + return _dialogCompleter!.future; } /// Completes the _dialogCompleter to resume the Future's execution call void dialogComplete(DialogResponse response) { - _dialogNavigationKey.currentState.pop(); - _dialogCompleter.complete(response); + _dialogNavigationKey.currentState!.pop(); + _dialogCompleter!.complete(response); _dialogCompleter = null; } } diff --git a/lib/core/services/navigator_service.dart b/lib/core/services/navigator_service.dart index 9be0ff2..784545b 100644 --- a/lib/core/services/navigator_service.dart +++ b/lib/core/services/navigator_service.dart @@ -6,27 +6,27 @@ class NavigatorService extends BaseService { Future push(String routeName, {dynamic arguments}) { log.i('routeName: $routeName'); - return navigatorKey.currentState + return navigatorKey.currentState! .pushNamed(routeName, arguments: arguments); } Future replace(String routeName, {dynamic arguments}) { log.i('routeName: $routeName'); - return navigatorKey.currentState + return navigatorKey.currentState! .pushNamedAndRemoveUntil(routeName, (Route route) => false, arguments: arguments); } - Future navigateToPage(MaterialPageRoute pageRoute) async { + Future navigateToPage(MaterialPageRoute pageRoute) async { log.i('navigateToPage: pageRoute: ${pageRoute.settings.name}'); if (navigatorKey.currentState == null) { log.e('navigateToPage: Navigator State is null'); return null; } - return navigatorKey.currentState.push(pageRoute); + return navigatorKey.currentState!.push(pageRoute); } - Future navigateToPageWithReplacement( + Future navigateToPageWithReplacement( MaterialPageRoute pageRoute) async { log.i('navigateToPageWithReplacement: ' 'pageRoute: ${pageRoute.settings.name}'); @@ -34,15 +34,15 @@ class NavigatorService extends BaseService { log.e('navigateToPageWithReplacement: Navigator State is null'); return null; } - return navigatorKey.currentState.pushReplacement(pageRoute); + return navigatorKey.currentState!.pushReplacement(pageRoute); } - void pop([T result]) { + void pop([T? result]) { log.i('goBack:'); if (navigatorKey.currentState == null) { log.e('goBack: Navigator State is null'); return; } - navigatorKey.currentState.pop(result); + navigatorKey.currentState!.pop(result); } } \ No newline at end of file diff --git a/lib/core/utilsParse.dart b/lib/core/utilsParse.dart index a5d21ea..c5ec54d 100644 --- a/lib/core/utilsParse.dart +++ b/lib/core/utilsParse.dart @@ -1,4 +1,4 @@ -List parseListString(json){ +List? parseListString(json){ if(json==null) return null; return new List.from(json); } \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 498394b..392fa16 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -7,7 +7,9 @@ import 'dart:io'; import 'package:aman_kassa_flutter/shared/app_colors.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:google_fonts/google_fonts.dart'; + //service & tools import 'package:aman_kassa_flutter/redux/store.dart'; import 'core/locator.dart'; @@ -15,10 +17,10 @@ import 'core/router.dart'; import 'core/services/navigator_service.dart'; import 'core/services/dialog_service.dart'; import './widgets/dialog_manager.dart'; + //pages import 'views/start_up/start_up_view.dart'; - //main start void main() async { WidgetsFlutterBinding.ensureInitialized(); @@ -35,41 +37,46 @@ void main() async { runApp(MainApplication()); } -class MyHttpOverrides extends HttpOverrides{ +class MyHttpOverrides extends HttpOverrides { @override - HttpClient createHttpClient(SecurityContext context){ + HttpClient createHttpClient(SecurityContext? context) { return super.createHttpClient(context) - ..badCertificateCallback = (X509Certificate cert, String host, int port)=> true; + ..badCertificateCallback = + (X509Certificate cert, String host, int port) => true; } } - class MainApplication extends StatelessWidget { - @override Widget build(BuildContext context) { return StoreProvider( - store: Redux.store, - child: MaterialApp( - theme: ThemeData( - backgroundColor: backgroundColor, - primaryColor: primaryColor, - accentColor: yellowColor, - scaffoldBackgroundColor: Colors.white, + store: Redux.store!, + child: ScreenUtilInit( + designSize: const Size( + 411.43, + 683.43, + ), + builder: () => MaterialApp( + theme: ThemeData( + backgroundColor: backgroundColor, + primaryColor: primaryColor, + accentColor: yellowColor, + scaffoldBackgroundColor: Colors.white, // textTheme: GoogleFonts.latoTextTheme( // Theme.of(context).textTheme, // ) + ), + debugShowCheckedModeBanner: false, + builder: (context, child) => Navigator( + key: locator().dialogNavigationKey, + onGenerateRoute: (settings) => MaterialPageRoute( + builder: (context) => DialogManager(child: child)), + ), + navigatorKey: locator().navigatorKey, + home: StartUpView(), + // first page + onGenerateRoute: generateRoute, ), - debugShowCheckedModeBanner: false, - builder: (context, child) => Navigator( - key: locator().dialogNavigationKey, - onGenerateRoute: (settings) => MaterialPageRoute( - builder: (context) => DialogManager(child: child)), - ), - navigatorKey: locator().navigatorKey, - home: StartUpView(), // first page - onGenerateRoute: generateRoute, - ), - ); + )); } -} \ No newline at end of file +} diff --git a/lib/redux/actions/calc_actions.dart b/lib/redux/actions/calc_actions.dart index 8832046..c2347e8 100644 --- a/lib/redux/actions/calc_actions.dart +++ b/lib/redux/actions/calc_actions.dart @@ -1,3 +1,4 @@ +import 'package:aman_kassa_flutter/core/models/calc_model.dart'; import 'package:aman_kassa_flutter/redux/state/calc_state.dart'; import 'package:aman_kassa_flutter/widgets/components/calculator/calculator.dart'; import 'package:meta/meta.dart'; @@ -26,7 +27,7 @@ ThunkAction onTapAction(String value) { if(value == Calculations.EQUAL){ return setEqual(store); } - List calcItems = Calculator.action(value: value, items: store.state.calcState.calcItems); + List calcItems = Calculator.action(value: value, items: store.state.calcState!.calcItems!); store.dispatch(SetCalcStateAction(CalcState(calcItems: calcItems, isEqual: false))); }; } \ No newline at end of file diff --git a/lib/redux/actions/kassa_actions.dart b/lib/redux/actions/kassa_actions.dart index 3c7be85..dcbdc43 100644 --- a/lib/redux/actions/kassa_actions.dart +++ b/lib/redux/actions/kassa_actions.dart @@ -24,8 +24,8 @@ final DataService _dataService = locator(); final DialogService _dialogService = locator(); Future backBottomElement(Store store) async { - List prevCategories = store.state.kassaState.prevCategories; - DictDao last = prevCategories.removeLast(); + List? prevCategories = store.state.kassaState!.prevCategories; + DictDao? last = prevCategories?.removeLast() ; if (last != null) { store.dispatch(SetKassaStateAction(KassaState(prevCategories: prevCategories))); store.dispatch(selectBottomElement(last.id)); @@ -38,16 +38,16 @@ Future cleanKassaItems(Store store) async { ThunkAction addCustomProductToKassaItems(String name, int count, double price, double total) { return (Store store) async { - List items = store.state.kassaState.kassaItems; + List items = store.state.kassaState!.kassaItems!; items.add(new ProductDao(name: name, count: count, price: price, total: total)); store.dispatch(SetKassaStateAction(KassaState(kassaItems: items))); }; } -ThunkAction addProductToKassaItems(Good good, String excise) { +ThunkAction addProductToKassaItems(Good good, String? excise) { return (Store store) async { - List items = store.state.kassaState.kassaItems; + List items = store.state.kassaState!.kassaItems!; int index = items.indexWhere((element) => element.excise == null && element.good?.id == good.id); if(excise !=null) { int existIndex = items.indexWhere((element) => element.excise != null && element.excise == excise); @@ -68,7 +68,7 @@ ThunkAction addProductToKassaItems(Good good, String excise) { ThunkAction addServiceToKassaItems(Service service) { return (Store store) async { - List items = store.state.kassaState.kassaItems; + List items = store.state.kassaState!.kassaItems!; int index = items.indexWhere((element) => element.good?.id == service.id); if (index > -1) { store.dispatch(counterProductFromKassaItems(index, 1)); @@ -82,7 +82,7 @@ ThunkAction addServiceToKassaItems(Service service) { ThunkAction removeProductFromKassaItems(int index) { return (Store store) async { - List items = List.from(store.state.kassaState.kassaItems); + List items = List.from(store.state.kassaState!.kassaItems!); items.removeAt(index); store.dispatch(SetKassaStateAction(KassaState(kassaItems: items))); }; @@ -90,7 +90,7 @@ ThunkAction removeProductFromKassaItems(int index) { ThunkAction counterProductFromKassaItems(int index, int counter) { return (Store store) async { - List items = store.state.kassaState.kassaItems; + List items = store.state.kassaState!.kassaItems!; ProductDao product = items.elementAt(index); if (product.count == 1 && counter < 0) { //if count to zero need delete element @@ -107,24 +107,24 @@ ThunkAction selectBottomElement(int parentId) { return (Store store) async { store.dispatch(SetKassaStateAction(KassaState(bottomSheetLoading: true, bottomSheetElements: []))); try { - List prevCategories = store.state.kassaState.prevCategories; + List prevCategories = store.state.kassaState!.prevCategories!; if (parentId == 0) { prevCategories = []; } - store.state.kassaState.bottomSheetElements.forEach((element) { + store.state.kassaState!.bottomSheetElements!.forEach((element) { if (element is Category && element.id == parentId) { - prevCategories.add(DictDao(id: element.parentIn, name: element.name)); + prevCategories.add(DictDao(id: element.parentIn!, name: element.name)); } }); List _bottomSheetElements = []; - if(store.state.settingState.tradeType == SettingTradeTypeGood) { + if(store.state.settingState!.tradeType == SettingTradeTypeGood) { List categories = await _dataService.getCategoriesByParentId(parentId: parentId); _bottomSheetElements.addAll(categories); List goods = await _dataService.getGoodsByCategoryId(categoryId: parentId); _bottomSheetElements.addAll(goods); - } else if(store.state.settingState.tradeType == SettingTradeTypeService) { + } else if(store.state.settingState!.tradeType == SettingTradeTypeService) { List services = await _dataService.getServices(); _bottomSheetElements.addAll(services); } diff --git a/lib/redux/actions/user_actions.dart b/lib/redux/actions/user_actions.dart index 72194e3..cf7737f 100644 --- a/lib/redux/actions/user_actions.dart +++ b/lib/redux/actions/user_actions.dart @@ -30,17 +30,17 @@ final DialogService _dialogService = locator(); Future checkUserAction(Store store) async { store.dispatch(SetUserStateAction(UserState(isLoading: true))); try { - User user = store.state.userState.user; - String token = user?.token; + User? user = store.state.userState?.user; + String? token = user?.token; bool isAuthenticated = false; - if (token != null) { - if(user.email!=null && user.email.toLowerCase().trim().startsWith('test')){ + if (token != null && user !=null) { + if(user.email!=null && user.email!.toLowerCase().trim().startsWith('test')){ _api.test = true; } else { _api.test = false; } Response session = await _api.isActive(token); - isAuthenticated = "OK" == session.body.message; + isAuthenticated = "OK" == session.body?.message; } else { await Future.delayed(Duration(milliseconds: 2000)); @@ -82,11 +82,11 @@ Future logoutAction(Store store) async { } } -Future> checkMoney(Store store) async { +Future?> checkMoney(Store store) async { store.dispatch(SetUserStateAction(UserState(money: Money(loading: true)))); try { Response result = - await _api.money(store.state.userState.user.token); + await _api.money(store.state.userState!.user!.token!); if (result.operation) { store.dispatch(SetUserStateAction(UserState( money: Money( @@ -165,20 +165,20 @@ ThunkAction authenticate(String email, String password) { } Future checkSmena(Store store) async { - String token = store.state.userState.user.token; + String token = store.state.userState!.user!.token!; Response result = await _api.smena(token); store.dispatch(SetUserStateAction(UserState(smena: result.body))); } Future closeSmena(Store store) async { - String token = store.state.userState.user.token; + String token = store.state.userState!.user!.token!; Response result = await _api.closeSmena(token); store.dispatch(SetUserStateAction(UserState(smena: result.body))); store.dispatch(checkMoney); } Future openSmena(Store store) async { - String token = store.state.userState.user.token; + String token = store.state.userState!.user!.token!; Response result = await _api.openSmena(token); store.dispatch(SetUserStateAction(UserState(smena: result.body))); if (result.operation) { diff --git a/lib/redux/state/calc_state.dart b/lib/redux/state/calc_state.dart index dd1f87c..cf9aace 100644 --- a/lib/redux/state/calc_state.dart +++ b/lib/redux/state/calc_state.dart @@ -3,8 +3,8 @@ import 'package:meta/meta.dart'; @immutable class CalcState { - final List calcItems; - final bool isEqual; + final List? calcItems; + final bool? isEqual; CalcState({this.calcItems, this.isEqual}); diff --git a/lib/redux/state/kassa_state.dart b/lib/redux/state/kassa_state.dart index e8d6bd0..f894b20 100644 --- a/lib/redux/state/kassa_state.dart +++ b/lib/redux/state/kassa_state.dart @@ -4,10 +4,10 @@ import 'package:meta/meta.dart'; @immutable class KassaState { - final List bottomSheetElements; - final bool bottomSheetLoading; - final List prevCategories; - final List kassaItems; + final List? bottomSheetElements; + final bool? bottomSheetLoading; + final List? prevCategories; + final List? kassaItems; KassaState( diff --git a/lib/redux/state/setting_state.dart b/lib/redux/state/setting_state.dart index 91a9edb..07ee938 100644 --- a/lib/redux/state/setting_state.dart +++ b/lib/redux/state/setting_state.dart @@ -4,14 +4,14 @@ import 'package:flutter_bluetooth_basic/src/bluetooth_device.dart'; @immutable class SettingState { - final String mode; - final String tradeType; - final String pinCode; - final bool pinLocked; - final bool pinSkip; - final BluetoothDevice printerBT; - final String printerEncoding; - final String printerPaperSize; + final String? mode; + final String? tradeType; + final String? pinCode; + final bool? pinLocked; + final bool? pinSkip; + final BluetoothDevice? printerBT; + final String? printerEncoding; + final String? printerPaperSize; SettingState({this.mode, this.tradeType, this.pinCode, this.pinLocked, this.pinSkip, this.printerBT, @@ -19,7 +19,7 @@ class SettingState { this.printerPaperSize}); //read hive - factory SettingState.initial(SettingState payload) { + factory SettingState.initial(SettingState? payload) { return SettingState( mode: payload?.mode ?? SettingModeKassa, tradeType: payload?.tradeType ?? SettingTradeTypeGood, @@ -56,7 +56,7 @@ class SettingState { ); } - static SettingState fromJson(dynamic json) { + static SettingState? fromJson(dynamic json) { return json != null ? SettingState( tradeType: json['tradeType'], @@ -80,7 +80,7 @@ class SettingState { "pinCode": pinCode, "pinLocked" : pinLocked, "pinSkip" : pinSkip, - "printerBT": printerBT != null ? printerBT.toJson() : null, + "printerBT": printerBT != null ? printerBT!.toJson() : null, "printerEncoding": printerEncoding, "printerPaperSize": printerPaperSize, }; diff --git a/lib/redux/state/user_state.dart b/lib/redux/state/user_state.dart index 6dbf02e..6c21377 100644 --- a/lib/redux/state/user_state.dart +++ b/lib/redux/state/user_state.dart @@ -5,16 +5,16 @@ import 'package:meta/meta.dart'; @immutable class UserState { - final bool isError; - final bool isLoading; - final bool isAuthenticated; - final String authenticateType; - final String login; - final String password; - final LoginFormMessage loginFormMessage; - final User user; - final Smena smena; - final Money money; + final bool? isError; + final bool? isLoading; + final bool? isAuthenticated; + final String? authenticateType; + final String? login; + final String? password; + final LoginFormMessage? loginFormMessage; + final User? user; + final Smena? smena; + final Money? money; UserState( @@ -30,7 +30,7 @@ class UserState { this.money, }); - factory UserState.initial(UserState payload) => UserState( + factory UserState.initial(UserState? payload) => UserState( isLoading: false, isError: false, isAuthenticated: false, @@ -44,16 +44,16 @@ class UserState { ); UserState copyWith({ - @required bool isError, - @required bool isLoading, - @required User user, - @required bool isAuthenticated, - @required LoginFormMessage loginFormMessage, - @required Smena smena, - @required String authenticateType, - @required String login, - @required String password, - @required Money money, + @required bool? isError, + @required bool? isLoading, + @required User? user, + @required bool? isAuthenticated, + @required LoginFormMessage? loginFormMessage, + @required Smena? smena, + @required String? authenticateType, + @required String? login, + @required String? password, + @required Money? money, }) { return UserState( isError: isError ?? this.isError, @@ -69,7 +69,7 @@ class UserState { ); } - static UserState fromJson(dynamic json) { + static UserState? fromJson(dynamic json) { return json != null ? UserState( user: User.fromJson(json['user']), @@ -82,7 +82,7 @@ class UserState { dynamic toJson() { return { - "user": user != null ? user.toJson() : null, + "user": user != null ? user!.toJson() : null, "authenticateType": authenticateType, "login": login, "password": password, @@ -91,9 +91,9 @@ class UserState { } class LoginFormMessage { - final String email; - final String password; - final String message; + final String? email; + final String? password; + final String? message; LoginFormMessage({this.email, this.password, this.message}); } diff --git a/lib/redux/store.dart b/lib/redux/store.dart index 8519399..208f0cc 100644 --- a/lib/redux/store.dart +++ b/lib/redux/store.dart @@ -21,19 +21,19 @@ import 'actions/calc_actions.dart'; AppState appReducer(AppState state, dynamic action) { if (action is SetUserStateAction) { /** UserAction **/ - final nextUserState = userReducer(state.userState, action); + final nextUserState = userReducer(state.userState!, action); return state.copyWith(userState: nextUserState); } else if (action is SetKassaStateAction) { /** KassaAction **/ - final nextMainState = mainReducer(state.kassaState, action); + final nextMainState = mainReducer(state.kassaState!, action); return state.copyWith(kassaState: nextMainState); } else if (action is SetSettingStateAction) { /** SettingAction **/ - final nextSettingState = settingReducer(state.settingState, action); + final nextSettingState = settingReducer(state.settingState!, action); return state.copyWith(settingState: nextSettingState); } else if (action is SetCalcStateAction) { /** CalcAction **/ - final nextCalcState = calcReducer(state.calcState, action); + final nextCalcState = calcReducer(state.calcState!, action); return state.copyWith(calcState: nextCalcState); } return state; @@ -42,10 +42,10 @@ AppState appReducer(AppState state, dynamic action) { //Main State @immutable class AppState { - final UserState userState; - final KassaState kassaState; - final SettingState settingState; - final CalcState calcState; + final UserState? userState; + final KassaState? kassaState; + final SettingState? settingState; + final CalcState? calcState; AppState({ this.userState, @@ -56,10 +56,10 @@ class AppState { //stable work AppState copyWith({ - UserState userState, - KassaState kassaState, - SettingState settingState, - CalcState calcState, + UserState? userState, + KassaState? kassaState, + SettingState? settingState, + CalcState? calcState, }) { return AppState( userState: userState ?? this.userState, @@ -69,7 +69,7 @@ class AppState { ); } - static AppState fromJson(dynamic json){ + static AppState? fromJson(dynamic json){ return json !=null ? AppState( settingState: SettingState.fromJson(json['settingState']), @@ -80,16 +80,16 @@ class AppState { dynamic toJson() { return { - "settingState": settingState.toJson(), - "userState" : userState.toJson(), + "settingState": settingState?.toJson(), + "userState" : userState?.toJson(), }; } } class Redux { - static Store _store; + static Store? _store; - static Store get store { + static Store? get store { if (_store == null) { throw Exception("store is not initialized"); } else { diff --git a/lib/views/check/image_show_container.dart b/lib/views/check/image_show_container.dart index d98efa6..fac7e56 100644 --- a/lib/views/check/image_show_container.dart +++ b/lib/views/check/image_show_container.dart @@ -19,7 +19,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bluetooth_basic/flutter_bluetooth_basic.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; -import 'package:esys_flutter_share/esys_flutter_share.dart'; +import 'package:vocsy_esys_flutter_share/vocsy_esys_flutter_share.dart'; import 'package:url_launcher/url_launcher.dart'; class ImageShowContainer extends StatefulWidget { @@ -34,14 +34,15 @@ class ImageShowContainer extends StatefulWidget { class _ImageShowContainerState extends State { final PrinterBluetoothManager printerManager = PrinterBluetoothManager(); final DialogService _dialogService = locator(); - final BluetoothDevice printerBtDevice = Redux.store.state.settingState.printerBT; + final BluetoothDevice? printerBtDevice = + Redux.store!.state.settingState!.printerBT; final BluetoothManager bluetoothManager = BluetoothManager.instance; bool _printing = false; void _preparePrint() async { if (Platform.isIOS) { - await _print(); + _print(); } else { bluetoothManager.state.listen((val) { print("state = $val"); @@ -49,11 +50,11 @@ class _ImageShowContainerState extends State { if (val == 12) { print('on'); _print(); - } else if (val == 10) { print('off'); _dialogService.showDialog( - description: 'Отсутвует соеденение Bluetooth или он отключен' , title: 'Bluetooth'); + description: 'Отсутвует соеденение Bluetooth или он отключен', + title: 'Bluetooth'); } print('state is $val'); }); @@ -61,9 +62,10 @@ class _ImageShowContainerState extends State { } void _print() async { - final SettingState state = Redux.store.state.settingState; - if(state.printerBT == null) { - _dialogService.showDialog(description: 'Укажите в настройках принтер для печати чеков'); + final SettingState state = Redux.store!.state.settingState!; + if (state.printerBT == null) { + _dialogService.showDialog( + description: 'Укажите в настройках принтер для печати чеков'); return; } @@ -71,7 +73,7 @@ class _ImageShowContainerState extends State { int chunkSizeBytes = 3096; int queueSleepTimeMs = 100; - if(isIos){ + if (isIos) { chunkSizeBytes = 75; queueSleepTimeMs = 10; } @@ -80,13 +82,13 @@ class _ImageShowContainerState extends State { _printing = true; }); try { - printerManager.selectPrinter(PrinterBluetooth(state.printerBT)); + printerManager.selectPrinter(PrinterBluetooth(state.printerBT!)); PaperSize paper = state.printerPaperSize == SettingPrinterPaperM80 ? PaperSize.mm80 : PaperSize.mm58; if (SettingPrinterEncodingImage == state.printerEncoding) { final PosPrintResult res = await printerManager.printTicket( - await printImageCheck(paper, widget.showModel.data.base64Data), + await printImageCheck(paper, widget.showModel.data!.base64Data!), chunkSizeBytes: chunkSizeBytes, queueSleepTimeMs: queueSleepTimeMs); if (res.value != 1) { @@ -94,9 +96,8 @@ class _ImageShowContainerState extends State { } } else { final PosPrintResult res = await printerManager.printTicket( - await printTextCheck( - paper, state.printerEncoding, - jsonDecode(widget.showModel.data.textData)), + await printTextCheck(paper, state.printerEncoding!, + jsonDecode(widget.showModel.data!.textData!)), chunkSizeBytes: chunkSizeBytes, queueSleepTimeMs: queueSleepTimeMs); if (res.value != 1) { @@ -119,7 +120,7 @@ class _ImageShowContainerState extends State { //backgroundColor: fillColor, title: Text(widget.showModel.title), actions: [ - if(_printing) + if (_printing) Padding( padding: const EdgeInsets.only(right: 8.0), child: SizedBox( @@ -127,8 +128,7 @@ class _ImageShowContainerState extends State { child: Center( child: CircularProgressIndicator( strokeWidth: 2, - valueColor: new AlwaysStoppedAnimation( - whiteColor), + valueColor: new AlwaysStoppedAnimation(whiteColor), ), ), ), @@ -138,7 +138,9 @@ class _ImageShowContainerState extends State { ], ), body: ListView( - children: [imageFromBase64String(widget.showModel.data.base64Data)], + children: [ + imageFromBase64String(widget.showModel.data!.base64Data!) + ], ), floatingActionButton: MyFloatingActionButton(widget.showModel), ); @@ -153,16 +155,18 @@ Padding imageFromBase64String(String base64String) { } class ImageShowModel { - final CheckImageModal data; + final CheckImageModal? data; final String title; - final String url; + final String? url; - ImageShowModel({this.data, this.title, this.url}); + ImageShowModel({this.data, required this.title, this.url}); } class MyFloatingActionButton extends StatefulWidget { final ImageShowModel data; + MyFloatingActionButton(this.data); + @override _MyFloatingActionButtonState createState() => _MyFloatingActionButtonState(); } @@ -172,13 +176,10 @@ class _MyFloatingActionButtonState extends State { DialogService _dialog = locator(); NavigatorService _navigatorService = locator(); - double sheetHeight = 260; @override Widget build(BuildContext context) { - - return showFab ? FloatingActionButton( child: Icon(Icons.share), @@ -193,7 +194,7 @@ class _MyFloatingActionButtonState extends State { boxShadow: [ BoxShadow( blurRadius: 10, - color: Colors.grey[300], + color: Colors.grey[300]!, spreadRadius: 5) ]), height: sheetHeight, @@ -236,7 +237,7 @@ class _MyFloatingActionButtonState extends State { void shareFile() async { try { await Share.file('Aman Kassa', 'aman_kassa_check.png', - base64Decode(widget.data.data.base64Data), 'image/png'); + base64Decode(widget.data.data!.base64Data!), 'image/png'); } catch (e) { print('error: $e'); } @@ -255,15 +256,15 @@ class _MyFloatingActionButtonState extends State { confirmationTitle: 'Отправить', formatType: 'phone'); if (response.confirmed) { - String phoneNumber = response.responseText; + String phoneNumber = response.responseText!; String msg = "Спасибо за покупку! \r\n ${widget.data.url} "; launchWhatsApp(phone: phoneNumber, message: msg); } } void launchWhatsApp({ - @required String phone, - @required String message, + required String phone, + required String message, }) async { String url() { if (Platform.isIOS) { diff --git a/lib/views/history/history_view.dart b/lib/views/history/history_view.dart index 1e85ac8..1efd547 100644 --- a/lib/views/history/history_view.dart +++ b/lib/views/history/history_view.dart @@ -65,7 +65,7 @@ class _HistoryViewState extends State { }, itemBuilder: (BuildContext context, int index) { Voucher voucher = data[index]; - String base64Data = voucher.base64Data; + String? base64Data = voucher.base64Data; CheckImageModal checkImageData; if(base64Data !=null && base64Data.startsWith('{')){ checkImageData = CheckImageModal.fromJson(jsonDecode(base64Data)); @@ -77,11 +77,11 @@ class _HistoryViewState extends State { _navigatorService.push(ImageShowRoute, arguments: ImageShowModel( data: checkImageData, - title: voucher.name, - url: voucher.url)); + title: voucher.name!, + url: voucher.url!)); }, title: buildText(voucher), - subtitle: Text(dateFormat.format(voucher.dateTime)), + subtitle: Text(dateFormat.format(voucher.dateTime!)), trailing: Icon(Icons.arrow_right), leading: voucher.type == VoucherTypePayment ? Icon( @@ -106,7 +106,7 @@ class _HistoryViewState extends State { Text buildText(Voucher voucher) { if (voucher.type == VoucherTypePayment || voucher.type == VoucherTypeReturnPay) { return Text( - '${voucher.name} на сумму: ${voucher.total.toStringAsFixed(2)}'); + '${voucher.name} на сумму: ${voucher.total?.toStringAsFixed(2)}'); } return Text('${voucher.name}'); } diff --git a/lib/views/home/components/bottom_bar.dart b/lib/views/home/components/bottom_bar.dart index 8401901..b5732ea 100644 --- a/lib/views/home/components/bottom_bar.dart +++ b/lib/views/home/components/bottom_bar.dart @@ -11,17 +11,18 @@ class BottomBar extends StatelessWidget { final int selectedTabIndex; BottomBar({ - this.pageController, - this.selectedTabIndex, + required this.pageController, + required this.selectedTabIndex, }); @override Widget build(BuildContext context) { return StoreConnector( - converter: (store) => store.state.settingState, + converter: (store) => store.state.settingState!, builder: (context, vm) { return BottomNavigationBar( currentIndex: selectedTabIndex, + showUnselectedLabels: true, backgroundColor: menuColor, type: BottomNavigationBarType.shifting, items: [ diff --git a/lib/views/home/components/header_title.dart b/lib/views/home/components/header_title.dart index 7e92489..e5116fb 100644 --- a/lib/views/home/components/header_title.dart +++ b/lib/views/home/components/header_title.dart @@ -11,7 +11,7 @@ class HeaderTitle extends StatelessWidget { @override Widget build(BuildContext context) { return StoreConnector( - converter: (store) => store.state.userState, + converter: (store) => store.state.userState!, builder: (context, vm) { return Row( mainAxisAlignment: MainAxisAlignment.start, @@ -30,7 +30,7 @@ class HeaderTitle extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - 'Пользователь: ${vm.user.email}', + 'Пользователь: ${vm.user?.email}', overflow: TextOverflow.fade, maxLines: 1, softWrap: false, @@ -39,10 +39,10 @@ class HeaderTitle extends StatelessWidget { color: Colors.black, ), ), - vm.smena.message != null - ? Text(vm.smena.message, + vm.smena?.message != null + ? Text(vm.smena!.message!, style: TextStyle(fontSize: 13, color: redColor)) - : vm.smena.startedAt != null + : vm.smena!.startedAt != null ? Text( 'Смена открыта', overflow: TextOverflow.fade, diff --git a/lib/views/home/components/popup_menu.dart b/lib/views/home/components/popup_menu.dart index 4f64903..f3e095a 100644 --- a/lib/views/home/components/popup_menu.dart +++ b/lib/views/home/components/popup_menu.dart @@ -15,7 +15,7 @@ const List choices = const [ class PopupMenu extends StatelessWidget { final void Function(Choice value) onSelectChoice; - PopupMenu({this.onSelectChoice}); + PopupMenu({required this.onSelectChoice}); @override Widget build(BuildContext context) { diff --git a/lib/views/home/home_view.dart b/lib/views/home/home_view.dart index 6a625f3..3d2b584 100644 --- a/lib/views/home/home_view.dart +++ b/lib/views/home/home_view.dart @@ -34,8 +34,8 @@ class HomeView extends StatefulWidget { class _HomeViewState extends State with WidgetsBindingObserver { Logger log = getLogger('HomeView'); - PageController pageController; - int selectedTabIndex; + late PageController pageController; + late int selectedTabIndex; DataService _dataService = locator(); ApiService _api = locator(); NavigatorService _navigatorService = locator(); @@ -55,8 +55,8 @@ class _HomeViewState extends State with WidgetsBindingObserver { final prevState = sp.getInt(lastKnownStateKey); final prevStateIsNotPaused = prevState != null && AppLifecycleState.values[prevState] != AppLifecycleState.paused; - final bool pinIsExist = Redux.store.state.settingState?.pinCode?.isNotEmpty; - final bool pinSkipped = Redux.store.state.settingState.pinSkip; + final bool pinIsExist = Redux.store!.state.settingState?.pinCode != null; + final bool pinSkipped = Redux.store!.state.settingState?.pinSkip == true; print('prevStateIsNotPaused=$prevStateIsNotPaused, pinIsExist=$pinIsExist, pinSkipped=$pinSkipped'); if(prevStateIsNotPaused && pinSkipped == false && pinIsExist == true) { // save App backgrounded time to Shared preferences @@ -72,7 +72,7 @@ class _HomeViewState extends State with WidgetsBindingObserver { final allowedBackgroundTime = bgTime + pinLockMillis; final shouldShowPIN = DateTime.now().millisecondsSinceEpoch > allowedBackgroundTime; if(shouldShowPIN && bgTime > 0) { - await Redux.store.dispatch(changePinLockedFromSetting(true)); + await Redux.store!.dispatch(changePinLockedFromSetting(true)); pushToLockScreen(); } sp.remove(backgroundedTimeKey); // clean @@ -86,14 +86,14 @@ class _HomeViewState extends State with WidgetsBindingObserver { onWillPop: () async { return false; }, - child: PassCodeScreen( title: '',) + child: PassCodeScreen( title: 'Безопасность',) ) )); } _checkLockPin () async { - final bool pinIsExist = Redux.store.state.settingState?.pinCode?.isNotEmpty; - final bool pinLocked = Redux.store.state.settingState?.pinLocked; + final bool pinIsExist = Redux.store!.state.settingState?.pinCode != null; + final bool pinLocked = Redux.store!.state.settingState?.pinLocked == true; final sp = await SharedPreferences.getInstance(); sp.remove(backgroundedTimeKey); sp.setInt(lastKnownStateKey, AppLifecycleState.resumed.index);// previous state @@ -106,11 +106,11 @@ class _HomeViewState extends State with WidgetsBindingObserver { @override void initState() { super.initState(); - WidgetsBinding.instance.addObserver(this); + WidgetsBinding.instance!.addObserver(this); selectedTabIndex = 0; pageController = new PageController(initialPage: selectedTabIndex); - Redux.store.dispatch(checkSmena); - _dataService.checkDbFill(Redux.store.state.userState.user); + Redux.store!.dispatch(checkSmena); + _dataService.checkDbFill(Redux.store!.state.userState!.user!); _checkLockPin(); } @@ -135,7 +135,7 @@ class _HomeViewState extends State with WidgetsBindingObserver { @override void dispose() { - WidgetsBinding.instance.removeObserver(this); + WidgetsBinding.instance!.removeObserver(this); pageController.dispose(); super.dispose(); } @@ -143,11 +143,11 @@ class _HomeViewState extends State with WidgetsBindingObserver { void _onSelectChoice(Choice choice) async { if (choice.command == 'exit') { Dialogs.showLoadingDialog(context, _keyLoader); - Response result = await _api.logout(Redux.store.state.userState.user.token); + Response result = await _api.logout(Redux.store!.state.userState!.user!.token!); if(result.operation && result.status == 200) { - Redux.store.dispatch(logoutAction); + Redux.store!.dispatch(logoutAction); } - Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop(); + Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop(); } else if (choice.command == 'infokkm') { _navigatorService.push(InfoKkmViewRoute); } else if (choice.command == 'settings') { @@ -172,7 +172,7 @@ class _HomeViewState extends State with WidgetsBindingObserver { backgroundColor: fillColor, ), body:StoreConnector( - converter: (store) => store.state.settingState, + converter: (store) => store.state.settingState!, builder: (context, vm) { return PageView( pageSnapping: true, diff --git a/lib/views/home/tabs/AdditionalTab.dart b/lib/views/home/tabs/AdditionalTab.dart index 85a0a08..1dd7b50 100644 --- a/lib/views/home/tabs/AdditionalTab.dart +++ b/lib/views/home/tabs/AdditionalTab.dart @@ -44,13 +44,13 @@ class _AdditionalTabState extends State { DataService _dataService = locator(); final GlobalKey _keyLoader = new GlobalKey(); - bool isMoneyCheckBusy; - bool closeSmenaBusy; - bool openSmenaBusy; - bool depositBusy; - bool withdrawalBusy; - bool xReportBusy; - bool updateCatalog; + late bool isMoneyCheckBusy; + late bool closeSmenaBusy; + late bool openSmenaBusy; + late bool depositBusy; + late bool withdrawalBusy; + late bool xReportBusy; + late bool updateCatalog; @override void initState() { @@ -69,7 +69,7 @@ class _AdditionalTabState extends State { closeSmenaBusy = true; }); try { - await Redux.store.dispatch(closeSmena); + await Redux.store!.dispatch(closeSmena); } catch (e) { print(e); } finally { @@ -84,7 +84,7 @@ class _AdditionalTabState extends State { openSmenaBusy = true; }); try { - await Redux.store.dispatch(openSmena); + await Redux.store!.dispatch(openSmena); } catch (e) { print(e); } finally { @@ -99,15 +99,15 @@ class _AdditionalTabState extends State { xReportBusy = true; }); try { - User user = Redux.store.state.userState.user; - Response response = await _api.xReport(user.token); + User user = Redux.store!.state.userState!.user!; + Response response = await _api.xReport(user.token!); if (response.operation) { String check = response.body['check']; var checkText = response.body['check_text']; _navigator.push(ImageShowRoute, arguments: ImageShowModel(data: CheckImageModal(base64Data: check, textData: checkText !=null ? jsonEncode(checkText) : null ), title: 'X Отчет')); - String url = response?.body['link']; + String url = response.body['link']; _dataService.insertVoucher( user: user, name: 'X Отчет', @@ -132,8 +132,8 @@ class _AdditionalTabState extends State { }); try { Dialogs.showLoadingDialog(context, _keyLoader); - await _dataService.getDataFromServer(Redux.store.state.userState.user); - Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop(); + await _dataService.getDataFromServer(Redux.store!.state.userState!.user!); + Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop(); } catch (e) { print(e); } finally { @@ -155,10 +155,10 @@ class _AdditionalTabState extends State { ); if (response.confirmed) { Response result = await _api.deposit( - Redux.store.state.userState.user.token, response.responseText); + Redux.store!.state.userState!.user!.token!, response.responseText!); _dialog.showDialog(description: result.body['message']); if (result.operation) { - await Redux.store.dispatch(checkMoney); + await Redux.store!.dispatch(checkMoney); } } } catch (e) { @@ -182,10 +182,10 @@ class _AdditionalTabState extends State { ); if (response.confirmed) { Response result = await _api.withdrawal( - Redux.store.state.userState.user.token, response.responseText); + Redux.store!.state.userState!.user!.token!, response.responseText!); _dialog.showDialog(description: result.body['message']); if (result.operation) { - await Redux.store.dispatch(checkMoney); + await Redux.store!.dispatch(checkMoney); } } } catch (e) { @@ -202,7 +202,7 @@ class _AdditionalTabState extends State { isMoneyCheckBusy = true; }); try { - await Redux.store.dispatch(checkMoney); + await Redux.store!.dispatch(checkMoney); setState(() { isMoneyCheckBusy = false; }); @@ -226,7 +226,7 @@ class _AdditionalTabState extends State { right: 20.0, ), child: StoreConnector( - converter: (store) => store.state.settingState, + converter: (store) => store.state.settingState!, builder: (context, vm) { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -272,7 +272,7 @@ class _AdditionalTabState extends State { height: 50, width: double.infinity, child: StoreConnector( - converter: (store) => store.state.userState.money, + converter: (store) => store.state.userState!.money!, builder: (_, vm) { if (vm.loading == true) { return Center( @@ -395,6 +395,6 @@ class _AdditionalTabState extends State { } void changeMode(el) { - Redux.store.dispatch(changeModeFromSetting(el)); + Redux.store!.dispatch(changeModeFromSetting(el)); } } diff --git a/lib/views/home/tabs/CalculatorTab.dart b/lib/views/home/tabs/CalculatorTab.dart index 2deb234..5e56042 100644 --- a/lib/views/home/tabs/CalculatorTab.dart +++ b/lib/views/home/tabs/CalculatorTab.dart @@ -28,10 +28,10 @@ class CalculatorTab extends StatelessWidget { body: Column( children: [ StoreConnector( - converter: (store) => store.state.calcState, + converter: (store) => store.state.calcState!, builder: (context, vm) { return NumberDisplay( - value: Calculator.parseItems(vm.calcItems, vm.isEqual)); + value: Calculator.parseItems(vm.calcItems!, vm.isEqual!)); }), CalculatorButtons(onTap: _onPress), Row( @@ -74,7 +74,7 @@ class CalculatorTab extends StatelessWidget { )); } - void _onPress({String buttonText}) { - Redux.store.dispatch(onTapAction(buttonText)); + void _onPress({required String buttonText}) { + Redux.store!.dispatch(onTapAction(buttonText)); } } diff --git a/lib/views/home/tabs/KassaTab.dart b/lib/views/home/tabs/KassaTab.dart index f37be9c..f2feae3 100644 --- a/lib/views/home/tabs/KassaTab.dart +++ b/lib/views/home/tabs/KassaTab.dart @@ -17,10 +17,10 @@ import 'package:aman_kassa_flutter/views/home/tabs/kassaView/CatalogBottomSheet. import 'package:aman_kassa_flutter/views/home/tabs/kassaView/ProductAddBottomSheet.dart'; import 'package:aman_kassa_flutter/views/payment/payment_view.dart'; import 'package:aman_kassa_flutter/widgets/components/ProductListItem.dart'; -import 'package:barcode_scan/gen/protos/protos.pb.dart'; -import 'package:barcode_scan/gen/protos/protos.pbenum.dart'; -import 'package:barcode_scan/model/scan_options.dart'; -import 'package:barcode_scan/platform_wrapper.dart'; +import 'package:barcode_scan2/gen/protos/protos.pb.dart'; +import 'package:barcode_scan2/gen/protos/protos.pbenum.dart'; +import 'package:barcode_scan2/model/scan_options.dart'; +import 'package:barcode_scan2/platform_wrapper.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_redux/flutter_redux.dart'; @@ -103,12 +103,12 @@ class KassaTab extends StatelessWidget { Expanded( child: Container( child: StoreConnector( - converter: (store) => store.state.kassaState, + converter: (store) => store.state.kassaState!, builder: (context, vm) { return ListView.builder( - itemCount: vm.kassaItems.length, + itemCount: vm.kassaItems!.length, itemBuilder: (BuildContext ctxt, int index) => - buildItem(ctxt, index, vm.kassaItems[index])); + buildItem(ctxt, index, vm.kassaItems![index])); }), ), ), @@ -119,9 +119,9 @@ class KassaTab extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.end, children: [ StoreConnector( - converter: (store) => store.state.kassaState, + converter: (store) => store.state.kassaState!, builder: (context, vm) { - return Text(totalCalc(vm.kassaItems), + return Text(totalCalc(vm.kassaItems!), style: TextStyle(fontSize: 25)); }), ], @@ -184,7 +184,7 @@ class KassaTab extends StatelessWidget { Future scan() async { try { - await Redux.store.dispatch(changePinSkipFromSetting(true)); + await Redux.store!.dispatch(changePinSkipFromSetting(true)); var options = ScanOptions(strings: { "cancel": 'Отмена', "flash_on": 'Вкл фонарик', @@ -197,8 +197,8 @@ class KassaTab extends StatelessWidget { // print(result.formatNote); // If a unknown format was scanned this field contains a note // print(result.rawContent); // content if (result.type == ResultType.Barcode ) { - String barcode; - String dataMatrix; + String? barcode; + String? dataMatrix; if(result.format == BarcodeFormat.ean13 || result.format == BarcodeFormat.ean8) { barcode = result.rawContent; } else if( result.format == BarcodeFormat.dataMatrix ) { @@ -219,7 +219,7 @@ class KassaTab extends StatelessWidget { List goods = await _dataService.getGoodsByBarcode(barcode: barcode); if (goods != null && goods.isNotEmpty) { - await Redux.store.dispatch(addProductToKassaItems(goods.first, dataMatrix)); + await Redux.store!.dispatch(addProductToKassaItems(goods.first, dataMatrix)); } else { _dialogService.showDialog( description: 'Товар не найден: $barcode'); @@ -241,7 +241,7 @@ class KassaTab extends StatelessWidget { _dialogService.showDialog(description: 'Неизвестная ошибка: $e'); } } finally { - await Redux.store.dispatch(changePinSkipFromSetting(false)); + await Redux.store!.dispatch(changePinSkipFromSetting(false)); } } diff --git a/lib/views/home/tabs/kassaView/CatalogBottomSheet.dart b/lib/views/home/tabs/kassaView/CatalogBottomSheet.dart index 664a006..98d3f18 100644 --- a/lib/views/home/tabs/kassaView/CatalogBottomSheet.dart +++ b/lib/views/home/tabs/kassaView/CatalogBottomSheet.dart @@ -15,20 +15,20 @@ import 'package:flutter/material.dart'; import 'package:flutter_redux/flutter_redux.dart'; class CatalogBottomSheet extends StatelessWidget { - final ScrollController scrollController; + final ScrollController? scrollController; CatalogBottomSheet({this.scrollController}); @override Widget build(BuildContext context) { return StoreConnector( - converter: (store) => store.state.kassaState, - onInit: (store) => Redux.store.dispatch(selectBottomElement(0)), + converter: (store) => store.state.kassaState!, + onInit: (store) => Redux.store!.dispatch(selectBottomElement(0)), builder: (context, vm) { return WillPopScope( onWillPop: () { - if (vm.prevCategories.length > 0) { - Redux.store.dispatch(backBottomElement); + if (vm.prevCategories!.length > 0) { + Redux.store!.dispatch(backBottomElement); } else Navigator.pop(context); return new Future(() => false); @@ -36,8 +36,8 @@ class CatalogBottomSheet extends StatelessWidget { child: Scaffold( appBar: AppBar( title: Text( - vm.prevCategories.isNotEmpty - ? vm.prevCategories?.last?.name + vm.prevCategories!.isNotEmpty + ? vm.prevCategories!.last.name : '', style: TextStyle(color: Colors.black45), ), @@ -45,12 +45,12 @@ class CatalogBottomSheet extends StatelessWidget { backgroundColor: whiteColor, elevation: 1, leading: IconButton( - icon: Icon(vm.prevCategories.length > 0 + icon: Icon(vm.prevCategories!.length > 0 ? Icons.arrow_back : Icons.close), onPressed: () { - if (vm.prevCategories.length > 0) { - Redux.store.dispatch(backBottomElement); + if (vm.prevCategories!.length > 0) { + Redux.store!.dispatch(backBottomElement); } else Navigator.pop(context); }, @@ -63,11 +63,11 @@ class CatalogBottomSheet extends StatelessWidget { Expanded( child: ListView.builder( controller: scrollController, - itemCount: vm.bottomSheetElements.length, + itemCount: vm.bottomSheetElements!.length, itemBuilder: (context, index) { - var el = vm.bottomSheetElements[index]; - String name; - String price; + var el = vm.bottomSheetElements![index]; + String? name; + String? price; if (el is Category) { Category category = el; name = category.name; @@ -86,19 +86,19 @@ class CatalogBottomSheet extends StatelessWidget { ? Icon(Icons.layers, size: 25) : null, title: Text( - name, + name ?? '', style: TextStyle(fontSize: 15), ), onTap: () async { if (el is Category) { - Redux.store - .dispatch(selectBottomElement(el.id)); + Redux.store! + .dispatch(selectBottomElement(el.id!)); } else if (el is Good) { - await Redux.store + await Redux.store! .dispatch(addProductToKassaItems(el, null)); Navigator.pop(context); } else if (el is Service) { - await Redux.store + await Redux.store! .dispatch(addServiceToKassaItems(el)); Navigator.pop(context); } @@ -106,7 +106,7 @@ class CatalogBottomSheet extends StatelessWidget { trailing: el is Category ? Icon(Icons.chevron_right) : Text( - price, + price ?? '', style: TextStyle( fontSize: 15, color: Colors.black54), ), @@ -135,12 +135,12 @@ class CatalogBottomSheet extends StatelessWidget { return Container( margin: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 5.0), child: StoreConnector( - converter: (store) => store.state.kassaState, + converter: (store) => store.state.kassaState!, builder: (_, mainState) { return StoreConnector( - converter: (store) => store.state.settingState, + converter: (store) => store.state.settingState!, builder: (_, settingState) { - if (mainState.kassaItems.isNotEmpty) { + if (mainState.kassaItems!.isNotEmpty) { return GestureDetector( onTap: () { locator().showDialog( @@ -169,8 +169,8 @@ class CatalogBottomSheet extends StatelessWidget { underline: Container( height: 1, ), - onChanged: (String newValue) { - onChangeTradeType(newValue, settingState.tradeType); + onChanged: (String? newValue) { + onChangeTradeType(newValue!, settingState.tradeType!); }, items: [ DropdownMenuItem( @@ -190,8 +190,8 @@ class CatalogBottomSheet extends StatelessWidget { void onChangeTradeType(String newValue, String oldValue) async { if (oldValue != newValue) { - await Redux.store.dispatch(changeTradeTypeFromSetting(newValue)); - await Redux.store.dispatch(selectBottomElement(0)); + await Redux.store!.dispatch(changeTradeTypeFromSetting(newValue)); + await Redux.store!.dispatch(selectBottomElement(0)); } } } diff --git a/lib/views/home/tabs/kassaView/ProductAddBottomSheet.dart b/lib/views/home/tabs/kassaView/ProductAddBottomSheet.dart index 19423c2..ba42553 100644 --- a/lib/views/home/tabs/kassaView/ProductAddBottomSheet.dart +++ b/lib/views/home/tabs/kassaView/ProductAddBottomSheet.dart @@ -6,7 +6,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; class ProductAddBottomSheet extends StatefulWidget { - final ScrollController scrollController; + final ScrollController? scrollController; ProductAddBottomSheet({this.scrollController}); @@ -15,9 +15,9 @@ class ProductAddBottomSheet extends StatefulWidget { } class _ProductAddBottomSheetState extends State { - TextEditingController nameController; - TextEditingController countController; - TextEditingController priceController; + late TextEditingController nameController; + late TextEditingController countController; + late TextEditingController priceController; double sum = 0.0; @override @@ -157,7 +157,7 @@ class _ProductAddBottomSheetState extends State { priceController.text.isEmpty) { _showDialog(); } else { - Redux.store.dispatch(addCustomProductToKassaItems( + Redux.store!.dispatch(addCustomProductToKassaItems( nameController.text, int.parse(countController.text), double.parse(priceController.text), diff --git a/lib/views/info_kkm/info_kkm_view.dart b/lib/views/info_kkm/info_kkm_view.dart index f0cae7a..2a60da2 100644 --- a/lib/views/info_kkm/info_kkm_view.dart +++ b/lib/views/info_kkm/info_kkm_view.dart @@ -28,8 +28,8 @@ class _InfoKkmViewState extends State { setState(() { loading = true; }); - User user = Redux.store.state.userState.user; - Response response = await _apiService.infoKkm(user.token); + User user = Redux.store!.state.userState!.user!; + Response response = await _apiService.infoKkm(user.token!); if (response.operation) { List list = []; for (var key in response.body.keys) { diff --git a/lib/views/lockscreen/passcodescreen.dart b/lib/views/lockscreen/passcodescreen.dart index b75234d..27fb2ce 100644 --- a/lib/views/lockscreen/passcodescreen.dart +++ b/lib/views/lockscreen/passcodescreen.dart @@ -8,7 +8,7 @@ import 'package:aman_kassa_flutter/core/locator.dart'; import 'package:aman_kassa_flutter/core/services/navigator_service.dart'; class PassCodeScreen extends StatefulWidget { - PassCodeScreen({Key key, this.title}) : super(key: key); + PassCodeScreen({Key? key, required this.title}) : super(key: key); final String title; @@ -45,7 +45,7 @@ class _PassCodeScreenState extends State { @override Widget build(BuildContext context) { var myPass = []; - String _pinCode = Redux.store.state.settingState.pinCode; + String _pinCode = Redux.store!.state.settingState!.pinCode!; for (var i = 0; i < _pinCode.length; i++) { myPass.add(int.parse(_pinCode[i])); } @@ -72,7 +72,7 @@ class _PassCodeScreenState extends State { return true; }, onSuccess: () { - Redux.store.dispatch(changePinLockedFromSetting(false)); + Redux.store!.dispatch(changePinLockedFromSetting(false)); _navigatorService.replace(HomeViewRoute); }); } diff --git a/lib/views/login/login_view.dart b/lib/views/login/login_view.dart index e6b122d..5f3b056 100644 --- a/lib/views/login/login_view.dart +++ b/lib/views/login/login_view.dart @@ -11,27 +11,27 @@ import 'package:aman_kassa_flutter/shared/app_colors.dart'; import 'package:aman_kassa_flutter/shared/ui_helpers.dart'; import 'package:aman_kassa_flutter/widgets/fields/busy_button.dart'; import 'package:aman_kassa_flutter/widgets/fields/input_field.dart'; -import 'package:barcode_scan/gen/protos/protos.pb.dart'; -import 'package:barcode_scan/gen/protos/protos.pbenum.dart'; -import 'package:barcode_scan/model/scan_options.dart'; -import 'package:barcode_scan/platform_wrapper.dart'; +import 'package:barcode_scan2/gen/protos/protos.pb.dart'; +import 'package:barcode_scan2/gen/protos/protos.pbenum.dart'; +import 'package:barcode_scan2/model/scan_options.dart'; +import 'package:barcode_scan2/platform_wrapper.dart'; import 'package:flutter/services.dart'; import 'package:flutter_redux/flutter_redux.dart'; import 'package:flutter/material.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; class LoginView extends StatefulWidget { - final LoginModel loginModel; - LoginView({this.loginModel}); + final LoginModel? loginModel; + LoginView({ this.loginModel}); @override _LoginViewState createState() => _LoginViewState(); } class _LoginViewState extends State { - TextEditingController emailController; + late TextEditingController emailController; - TextEditingController passwordController; + late TextEditingController passwordController; final FocusNode passwordNode = new FocusNode(); @@ -45,10 +45,10 @@ class _LoginViewState extends State { void initState() { super.initState(); if (widget.loginModel != null && - widget.loginModel.authType == AuthenticateTypeLogin) { - emailController = TextEditingController(text: widget.loginModel.login); + widget.loginModel?.authType == AuthenticateTypeLogin) { + emailController = TextEditingController(text: widget.loginModel?.login); passwordController = - TextEditingController(text: widget.loginModel.password); + TextEditingController(text: widget.loginModel?.password); } else { emailController = TextEditingController(); passwordController = TextEditingController(); @@ -65,7 +65,7 @@ class _LoginViewState extends State { @override Widget build(BuildContext context) { return StoreConnector( - converter: (store) => store.state.userState, + converter: (store) => store.state.userState!, builder: (context, vm) { return Scaffold( key: _scaffoldKey, @@ -100,7 +100,7 @@ class _LoginViewState extends State { controller: emailController, textInputType: TextInputType.emailAddress, nextFocusNode: passwordNode, - additionalNote: vm.loginFormMessage.email, + additionalNote: vm.loginFormMessage?.email, ), verticalSpaceSmall, InputField( @@ -108,7 +108,7 @@ class _LoginViewState extends State { password: true, controller: passwordController, fieldFocusNode: passwordNode, - additionalNote: vm.loginFormMessage.password, + additionalNote: vm.loginFormMessage?.password, enterPressed: _pressBtnEnter, textInputAction: TextInputAction.done, ), @@ -121,7 +121,7 @@ class _LoginViewState extends State { width: 150, child: BusyButton( title: 'Войти', - busy: vm.isLoading, + busy: vm.isLoading ?? false, onPressed: _pressBtnEnter, ), ) @@ -151,7 +151,7 @@ class _LoginViewState extends State { } else { _apiService.test = false; } - Redux.store + Redux.store! .dispatch(authenticate(emailController.text, passwordController.text)); } @@ -169,13 +169,13 @@ class _LoginViewState extends State { // print(result // .formatNote); // If a unknown format was scanned this field contains a note if (result.type == ResultType.Barcode && - result.rawContent?.length == 60) { + result.rawContent.length == 60) { if (result.rawContent.toLowerCase().trim().startsWith('test')) { _apiService.test = true; } else { _apiService.test = false; } - Redux.store.dispatch(authenticateToken(result.rawContent)); + Redux.store!.dispatch(authenticateToken(result.rawContent)); } else if (result.type == ResultType.Error) { _dialogService.showDialog(description: 'Не верный формат QR кода'); } @@ -196,8 +196,8 @@ class _LoginViewState extends State { } class LoginModel { - final String authType; - final String login; - final String password; + final String? authType; + final String? login; + final String? password; LoginModel({this.authType, this.login, this.password}); } diff --git a/lib/views/payment/payment_view.dart b/lib/views/payment/payment_view.dart index a6a6f15..eca516e 100644 --- a/lib/views/payment/payment_view.dart +++ b/lib/views/payment/payment_view.dart @@ -29,7 +29,7 @@ import 'package:flutter_redux/flutter_redux.dart'; class PaymentView extends StatefulWidget { final PaymentModel model; - const PaymentView({Key key, this.model}) : super(key: key); + const PaymentView({Key? key, required this.model}) : super(key: key); @override _PaymentViewState createState() => _PaymentViewState(); @@ -40,7 +40,7 @@ class _PaymentViewState extends State { final DataService _dataService = locator(); final DialogService _dialogService = locator(); final NavigatorService _navigatorService = locator(); - bool isBusy; + late bool isBusy; @override void initState() { @@ -102,9 +102,9 @@ class _PaymentViewState extends State { StoreConnector buildStoreConnector() { if (widget.model.mode == SettingModeCalc) { return StoreConnector( - converter: (store) => store.state.calcState, + converter: (store) => store.state.calcState!, builder: (_, vm) { - return Text('${totalCalc(vm.calcItems)} тнг', + return Text('${totalCalc(vm.calcItems!)} тнг', style: TextStyle( fontWeight: FontWeight.bold, color: Colors.black87, @@ -112,9 +112,9 @@ class _PaymentViewState extends State { }); } return StoreConnector( - converter: (store) => store.state.kassaState, + converter: (store) => store.state.kassaState!, builder: (_, vm) { - return Text('${totalKassa(vm.kassaItems)} тнг', + return Text('${totalKassa(vm.kassaItems!)} тнг', style: TextStyle( fontWeight: FontWeight.bold, color: Colors.black87, @@ -174,16 +174,16 @@ class _PaymentViewState extends State { }); Dialogs.showLoadingDialog(context, _keyLoader); try { - AppState _state = Redux.store.state; - String _token = _state.userState.user.token; - String _tradeType = _state.settingState.tradeType; - String _mode = _state.settingState.mode; + AppState _state = Redux.store!.state; + String _token = _state.userState!.user!.token!; + String _tradeType = _state.settingState!.tradeType!; + String _mode = _state.settingState!.mode!; if (_mode == SettingModeCalc) { _tradeType = SettingTradeTypeGood; } - List kassaItems = _state.kassaState.kassaItems; - List calcItems = _state.calcState.calcItems; - Response response = await _dataService.sellOrReturn( + List kassaItems = _state.kassaState!.kassaItems!; + List calcItems = _state.calcState!.calcItems!; + Response? response = await _dataService.sellOrReturn( token: _token, kassaItems: kassaItems, paymentType: type, @@ -199,34 +199,34 @@ class _PaymentViewState extends State { String message = response.body['message']; String check = response.body['check']; var checkText = response.body['check_text']; - String url = response?.body['link']; + String url = response.body['link']; print('url : $url'); if (_mode == SettingModeCalc) { - Redux.store.dispatch(cleanCalcItems); + Redux.store!.dispatch(cleanCalcItems); } else if (_mode == SettingModeKassa) { - Redux.store.dispatch(cleanKassaItems); + Redux.store!.dispatch(cleanKassaItems); } - Redux.store.dispatch(checkMoney); - Redux.store.dispatch(openSmenaPseudo); - Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop(); + Redux.store!.dispatch(checkMoney); + Redux.store!.dispatch(openSmenaPseudo); + Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop(); _navigatorService.pop(); _navigatorService.push(ImageShowRoute, arguments: ImageShowModel(data:new CheckImageModal(base64Data: check, textData: checkText !=null ? jsonEncode(checkText) : null ), title: message, url: url )); } else if (!response.operation && ![401,402,403,412,500].contains(response.status)) { - Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop(); + Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop(); _dialogService.showDialog(description: response.body['message']); } else if(!response.operation && response.body['message'] != null) { - Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop(); + Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop(); _dialogService.showDialog(description: response.body['message']); } else { - Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop(); + Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop(); } } else { - Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop(); + Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop(); } } catch (e) { print(e); - Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop(); + Navigator.of(_keyLoader.currentContext!, rootNavigator: true).pop(); } finally { //Navigator.of(context, rootNavigator: true).pop(); @@ -249,7 +249,7 @@ class _PaymentViewState extends State { items.forEach((element) { if (element.operation == Calculations.MULTIPLY) { double num1 = element.num1 == null ? 0.0 : double.parse(element.num1); - double num2 = element.num2 == null ? 0.0 : double.parse(element.num2); + double num2 = element.num2 == null ? 0.0 : double.parse(element.num2!); total += num1 * num2; } else { total += element.num1 == null ? 0.0 : double.parse(element.num1); @@ -262,5 +262,5 @@ class _PaymentViewState extends State { class PaymentModel { String operationType; String mode; - PaymentModel({this.mode, this.operationType}); + PaymentModel({required this.mode, required this.operationType}); } diff --git a/lib/views/qr_view/qr_view.dart b/lib/views/qr_view/qr_view.dart index ae73426..f414a4e 100644 --- a/lib/views/qr_view/qr_view.dart +++ b/lib/views/qr_view/qr_view.dart @@ -27,7 +27,7 @@ class _QrViewState extends State { body: Container( child: Center( child: QrImage( - data: widget.data.url, + data: widget.data.url!, version: QrVersions.auto, size: 220.0, ), diff --git a/lib/views/settings/component/setting_item.dart b/lib/views/settings/component/setting_item.dart index 7f81896..f248fd2 100644 --- a/lib/views/settings/component/setting_item.dart +++ b/lib/views/settings/component/setting_item.dart @@ -2,12 +2,12 @@ import 'package:flutter/material.dart'; class SettingItem extends StatefulWidget { - final String name; - final String value; + final String? name; + final String? value; final String title; final Function onTap; - SettingItem({Key key, this.name, this.value, this.onTap, this.title }) : super(key: key); + SettingItem({Key? key, this.name, this.value, required this.onTap, required this.title }) : super(key: key); @override _SettingItemState createState() => _SettingItemState(); @@ -21,16 +21,16 @@ class _SettingItemState extends State { title: Text(widget.title), subtitle: Text.rich( TextSpan( - text: widget.name, + text: widget.name ?? '', style: TextStyle(fontWeight: FontWeight.w500), children: [ - if(widget.value !=null) + if(widget.value != null) TextSpan(text: ' ${widget.value}', style: TextStyle(fontStyle: FontStyle.italic)), ], ) ), trailing: Icon(Icons.chevron_right), - onTap: widget.onTap, + onTap: () => widget.onTap(), ), ); } diff --git a/lib/views/settings/printer/PrinterTest.dart b/lib/views/settings/printer/PrinterTest.dart index 3dbaba7..abbd4ca 100644 --- a/lib/views/settings/printer/PrinterTest.dart +++ b/lib/views/settings/printer/PrinterTest.dart @@ -10,65 +10,26 @@ import 'package:image/image.dart' as Im; import 'package:path_provider/path_provider.dart'; import 'package:qr_flutter/qr_flutter.dart'; -Future testTicket(PaperSize paper) async { - final Ticket ticket = Ticket(paper); +Future> testTicket(PaperSize paper) async { - //Uint8List encTxt11 = await CharsetConverter.encode("cp866", "Russian: Привет Мир!"); - //ticket.textEncoded(encTxt11, styles: PosStyles(codeTable: PosCodeTable.pc866_2)); - //ticket.textEncoded(encTxt11); - - // ticket.text('Special 1: àÀ', styles: PosStyles(codeTable: PosCodeTable.westEur)); //А - // ticket.text('Special 1: á'.toUpperCase(), styles: PosStyles(codeTable: PosCodeTable.westEur));// Б - // ticket.text('Special 1: â', styles: PosStyles(codeTable: PosCodeTable.westEur)); //В - // ticket.text('Special 1: ã', styles: PosStyles(codeTable: PosCodeTable.westEur));// Г - // ticket.text('Special 1: äÄ', styles: PosStyles(codeTable: PosCodeTable.westEur)); //Д - // ticket.text('Special 1: å', styles: PosStyles(codeTable: PosCodeTable.westEur));// Е - // ticket.text('Special 1: æÆ', styles: PosStyles(codeTable: PosCodeTable.westEur));// Ж - // ticket.text('Special 1: ç', styles: PosStyles(codeTable: PosCodeTable.westEur));//З - // ticket.text('Special 1: èÈ', styles: PosStyles(codeTable: PosCodeTable.westEur)); // И - // ticket.text('Special 1: éÉ', styles: PosStyles(codeTable: PosCodeTable.westEur)); // Й - // ticket.text('Special 1: ê', styles: PosStyles(codeTable: PosCodeTable.westEur));//К - // ticket.text('Special 1: ëË', styles: PosStyles(codeTable: PosCodeTable.westEur)); // Л - // ticket.text('Special 1: ìÌ', styles: PosStyles(codeTable: PosCodeTable.westEur));// M - // ticket.text('Special 1: íÍ', styles: PosStyles(codeTable: PosCodeTable.westEur)); // Н - // ticket.text('Special 1: î', styles: PosStyles(codeTable: PosCodeTable.westEur));// О - // ticket.text('Special 1: ï', styles: PosStyles(codeTable: PosCodeTable.westEur)); // П - // ticket.text('Special 1: ð', styles: PosStyles(codeTable: PosCodeTable.westEur));// Р - // ticket.text('Special 1: ñ', styles: PosStyles(codeTable: PosCodeTable.westEur));// С - // ticket.text('Special 1: ò', styles: PosStyles(codeTable: PosCodeTable.westEur)); // Т - // ticket.text('Special 1: óÓ', styles: PosStyles(codeTable: PosCodeTable.westEur)); //У - // ticket.text('Special 1: ô', styles: PosStyles(codeTable: PosCodeTable.westEur));// Ф - // ticket.text('Special 1: õÕ', styles: PosStyles(codeTable: PosCodeTable.westEur));// Х - // ticket.text('Special 1: ö', styles: PosStyles(codeTable: PosCodeTable.westEur)); //Ц - // ticket.text('Special 1: ÷', styles: PosStyles(codeTable: PosCodeTable.westEur)); //Ч - // ticket.text('Special 1: ø', styles: PosStyles(codeTable: PosCodeTable.westEur));//Ш - // ticket.text('Special 1: ù', styles: PosStyles(codeTable: PosCodeTable.westEur)); //Щ - // ticket.text('Special 1: ú', styles: PosStyles(codeTable: PosCodeTable.westEur));//Ъ - // ticket.text('Special 1: û', styles: PosStyles(codeTable: PosCodeTable.westEur));//Ы - // ticket.text('Special 1: üÜ', styles: PosStyles(codeTable: PosCodeTable.westEur)); //Ь - // ticket.text('Special 1: ý', styles: PosStyles(codeTable: PosCodeTable.westEur)); //Э - // ticket.text('Special 1: þ', styles: PosStyles(codeTable: PosCodeTable.westEur)); // ю - // ticket.text('Special 1: ÿß', styles: PosStyles(codeTable: PosCodeTable.westEur)); //Я - - // Uint8List encTxt11 = await CharsetConverter.encode("cp866", "Russian: Привет Мир!"); - // //ticket.textEncoded(encTxt11, styles: PosStyles(codeTable: PosCodeTable.pc866_2)); - // ticket.textEncoded(encTxt11); - - ticket.text( + final profile = await CapabilityProfile.load(); + final ticket = Generator(PaperSize.mm80, profile); + List bytes = []; + bytes += ticket.text( 'Regular: aA bB cC dD eE fF gG hH iI jJ kK lL mM nN oO pP qQ rR sS tT uU vV wW xX yY zZ'); //ticket.text('Special 1: àÀ èÈ éÉ ûÛ üÜ çÇ ôÔ', styles: PosStyles(codeTable: PosCodeTable.westEur)); //ticket.text('Special 2: blåbærgrød', styles: PosStyles(codeTable: PosCodeTable.westEur)); - ticket.text('Bold text', styles: PosStyles(bold: true)); - ticket.text('Reverse text', styles: PosStyles(reverse: true)); - ticket.text('Underlined text', + bytes += ticket.text('Bold text', styles: PosStyles(bold: true)); + bytes += ticket.text('Reverse text', styles: PosStyles(reverse: true)); + bytes += ticket.text('Underlined text', styles: PosStyles(underline: true), linesAfter: 1); - ticket.text('Align left', styles: PosStyles(align: PosAlign.left)); - ticket.text('Align center', styles: PosStyles(align: PosAlign.center)); - ticket.text('Align right', + bytes += ticket.text('Align left', styles: PosStyles(align: PosAlign.left)); + bytes += ticket.text('Align center', styles: PosStyles(align: PosAlign.center)); + bytes += ticket.text('Align right', styles: PosStyles(align: PosAlign.right), linesAfter: 1); - ticket.row([ + bytes += ticket.row([ PosColumn( text: 'col3', width: 3, @@ -86,7 +47,7 @@ Future testTicket(PaperSize paper) async { ), ]); - ticket.text('Text size 200%', + bytes += ticket.text('Text size 200%', styles: PosStyles( height: PosTextSize.size2, width: PosTextSize.size2, @@ -101,64 +62,70 @@ Future testTicket(PaperSize paper) async { // Print barcode final List barData = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 4]; - ticket.barcode(Barcode.upcA(barData)); + bytes += ticket.barcode(Barcode.upcA(barData)); - ticket.feed(2); + bytes += ticket.feed(2); - ticket.cut(); - return ticket; + bytes += ticket.cut(); + return bytes; } -Future testTicketImage(PaperSize paper) async { - final Ticket ticket = Ticket(paper); +Future> testTicketImage(PaperSize paper) async { + final profile = await CapabilityProfile.load(); + final ticket = Generator(paper, profile); + List bytesResult = []; // Print image final ByteData byteData = await rootBundle.load('assets/images/check.png'); final Uint8List bytes = byteData.buffer.asUint8List(); - final Im.Image image = Im.decodeImage(bytes); + final Im.Image? image = Im.decodeImage(bytes); // Using `ESC *` //ticket.image(imagea); // Using `GS v 0` (obsolete) //ticket.imageRaster(imagea); // Using `GS ( L` - ticket.imageRaster(image, imageFn: PosImageFn.bitImageRaster); + if(image !=null) { + bytesResult += ticket.imageRaster(image, imageFn: PosImageFn.bitImageRaster); + } //ticket.image(imagea); - ticket.feed(2); + bytesResult += ticket.feed(2); - ticket.cut(); - return ticket; + bytesResult += ticket.cut(); + return bytesResult; } -Future printImageCheck(PaperSize paper, String base64Src) async { - final Ticket ticket = Ticket(paper); +Future> printImageCheck(PaperSize paper, String base64Src) async { + final profile = await CapabilityProfile.load(); + final ticket = Generator(paper, profile); + List bytesResult = []; final Uint8List bytes = base64Decode(base64Src); - final Im.Image image = Im.decodeImage(bytes); - ticket.imageRaster(image, imageFn: PosImageFn.bitImageRaster); - //ticket.image(image); - ticket.feed(2); - ticket.cut(); - return ticket; + final Im.Image? image = Im.decodeImage(bytes); + if(image != null) { + bytesResult += ticket.imageRaster(image, imageFn: PosImageFn.bitImageRaster); + } + bytesResult += ticket.feed(2); + bytesResult += ticket.cut(); + return bytesResult; } -Future printTextCheck(PaperSize paper, String encoding, var data ) async { - final Ticket ticket = Ticket(paper); - ticket.emptyLines(1); - - - PosCodeTable codeTable; +Future> printTextCheck(PaperSize paper, String encoding, var data ) async { + final profile = await CapabilityProfile.load(); + final ticket = Generator(paper, profile); + List bytesResult = []; + String codeTable = 'CP866'; if(encoding == SettingPrinterEncodingCp866) { - codeTable = PosCodeTable.pc866_2; + codeTable = 'CP866'; } else if(encoding == SettingPrinterEncodingWin1251) { - codeTable = PosCodeTable.wpc1251; + codeTable = 'CP1251'; } - - //ticket.setGlobalCodeTable(codeTable); - ticket.setGlobalFont(PosFontType.fontB); + ticket.setGlobalCodeTable(codeTable); + bytesResult += ticket.emptyLines(1); + //ticket.setGlobalFont(PosFontType.fontB); String qr = data['qr']; @@ -172,7 +139,7 @@ Future printTextCheck(PaperSize paper, String encoding, var data ) async if(text is List) { Uint8List firstCol = await CharsetConverter.encode(encoding, (text).first as String); Uint8List lastCol = await CharsetConverter.encode(encoding, (text).last as String); - ticket.row([ + bytesResult += ticket.row([ PosColumn( textEncoded: firstCol, width: 6, @@ -187,16 +154,16 @@ Future printTextCheck(PaperSize paper, String encoding, var data ) async } else { String line = text as String; if(line == 'breakline') { - ticket.hr(); + bytesResult += ticket.hr(); } else if(line == 'br') { - ticket.emptyLines(1); + bytesResult += ticket.emptyLines(1); } else if(line.trim() == '') { - ticket.emptyLines(1); + bytesResult += ticket.emptyLines(1); } else { line = line.replaceAll("«", '\"'); line = line.replaceAll("»", '\"'); Uint8List encTxt11 = await CharsetConverter.encode(encoding, line); - ticket.textEncoded( encTxt11, styles: PosStyles( align: center ? PosAlign.center : PosAlign.left, codeTable: codeTable )); + bytesResult += ticket.textEncoded( encTxt11, styles: PosStyles( align: center ? PosAlign.center : PosAlign.left, codeTable: codeTable )); } } } @@ -205,7 +172,7 @@ Future printTextCheck(PaperSize paper, String encoding, var data ) async //final List barData = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 4]; //ticket.barcode(Barcode.upcA(barData)); //ticket.qrcode(qr, align: PosAlign.center); - ticket.emptyLines(1); + bytesResult += ticket.emptyLines(1); const double qrSize = 200; try { final uiImg = await QrPainter( @@ -217,8 +184,12 @@ Future printTextCheck(PaperSize paper, String encoding, var data ) async //final pathName = '${dir.path}/qr_tmp.png'; //final qrFile = File(pathName); //final imgFile = await qrFile.writeAsBytes(uiImg.buffer.asUint8List()); - final img = Im.decodePng(uiImg.buffer.asUint8List()); - ticket.image(img); + if(uiImg !=null) { + final Im.Image? img = Im.decodePng(uiImg.buffer.asUint8List()); + if(img !=null) { + bytesResult += ticket.image(img); + } + } //ticket.qrcode(qr, size: QRSize.Size1 ); } catch (e) { @@ -226,9 +197,9 @@ Future printTextCheck(PaperSize paper, String encoding, var data ) async } - ticket.emptyLines(1); - ticket.feed(1); + bytesResult += ticket.emptyLines(1); + bytesResult += ticket.feed(1); - ticket.cut(); - return ticket; + bytesResult += ticket.cut(); + return bytesResult; } \ No newline at end of file diff --git a/lib/views/settings/printer/views/PrinterEncoding.dart b/lib/views/settings/printer/views/PrinterEncoding.dart index 8f45bac..cff273b 100644 --- a/lib/views/settings/printer/views/PrinterEncoding.dart +++ b/lib/views/settings/printer/views/PrinterEncoding.dart @@ -21,8 +21,8 @@ import '../data/settings_envi.dart'; class PrinterEncodingView extends StatefulWidget { - PrinterEncodingView({Key key, this.title}) : super(key: key); - final String title; + PrinterEncodingView({Key? key, this.title}) : super(key: key); + final String? title; @override _PrinterEncodingViewState createState() => _PrinterEncodingViewState(); @@ -44,7 +44,7 @@ class _PrinterEncodingViewState extends State { void _selectPrinter(String encoding, BuildContext context, ) async { _logger.i(encoding); - await Redux.store.dispatch(selectPrinterEncodingFromSetting(encoding)); + await Redux.store!.dispatch(selectPrinterEncodingFromSetting(encoding)); Navigator.of(context).pop(false); } @@ -76,7 +76,7 @@ class _PrinterEncodingViewState extends State { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ - Text(encoding.values.elementAt(index) ?? ''), + Text(encoding.values.elementAt(index)), ], ), ) diff --git a/lib/views/settings/printer/views/PrinterPaperSize.dart b/lib/views/settings/printer/views/PrinterPaperSize.dart index b028c84..39453be 100644 --- a/lib/views/settings/printer/views/PrinterPaperSize.dart +++ b/lib/views/settings/printer/views/PrinterPaperSize.dart @@ -21,8 +21,8 @@ import '../data/settings_envi.dart'; class PrinterPaperView extends StatefulWidget { - PrinterPaperView({Key key, this.title}) : super(key: key); - final String title; + PrinterPaperView({Key? key, this.title}) : super(key: key); + final String? title; @override _PrinterEncodingViewState createState() => _PrinterEncodingViewState(); @@ -44,7 +44,7 @@ class _PrinterEncodingViewState extends State { void _selectPaper(String paperSize, BuildContext context, ) async { _logger.i(encoding); - await Redux.store.dispatch(selectPrinterPaperSizeFromSetting(paperSize)); + await Redux.store!.dispatch(selectPrinterPaperSizeFromSetting(paperSize)); Navigator.of(context).pop(false); } @@ -76,7 +76,7 @@ class _PrinterEncodingViewState extends State { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ - Text(paperSize.values.elementAt(index) ?? ''), + Text(paperSize.values.elementAt(index)), ], ), ) diff --git a/lib/views/settings/printer/views/PrinterSelect.dart b/lib/views/settings/printer/views/PrinterSelect.dart index f28b03c..cccd885 100644 --- a/lib/views/settings/printer/views/PrinterSelect.dart +++ b/lib/views/settings/printer/views/PrinterSelect.dart @@ -21,8 +21,8 @@ import '../PrinterTest.dart'; class PrinterSelectView extends StatefulWidget { - PrinterSelectView({Key key, this.title}) : super(key: key); - final String title; + PrinterSelectView({Key? key, this.title}) : super(key: key); + final String? title; @override _PrinterSelectViewState createState() => _PrinterSelectViewState(); @@ -58,163 +58,6 @@ class _PrinterSelectViewState extends State { printerManager.stopScan(); } - Future demoReceipt(PaperSize paper) async { - final Ticket ticket = Ticket(paper, ); - - // Print image - // final ByteData data = await rootBundle.load('assets/images/aman_kassa_check.png'); - // final Uint8List bytes = data.buffer.asUint8List(); - // final Im.Image image = Im.decodeImage(bytes); - // Im.Image thumbnail = Im.copyResize(image, width: 270); - // ticket.image(thumbnail, align: PosAlign.center); - - //ticket.imageRaster(image, align: PosAlign.center); - - ticket.text('AMAN-SATU', - styles: PosStyles( - align: PosAlign.center, - height: PosTextSize.size2, - width: PosTextSize.size2, - ), - linesAfter: 1); - - ticket.text('889 Watson Lane', styles: PosStyles(align: PosAlign.center)); - ticket.text('Русский язык', styles: PosStyles(align: PosAlign.center, codeTable: PosCodeTable.westEur), containsChinese: true); - ticket.text('Русский язык', styles: PosStyles(align: PosAlign.center, fontType: PosFontType.fontA), containsChinese: true); - ticket.text('Русский язык', styles: PosStyles(align: PosAlign.center, fontType: PosFontType.fontB), containsChinese: true); - ticket.text('Русский язык', styles: PosStyles(align: PosAlign.center, height: PosTextSize.size1), containsChinese: true); - ticket.text('Русский язык', styles: PosStyles(align: PosAlign.center, width: PosTextSize.size2), containsChinese: true); - ticket.text('Русский язык', styles: PosStyles(align: PosAlign.center, width: PosTextSize.size3), containsChinese: true); - ticket.text('Русский язык', styles: PosStyles(align: PosAlign.center, width: PosTextSize.size4), containsChinese: true); - ticket.text('Tel: 830-221-1234', styles: PosStyles(align: PosAlign.center)); - ticket.text('Web: www.example.com', - styles: PosStyles(align: PosAlign.center), linesAfter: 1); - - ticket.hr(); - ticket.row([ - PosColumn(text: 'Qty', width: 1), - PosColumn(text: 'Item', width: 7), - PosColumn( - text: 'Price', width: 2, styles: PosStyles(align: PosAlign.right)), - PosColumn( - text: 'Total', width: 2, styles: PosStyles(align: PosAlign.right)), - ]); - - ticket.row([ - PosColumn(text: '2', width: 1), - PosColumn(text: 'ONION RINGS', width: 7), - PosColumn( - text: '0.99', width: 2, styles: PosStyles(align: PosAlign.right)), - PosColumn( - text: '1.98', width: 2, styles: PosStyles(align: PosAlign.right)), - ]); - ticket.row([ - PosColumn(text: '1', width: 1), - PosColumn(text: 'PIZZA', width: 7), - PosColumn( - text: '3.45', width: 2, styles: PosStyles(align: PosAlign.right)), - PosColumn( - text: '3.45', width: 2, styles: PosStyles(align: PosAlign.right)), - ]); - ticket.row([ - PosColumn(text: '1', width: 1), - PosColumn(text: 'SPRING ROLLS', width: 7), - PosColumn( - text: '2.99', width: 2, styles: PosStyles(align: PosAlign.right)), - PosColumn( - text: '2.99', width: 2, styles: PosStyles(align: PosAlign.right)), - ]); - ticket.row([ - PosColumn(text: '3', width: 1), - PosColumn(text: 'CRUNCHY STICKS', width: 7), - PosColumn( - text: '0.85', width: 2, styles: PosStyles(align: PosAlign.right)), - PosColumn( - text: '2.55', width: 2, styles: PosStyles(align: PosAlign.right)), - ]); - ticket.hr(); - - ticket.row([ - PosColumn( - text: 'TOTAL', - width: 6, - styles: PosStyles( - height: PosTextSize.size2, - width: PosTextSize.size2, - )), - PosColumn( - text: '\$10.97', - width: 6, - styles: PosStyles( - align: PosAlign.right, - height: PosTextSize.size2, - width: PosTextSize.size2, - )), - ]); - - ticket.hr(ch: '=', linesAfter: 1); - - ticket.row([ - PosColumn( - text: 'Cash', - width: 7, - styles: PosStyles(align: PosAlign.right, width: PosTextSize.size2)), - PosColumn( - text: '\$15.00', - width: 5, - styles: PosStyles(align: PosAlign.right, width: PosTextSize.size2)), - ]); - ticket.row([ - PosColumn( - text: 'Change', - width: 7, - styles: PosStyles(align: PosAlign.right, width: PosTextSize.size2)), - PosColumn( - text: '\$4.03', - width: 5, - styles: PosStyles(align: PosAlign.right, width: PosTextSize.size2)), - ]); - - ticket.feed(2); - ticket.text('Thank you!', - styles: PosStyles(align: PosAlign.center, bold: true)); - - final now = DateTime.now(); - final formatter = DateFormat('MM/dd/yyyy H:m'); - final String timestamp = formatter.format(now); - ticket.text(timestamp, - styles: PosStyles(align: PosAlign.center), linesAfter: 2); - - // Print QR Code from image - // try { - // const String qrData = 'example.com'; - // const double qrSize = 200; - // final uiImg = await QrPainter( - // data: qrData, - // version: QrVersions.auto, - // gapless: false, - // ).toImageData(qrSize); - // final dir = await getTemporaryDirectory(); - // final pathName = '${dir.path}/qr_tmp.png'; - // final qrFile = File(pathName); - // final imgFile = await qrFile.writeAsBytes(uiImg.buffer.asUint8List()); - // final img = decodeImage(imgFile.readAsBytesSync()); - - // ticket.image(img); - // } catch (e) { - // print(e); - // } - - // Print QR Code using native function - // ticket.qrcode('example.com'); - - ticket.feed(2); - ticket.cut(); - return ticket; - } - - - void _selectPrinter(PrinterBluetooth printer, BuildContext context, ) async { printerManager.selectPrinter(printer); _logger.i(printer.name); @@ -225,7 +68,7 @@ class _PrinterSelectViewState extends State { ..name=printer.name ..type=printer.type; - await Redux.store.dispatch(selectPrinterFromSetting(device)); + await Redux.store!.dispatch(selectPrinterFromSetting(device)); Navigator.of(context).pop(false); } @@ -246,9 +89,6 @@ class _PrinterSelectViewState extends State { queueSleepTimeMs: 50 ); - // DEMO RECEIPT - // final PosPrintResult res = - // await printerManager.printTicket(await demoReceipt(paper) , queueSleepTimeMs: 50); } @@ -283,7 +123,7 @@ class _PrinterSelectViewState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Text(_devices[index].name ?? ''), - Text(_devices[index].address), + Text(_devices[index].address ?? ''), Text( 'Click to print a test receipt', style: TextStyle(color: Colors.grey[700]), @@ -303,7 +143,7 @@ class _PrinterSelectViewState extends State { stream: printerManager.isScanningStream, initialData: false, builder: (c, snapshot) { - if (snapshot.data) { + if (snapshot.data != null) { return FloatingActionButton( child: Icon(Icons.stop), onPressed: _stopScanDevices, diff --git a/lib/views/settings/setting_printer_view.dart b/lib/views/settings/setting_printer_view.dart index cf10e01..92e7d79 100644 --- a/lib/views/settings/setting_printer_view.dart +++ b/lib/views/settings/setting_printer_view.dart @@ -53,8 +53,8 @@ class _SettingPrinterViewState extends State { _printing = true; }); try { - final SettingState state = Redux.store.state.settingState; - printerManager.selectPrinter(PrinterBluetooth(state.printerBT)); + final SettingState state = Redux.store!.state.settingState!; + printerManager.selectPrinter(PrinterBluetooth(state.printerBT!)); bool isIos = Platform.isIOS; int chunkSizeBytes = 3096; int queueSleepTimeMs = 100; @@ -78,7 +78,7 @@ class _SettingPrinterViewState extends State { _dialogService.showDialog(description: res.msg); } else { final PosPrintResult res = await printerManager.printTicket( - await printTextCheck(paper, state.printerEncoding, exampleJson['check_text']), + await printTextCheck(paper, state.printerEncoding!, exampleJson['check_text']), chunkSizeBytes: chunkSizeBytes, queueSleepTimeMs: queueSleepTimeMs ); @@ -107,22 +107,22 @@ class _SettingPrinterViewState extends State { body: Padding( padding: const EdgeInsets.symmetric(horizontal: 8.0), child: StoreConnector( - converter: (store) => store.state.settingState, + converter: (store) => store.state.settingState!, builder: (context, vm) { return Column( children: [ SettingItem( title: 'Принтер', - name: vm.printerBT?.name, + name: vm.printerBT?.name ?? '', value: vm.printerBT != null - ? 'BT: ${vm.printerBT.address} ' + ? 'BT: ${vm.printerBT?.address ?? ''} ' : 'не выбран', onTap: () { _navigatorService.push(SettingsPrinterBTRoute); }), SettingItem( title: 'Кодировка', - name: vm.printerEncoding != null ? encoding[vm.printerEncoding] : null , + name: vm.printerEncoding != null ? encoding[vm.printerEncoding] : '' , onTap: () { _navigatorService.push(SettingsPrinterEncodingRoute); }), @@ -144,9 +144,7 @@ class _SettingPrinterViewState extends State { busy: _printing, enabled: vm.printerBT != null, onPressed: () { - _startInitialPrint(); - }, ), ], @@ -166,7 +164,7 @@ class _SettingPrinterViewState extends State { if( Platform.isAndroid) { var status = await Permission.location.status; log.i(status); - if (status.isUndetermined || status.isDenied || status.isPermanentlyDenied) { + if ( status.isDenied || status.isPermanentlyDenied) { DialogResponse response = await _dialogService.showConfirmationDialog( title: 'Доступ', description: 'Для поиска устройств Bluetooth необходимо предоставить доступ к отслеживанию геолокации.', @@ -194,7 +192,7 @@ class _SettingPrinterViewState extends State { if (Platform.isIOS) { - await _testPrint(); + _testPrint(); } else { bluetoothManager.state.listen((val) { print("state = $val"); diff --git a/lib/views/settings/settings_view.dart b/lib/views/settings/settings_view.dart index 1b89fea..e8bc364 100644 --- a/lib/views/settings/settings_view.dart +++ b/lib/views/settings/settings_view.dart @@ -16,13 +16,13 @@ class SettingView extends StatefulWidget { } class _SettingViewState extends State { - TextEditingController _pinController; + late TextEditingController _pinController; final DialogService _dialogService = locator(); @override void initState() { super.initState(); - SettingState state = Redux.store.state.settingState; + SettingState state = Redux.store!.state.settingState!; _pinController = new TextEditingController(text: state.pinCode); } @@ -41,7 +41,7 @@ class _SettingViewState extends State { if(value.isNotEmpty && value.length !=4){ _dialogService.showDialog(description: 'Необходимо указать 4-х значный числовой код'); } else { - await Redux.store.dispatch(changePinCodeFromSetting(_pinController.text)); + await Redux.store!.dispatch(changePinCodeFromSetting(_pinController.text)); _dialogService.showDialog(description: 'Данные успешно сохранены'); } } diff --git a/lib/views/start_up/start_up_view.dart b/lib/views/start_up/start_up_view.dart index 414cfb9..3f058fc 100644 --- a/lib/views/start_up/start_up_view.dart +++ b/lib/views/start_up/start_up_view.dart @@ -3,7 +3,6 @@ import 'package:aman_kassa_flutter/redux/state/user_state.dart'; import 'package:aman_kassa_flutter/redux/store.dart'; import 'package:flutter_redux/flutter_redux.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/screenutil.dart'; class StartUpView extends StatefulWidget { @@ -16,14 +15,14 @@ class _StartUpViewState extends State { @override void initState() { super.initState(); - Redux.store.dispatch(checkUserAction); + Redux.store!.dispatch(checkUserAction); } @override Widget build(BuildContext context) { - ScreenUtil.init(context, width: 411.43, height: 683.43, allowFontScaling: false); + return StoreConnector( - converter: (store) => store.state.userState, + converter: (store) => store.state.userState!, builder: (context, userState) { return Scaffold( body: Center( diff --git a/lib/widgets/components/ProductListItem.dart b/lib/widgets/components/ProductListItem.dart index 5a5b35a..cd65f30 100644 --- a/lib/widgets/components/ProductListItem.dart +++ b/lib/widgets/components/ProductListItem.dart @@ -9,7 +9,7 @@ class ProductListItem extends StatelessWidget { final ProductDao item; final int index; - ProductListItem({this.item, this.index}); + ProductListItem({required this.item, required this.index}); @override Widget build(BuildContext context) { @@ -26,7 +26,7 @@ class ProductListItem extends StatelessWidget { padding: const EdgeInsets.symmetric( vertical: 8, horizontal: 4), child: Text( - item.name ?? 'name', + item.name, style: productTextStyle, )), ), @@ -35,7 +35,7 @@ class ProductListItem extends StatelessWidget { padding: const EdgeInsets.symmetric( vertical: 8, horizontal: 4), child: Text( - '${item.price?.toString()} x ${item.count?.toString()} = ${item.total?.toString()}', + '${item.price.toString()} x ${item.count.toString()} = ${item.total.toString()}', textAlign: TextAlign.right, style: productTextStyle)), ) @@ -60,13 +60,13 @@ class ProductListItem extends StatelessWidget { // }), if(item.excise == null) buildClipRect(primaryColor, Icons.remove, () { - Redux.store + Redux.store! .dispatch( counterProductFromKassaItems(index, -1)); }), if(item.excise == null) buildClipRect(primaryColor, Icons.add, () { - Redux.store + Redux.store! .dispatch( counterProductFromKassaItems(index, 1)); }), @@ -75,7 +75,7 @@ class ProductListItem extends StatelessWidget { child: Container(), ), buildClipRect(redColor, Icons.close, () { - Redux.store + Redux.store! .dispatch(removeProductFromKassaItems(index)); }), ], diff --git a/lib/widgets/components/calculator/calculator-button.dart b/lib/widgets/components/calculator/calculator-button.dart index a444df5..ef6e9c4 100644 --- a/lib/widgets/components/calculator/calculator-button.dart +++ b/lib/widgets/components/calculator/calculator-button.dart @@ -2,13 +2,13 @@ import 'package:aman_kassa_flutter/shared/app_colors.dart'; import 'package:aman_kassa_flutter/widgets/components/calculator/calculator.dart'; import 'package:flutter/material.dart'; -typedef void CalculatorButtonTapCallback({String buttonText}); +typedef void CalculatorButtonTapCallback({required String buttonText}); List operationsBlue = [Calculations.ADD,Calculations.MULTIPLY,Calculations.EQUAL,Calculations.ERASE]; List operationsRed = [Calculations.CLEAR]; class CalculatorButton extends StatelessWidget { - CalculatorButton({this.text, @required this.onTap}); + CalculatorButton({required this.text, required this.onTap}); final String text; final CalculatorButtonTapCallback onTap; diff --git a/lib/widgets/components/calculator/calculator-buttons.dart b/lib/widgets/components/calculator/calculator-buttons.dart index 22191dd..c1d7e16 100644 --- a/lib/widgets/components/calculator/calculator-buttons.dart +++ b/lib/widgets/components/calculator/calculator-buttons.dart @@ -4,7 +4,7 @@ import 'calculator-button.dart'; import 'calculator-row.dart'; class CalculatorButtons extends StatelessWidget { - CalculatorButtons({@required this.onTap}); + CalculatorButtons({required this.onTap}); final CalculatorButtonTapCallback onTap; final calculatorButtonRows = [ diff --git a/lib/widgets/components/calculator/calculator-row.dart b/lib/widgets/components/calculator/calculator-row.dart index 1b535f4..a557d71 100644 --- a/lib/widgets/components/calculator/calculator-row.dart +++ b/lib/widgets/components/calculator/calculator-row.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'calculator-button.dart'; class CalculatorRow extends StatelessWidget { - CalculatorRow({@required this.buttons, @required this.onTap }); + CalculatorRow({required this.buttons, required this.onTap }); final List buttons; final CalculatorButtonTapCallback onTap; diff --git a/lib/widgets/components/calculator/calculator.dart b/lib/widgets/components/calculator/calculator.dart index da15f8c..3a18707 100644 --- a/lib/widgets/components/calculator/calculator.dart +++ b/lib/widgets/components/calculator/calculator.dart @@ -54,7 +54,7 @@ class Calculator { var row = items[i]; if (row.operation == Calculations.MULTIPLY) { str += "${row.num1} * ${row.num2}" ; - summ += double.parse(row.num1) * double.parse(row.num2); + summ += double.parse(row.num1) * double.parse(row.num2!); } else { str += row.num1; summ += double.parse(row.num1) ; @@ -85,7 +85,7 @@ class Calculator { if (row.num2 == null) { str += row.num1 + " * "; } else { - str += row.num1 + " * " + row.num2; + str += row.num1 + " * " + row.num2!; } } else if (row.operation == Calculations.NONE) { str += row.num1; @@ -99,7 +99,7 @@ class Calculator { return str; } - static List action({String value, List items}) { + static List action({required String value, required List items}) { switch (value) { case Calculations.ADD: { @@ -142,7 +142,7 @@ class Calculator { return [...items]; } - static List _setNumber({String value, List items}) { + static List _setNumber({required String value, required List items}) { if (items.isEmpty) { items.add(CalcModel(num1: value, operation: Calculations.NONE)); } else { @@ -169,8 +169,9 @@ class Calculator { } else if (last.operation == Calculations.MULTIPLY) { if(last.num2 == null) last.num2 = value; - else - last.num2 += value; + else if(last.num2 !=null) { + last.num2 = last.num2! + value; + } last.operation = Calculations.MULTIPLY; items.add(last); } else if (last.operation == Calculations.ADD) { @@ -183,7 +184,7 @@ class Calculator { return [...items]; } - static List _setPlus({String value, List items}) { + static List _setPlus({required String value, required List items}) { if (items.isNotEmpty) { CalcModel last = items.removeLast(); if (last.closed) { @@ -212,11 +213,11 @@ class Calculator { return [...items]; } - static List _setDot({String value, List items}) { + static List _setDot({required String value, required List items}) { if (items.isNotEmpty) { CalcModel last = items.removeLast(); if (last.operation == Calculations.NONE) { - if (last.num1?.contains('.') == false) { + if (last.num1.contains('.') == false) { last.num1 += '.'; } last.operation = Calculations.NONE; @@ -226,10 +227,10 @@ class Calculator { items.add(CalcModel(num1: '0.', operation: Calculations.NONE)); } else if (last.operation == Calculations.MULTIPLY) { if (last.num2 == null) { - last.num2 += '0.'; + last.num2 = last.num2! + '0.'; } else { if (last.num2?.contains('.') == false) { - last.num2 += '.'; + last.num2 = last.num2! + '.'; } } last.operation = Calculations.MULTIPLY; @@ -241,11 +242,11 @@ class Calculator { return [...items]; } - static List _setClean({String value, List items}) { + static List _setClean({required String value, required List items}) { return []; } - static List _setEqual({String value, List items}) { + static List _setEqual({required String value, required List items}) { if (items.isNotEmpty) { CalcModel last = items.removeLast(); last.operation = Calculations.EQUAL; @@ -254,7 +255,7 @@ class Calculator { return [...items]; } - static List _setMultiply({String value, List items}) { + static List _setMultiply({required String value, required List items}) { if (items.isNotEmpty) { CalcModel last = items.removeLast(); if (last.closed) { @@ -282,7 +283,7 @@ class Calculator { return [...items]; } - static List _setBackward({String value, List items}) { + static List _setBackward({required String value, required List items}) { if (items.isNotEmpty) { items.removeLast(); } diff --git a/lib/widgets/components/calculator/number-display.dart b/lib/widgets/components/calculator/number-display.dart index 09650e6..c0d41ec 100644 --- a/lib/widgets/components/calculator/number-display.dart +++ b/lib/widgets/components/calculator/number-display.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:auto_size_text/auto_size_text.dart'; class NumberDisplay extends StatelessWidget { - NumberDisplay({this.value}); + NumberDisplay({required this.value}); final String value; diff --git a/lib/widgets/dialog_manager.dart b/lib/widgets/dialog_manager.dart index 26dc986..cd3e340 100644 --- a/lib/widgets/dialog_manager.dart +++ b/lib/widgets/dialog_manager.dart @@ -7,16 +7,16 @@ import 'package:flutter/services.dart'; import 'package:mask_text_input_formatter/mask_text_input_formatter.dart'; class DialogManager extends StatefulWidget { - final Widget child; + final Widget? child; - DialogManager({Key key, this.child}) : super(key: key); + DialogManager({Key? key, this.child}) : super(key: key); _DialogManagerState createState() => _DialogManagerState(); } class _DialogManagerState extends State { final DialogService _dialogService = locator(); - TextEditingController _controller; + late TextEditingController _controller; @override void initState() { @@ -33,7 +33,7 @@ class _DialogManagerState extends State { @override Widget build(BuildContext context) { - return widget.child; + return widget.child ?? Container(); } void _showDialog(DialogRequest request) { @@ -59,7 +59,7 @@ class _DialogManagerState extends State { actions: [ if (isConfirmationDialog) FlatButton( - child: Text(request.cancelTitle), + child: Text(request.cancelTitle!), onPressed: () { _dialogService .dialogComplete(DialogResponse(confirmed: false)); @@ -132,7 +132,7 @@ class _DialogManagerState extends State { RaisedButton( color: redColor, child: Text( - request.cancelTitle, + request.cancelTitle!, style: TextStyle(fontSize: 18), ), onPressed: () { @@ -163,7 +163,7 @@ class _DialogManagerState extends State { dialogController.whenComplete(() { //hook when press overlay and response not completed if (_dialogService.completer != null) { - _dialogService.completer.complete(DialogResponse(confirmed: false)); + _dialogService.completer!.complete(DialogResponse(confirmed: false)); } }); } diff --git a/lib/widgets/fields/aman_icon_button.dart b/lib/widgets/fields/aman_icon_button.dart index 852c96a..13270a0 100644 --- a/lib/widgets/fields/aman_icon_button.dart +++ b/lib/widgets/fields/aman_icon_button.dart @@ -11,12 +11,12 @@ class AmanIconButton extends StatefulWidget { final IconData icon; const AmanIconButton( { - @required this.title, + required this.title, this.busy = false, - @required this.onPressed, + required this.onPressed, this.enabled = true, - this.mainColor, - @required this.icon + required this.mainColor, + required this.icon }); @override @@ -29,7 +29,7 @@ class _AmanIconButtonState extends State { return GestureDetector( child: InkWell( borderRadius: BorderRadius.circular(15), - onTap: widget.busy ? () {} : widget.onPressed, + onTap: widget.busy ? () {} : () => widget.onPressed(), child: Container( //height: 75, width: 120, diff --git a/lib/widgets/fields/aman_icon_button_horizontal.dart b/lib/widgets/fields/aman_icon_button_horizontal.dart index 0439709..7464537 100644 --- a/lib/widgets/fields/aman_icon_button_horizontal.dart +++ b/lib/widgets/fields/aman_icon_button_horizontal.dart @@ -10,13 +10,14 @@ class AmanIconButtonHorizontal extends StatefulWidget { final Color inactiveColor; final bool selected; final IconData icon; + const AmanIconButtonHorizontal( - {@required this.title, - this.onPressed, + {required this.title, + required this.onPressed, this.activeColor = primaryColor, this.inactiveColor = Colors.black26, this.selected = false, - @required this.icon}); + required this.icon}); @override _AmanIconButtonHorizontalState createState() => @@ -29,7 +30,7 @@ class _AmanIconButtonHorizontalState extends State { return GestureDetector( child: InkWell( borderRadius: BorderRadius.circular(3), - onTap: widget.onPressed, + onTap: () => widget.onPressed(), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ diff --git a/lib/widgets/fields/busy_button.dart b/lib/widgets/fields/busy_button.dart index 5e5c7d4..38baf7c 100644 --- a/lib/widgets/fields/busy_button.dart +++ b/lib/widgets/fields/busy_button.dart @@ -9,12 +9,12 @@ class BusyButton extends StatefulWidget { final String title; final Function onPressed; final bool enabled; - final Color mainColor; + final Color? mainColor; const BusyButton({ - @required this.title, + required this.title, this.busy = false, - @required this.onPressed, + required this.onPressed, this.enabled = true, this.mainColor, }); @@ -38,7 +38,7 @@ class _BusyButtonState extends State { child: Material( type: MaterialType.transparency, child: InkWell( - onTap: widget.busy || !widget.enabled ? null : widget.onPressed, + onTap: widget.busy || !widget.enabled ? null : () => widget.onPressed(), child: AnimatedContainer( height: widget.busy ? 45 : 45, //width: widget.busy ? 40 : 40, diff --git a/lib/widgets/fields/busy_button_icon.dart b/lib/widgets/fields/busy_button_icon.dart index 6365f2e..bb9ae4b 100644 --- a/lib/widgets/fields/busy_button_icon.dart +++ b/lib/widgets/fields/busy_button_icon.dart @@ -8,16 +8,16 @@ class BusyButtonIcon extends StatefulWidget { final String title; final Function onPressed; final bool enabled; - final Color mainColor; + final Color? mainColor; final IconData icon; const BusyButtonIcon( - {@required this.title, + {required this.title, this.busy = false, - @required this.onPressed, + required this.onPressed, this.enabled = true, this.mainColor, - this.icon}); + required this.icon}); @override _BusyButtonIconState createState() => _BusyButtonIconState(); @@ -38,7 +38,7 @@ class _BusyButtonIconState extends State { child: Material( type: MaterialType.transparency, child: InkWell( - onTap: widget.busy || !widget.enabled ? null : widget.onPressed, + onTap: widget.busy || !widget.enabled ? null : () => widget.onPressed(), child: AnimatedContainer( height: widget.busy ? 45 : 45, //width: widget.busy ? 40 : 40, @@ -68,7 +68,9 @@ class _BusyButtonIconState extends State { Text( widget.title, textAlign: TextAlign.center, - style: widget.enabled ? buttonTitleTextStyle : buttonTitleDisableTextStyle, + style: widget.enabled + ? buttonTitleTextStyle + : buttonTitleDisableTextStyle, maxLines: 1, ), ], diff --git a/lib/widgets/fields/input_field.dart b/lib/widgets/fields/input_field.dart index b1ae4ef..bdf7e45 100644 --- a/lib/widgets/fields/input_field.dart +++ b/lib/widgets/fields/input_field.dart @@ -12,23 +12,23 @@ class InputField extends StatefulWidget { final bool password; final bool isReadOnly; final String placeholder; - final String validationMessage; - final Function enterPressed; + final String? validationMessage; + final Function? enterPressed; final bool smallVersion; - final FocusNode fieldFocusNode; - final FocusNode nextFocusNode; + final FocusNode? fieldFocusNode; + final FocusNode? nextFocusNode; final TextInputAction textInputAction; final bool multiline; - final String additionalNote; - final Function(String) onChanged; - final TextInputFormatter formatter; - final String initialValue; - final String labelText; + final String? additionalNote; + final Function(String)? onChanged; + final TextInputFormatter? formatter; + final String? initialValue; + final String? labelText; InputField( { - this.controller, - @required this.placeholder, + required this.controller, + required this.placeholder, this.enterPressed, this.fieldFocusNode, this.nextFocusNode, @@ -49,7 +49,7 @@ class InputField extends StatefulWidget { } class _InputFieldState extends State { - bool isPassword; + bool isPassword = false; double fieldHeight = 55; @override @@ -63,7 +63,7 @@ class _InputFieldState extends State { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - if (widget.labelText != null) NoteText(widget.labelText), + if (widget.labelText != null) NoteText(widget.labelText!), Container( //height: widget.smallVersion ? 40 : fieldHeight, constraints: BoxConstraints(minHeight: widget.smallVersion ? 40 : fieldHeight), @@ -84,16 +84,16 @@ class _InputFieldState extends State { onChanged: widget.onChanged, initialValue: widget.initialValue, inputFormatters: - widget.formatter != null ? [widget.formatter] : null, + widget.formatter != null ? [widget.formatter!] : null, onEditingComplete: () { if (widget.enterPressed != null) { FocusScope.of(context).requestFocus(FocusNode()); - widget.enterPressed(); + widget.enterPressed!(); } }, onFieldSubmitted: (value) { if (widget.nextFocusNode != null) { - widget.nextFocusNode.requestFocus(); + widget.nextFocusNode!.requestFocus(); } }, obscureText: isPassword, @@ -123,11 +123,11 @@ class _InputFieldState extends State { ), if (widget.validationMessage != null) NoteText( - widget.validationMessage, + widget.validationMessage!, color: Colors.red, ), if (widget.additionalNote != null) verticalSpace(5), - if (widget.additionalNote != null) NoteText(widget.additionalNote), + if (widget.additionalNote != null) NoteText(widget.additionalNote!), verticalSpaceSmall ], ); diff --git a/lib/widgets/fields/note_text.dart b/lib/widgets/fields/note_text.dart index a5d093a..8a8c36b 100644 --- a/lib/widgets/fields/note_text.dart +++ b/lib/widgets/fields/note_text.dart @@ -3,9 +3,9 @@ import 'package:flutter/material.dart'; class NoteText extends StatelessWidget { final String text; - final TextAlign textAlign; - final Color color; - final double fontSize; + final TextAlign? textAlign; + final Color? color; + final double? fontSize; const NoteText(this.text, {this.textAlign, this.color, this.fontSize}); @override diff --git a/lib/widgets/fields/text_link.dart b/lib/widgets/fields/text_link.dart index 22e6e60..240d7fd 100644 --- a/lib/widgets/fields/text_link.dart +++ b/lib/widgets/fields/text_link.dart @@ -3,13 +3,13 @@ import 'package:flutter/material.dart'; class TextLink extends StatelessWidget { final String text; - final Function onPressed; + final Function? onPressed; const TextLink(this.text, {this.onPressed}); @override Widget build(BuildContext context) { return GestureDetector( - onTap: onPressed, + onTap: () => onPressed, child: Text( text, style: TextStyle(fontWeight: FontWeight.w700, fontSize: 14, color: textColor), diff --git a/pubspec.lock b/pubspec.lock index 0f32a75..36d7daf 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,35 +7,28 @@ packages: name: archive url: "https://pub.dartlang.org" source: hosted - version: "2.0.13" - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "1.6.0" + version: "3.1.9" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.1" + version: "2.8.2" auto_size_text: dependency: "direct main" description: name: auto_size_text url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" - barcode_scan: + version: "3.0.0" + barcode_scan2: dependency: "direct main" description: - name: barcode_scan + name: barcode_scan2 url: "https://pub.dartlang.org" source: hosted - version: "3.0.1" + version: "4.2.0" boolean_selector: dependency: transitive description: @@ -49,7 +42,7 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" charcode: dependency: transitive description: @@ -63,7 +56,7 @@ packages: name: charset_converter url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "2.0.0" clock: dependency: transitive description: @@ -78,76 +71,62 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.15.0" - convert: - dependency: transitive - description: - name: convert - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" crypto: dependency: transitive description: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" + version: "3.0.1" csslib: dependency: transitive description: name: csslib url: "https://pub.dartlang.org" source: hosted - version: "0.16.2" + version: "0.17.1" cupertino_icons: dependency: "direct main" description: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "1.0.4" device_info: dependency: "direct main" description: name: device_info url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "2.0.3" device_info_platform_interface: dependency: transitive description: name: device_info_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "2.0.1" equatable: dependency: "direct main" description: name: equatable url: "https://pub.dartlang.org" source: hosted - version: "1.2.6" + version: "2.0.3" esc_pos_bluetooth: dependency: "direct main" description: name: esc_pos_bluetooth url: "https://pub.dartlang.org" source: hosted - version: "0.2.8" + version: "0.4.1" esc_pos_utils: dependency: "direct main" description: name: esc_pos_utils url: "https://pub.dartlang.org" source: hosted - version: "0.3.6" - esys_flutter_share: - dependency: "direct main" - description: - name: esys_flutter_share - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.2" + version: "1.1.0" fake_async: dependency: transitive description: @@ -175,7 +154,7 @@ packages: name: fixnum url: "https://pub.dartlang.org" source: hosted - version: "0.10.11" + version: "1.0.0" flutter: dependency: "direct main" description: flutter @@ -187,35 +166,35 @@ packages: name: flutter_bluetooth_basic url: "https://pub.dartlang.org" source: hosted - version: "0.1.5" + version: "0.1.7" flutter_lock_screen: dependency: "direct main" description: name: flutter_lock_screen url: "https://pub.dartlang.org" source: hosted - version: "1.0.8" + version: "2.0.1" flutter_plugin_android_lifecycle: dependency: transitive description: name: flutter_plugin_android_lifecycle url: "https://pub.dartlang.org" source: hosted - version: "1.0.11" + version: "2.0.5" flutter_redux: dependency: "direct main" description: name: flutter_redux url: "https://pub.dartlang.org" source: hosted - version: "0.7.0" + version: "0.8.2" flutter_screenutil: dependency: "direct main" description: name: flutter_screenutil url: "https://pub.dartlang.org" source: hosted - version: "2.3.1" + version: "5.1.0" flutter_test: dependency: "direct dev" description: flutter @@ -232,63 +211,63 @@ packages: name: gbk_codec url: "https://pub.dartlang.org" source: hosted - version: "0.3.2" + version: "0.4.0" get_it: dependency: "direct main" description: name: get_it url: "https://pub.dartlang.org" source: hosted - version: "5.0.6" + version: "7.2.0" google_fonts: dependency: "direct main" description: name: google_fonts url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "2.2.0" hex: dependency: transitive description: name: hex url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "0.2.0" html: dependency: transitive description: name: html url: "https://pub.dartlang.org" source: hosted - version: "0.14.0+4" + version: "0.15.0" http: dependency: "direct main" description: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.12.2" + version: "0.13.4" http_parser: dependency: transitive description: name: http_parser url: "https://pub.dartlang.org" source: hosted - version: "3.1.4" + version: "4.0.0" image: dependency: transitive description: name: image url: "https://pub.dartlang.org" source: hosted - version: "2.1.19" + version: "3.1.1" intl: dependency: "direct main" description: name: intl url: "https://pub.dartlang.org" source: hosted - version: "0.16.1" + version: "0.17.0" js: dependency: transitive description: @@ -302,42 +281,42 @@ packages: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "3.1.1" + version: "4.4.0" local_auth: dependency: "direct main" description: name: local_auth url: "https://pub.dartlang.org" source: hosted - version: "0.6.3+4" + version: "1.1.10" logger: dependency: "direct main" description: name: logger url: "https://pub.dartlang.org" source: hosted - version: "0.9.4" + version: "1.1.0" mask_text_input_formatter: dependency: "direct main" description: name: mask_text_input_formatter url: "https://pub.dartlang.org" source: hosted - version: "1.2.1" + version: "2.1.0" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10" + version: "0.12.11" material_design_icons_flutter: dependency: "direct main" description: name: material_design_icons_flutter url: "https://pub.dartlang.org" source: hosted - version: "4.0.5955" + version: "5.0.6595" meta: dependency: transitive description: @@ -365,196 +344,217 @@ packages: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "1.6.28" + version: "2.0.8" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.11" + path_provider_ios: + dependency: transitive + description: + name: path_provider_ios + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.7" path_provider_linux: dependency: transitive description: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+2" + version: "2.1.5" path_provider_macos: dependency: transitive description: name: path_provider_macos url: "https://pub.dartlang.org" source: hosted - version: "0.0.4+8" + version: "2.0.5" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "2.0.3" path_provider_windows: dependency: transitive description: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "0.0.5" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.11.1" + version: "2.0.5" permission_handler: dependency: "direct main" description: name: permission_handler url: "https://pub.dartlang.org" source: hosted - version: "5.1.0+2" + version: "8.3.0" permission_handler_platform_interface: dependency: transitive description: name: permission_handler_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "3.7.0" petitparser: dependency: transitive description: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "3.1.0" + version: "4.4.0" platform: dependency: transitive description: name: platform url: "https://pub.dartlang.org" source: hosted - version: "3.0.2" + version: "3.1.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "2.1.2" process: dependency: transitive description: name: process url: "https://pub.dartlang.org" source: hosted - version: "4.2.3" + version: "4.2.4" protobuf: dependency: transitive description: name: protobuf url: "https://pub.dartlang.org" source: hosted - version: "1.1.4" + version: "2.0.1" provider: dependency: "direct main" description: name: provider url: "https://pub.dartlang.org" source: hosted - version: "4.3.3" + version: "6.0.2" qr: dependency: transitive description: name: qr url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "2.1.0" qr_flutter: dependency: "direct main" description: name: qr_flutter url: "https://pub.dartlang.org" source: hosted - version: "3.2.0" + version: "4.0.0" redux: dependency: "direct main" description: name: redux url: "https://pub.dartlang.org" source: hosted - version: "4.0.0+3" + version: "5.0.0" redux_persist: dependency: "direct main" description: name: redux_persist url: "https://pub.dartlang.org" source: hosted - version: "0.8.4" + version: "0.9.0" redux_persist_flutter: dependency: "direct main" description: name: redux_persist_flutter url: "https://pub.dartlang.org" source: hosted - version: "0.8.3" + version: "0.9.0" redux_thunk: dependency: "direct main" description: name: redux_thunk url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.4.0" responsive_builder: dependency: "direct main" description: name: responsive_builder url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.4.1" rxdart: dependency: transitive description: name: rxdart url: "https://pub.dartlang.org" source: hosted - version: "0.23.1" + version: "0.26.0" shared_preferences: dependency: "direct main" description: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "0.5.12+4" + version: "2.0.12" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.10" + shared_preferences_ios: + dependency: transitive + description: + name: shared_preferences_ios + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.9" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux url: "https://pub.dartlang.org" source: hosted - version: "0.0.2+4" + version: "2.0.4" shared_preferences_macos: dependency: transitive description: name: shared_preferences_macos url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+11" + version: "2.0.2" shared_preferences_platform_interface: dependency: transitive description: name: shared_preferences_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "2.0.0" shared_preferences_web: dependency: transitive description: name: shared_preferences_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.2+7" + version: "2.0.3" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows url: "https://pub.dartlang.org" source: hosted - version: "0.0.2+3" + version: "2.0.4" sky_engine: dependency: transitive description: flutter @@ -573,14 +573,14 @@ packages: name: sqflite url: "https://pub.dartlang.org" source: hosted - version: "1.3.2+4" + version: "2.0.2" sqflite_common: dependency: transitive description: name: sqflite_common url: "https://pub.dartlang.org" source: hosted - version: "1.0.3+3" + version: "2.2.0" stack_trace: dependency: transitive description: @@ -608,7 +608,7 @@ packages: name: synchronized url: "https://pub.dartlang.org" source: hosted - version: "2.2.0+2" + version: "3.0.0" term_glyph: dependency: transitive description: @@ -622,7 +622,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.2" + version: "0.4.3" typed_data: dependency: transitive description: @@ -636,70 +636,91 @@ packages: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "5.7.10" + version: "6.0.18" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.14" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.14" url_launcher_linux: dependency: transitive description: name: url_launcher_linux url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+4" + version: "2.0.3" url_launcher_macos: dependency: transitive description: name: url_launcher_macos url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+9" + version: "2.0.3" url_launcher_platform_interface: dependency: transitive description: name: url_launcher_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.9" + version: "2.0.5" url_launcher_web: dependency: transitive description: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.5+3" + version: "2.0.6" url_launcher_windows: dependency: transitive description: name: url_launcher_windows url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+3" + version: "2.0.2" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" + vocsy_esys_flutter_share: + dependency: "direct main" + description: + name: vocsy_esys_flutter_share + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" win32: dependency: transitive description: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.2.9" + version: "2.3.8" xdg_directories: dependency: transitive description: name: xdg_directories url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "0.2.0" xml: dependency: transitive description: name: xml url: "https://pub.dartlang.org" source: hosted - version: "4.5.1" + version: "5.3.1" sdks: - dart: ">=2.13.0 <3.0.0" - flutter: ">=1.22.2" + dart: ">=2.15.0 <3.0.0" + flutter: ">=2.5.0" diff --git a/pubspec.yaml b/pubspec.yaml index 8f8283c..49a1894 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,42 +2,42 @@ name: aman_kassa_flutter description: A new Flutter project. version: 1.2.3+36 environment: - sdk: '>=2.3.0 <3.0.0' + sdk: '>=2.15.0 <3.0.0' dependencies: flutter: sdk: flutter - cupertino_icons: ^0.1.3 - redux: ^4.0.0+3 - flutter_redux: ^0.7.0 - redux_thunk: ^0.3.0 - redux_persist: ^0.8.4 - redux_persist_flutter: ^0.8.3 - responsive_builder: ^0.3.0 - provider: ^4.3.2+4 - logger: ^0.9.4 - get_it: ^5.0.4 - equatable: ^1.2.5 - http: ^0.12.2 - sqflite: ^1.3.2+2 - path_provider: ^1.6.27 - google_fonts: ^1.1.1 - material_design_icons_flutter: ^4.0.5855 - intl: ^0.16.1 - barcode_scan: ^3.0.1 - device_info: ^1.0.0 - esys_flutter_share: ^1.0.2 - auto_size_text: ^2.1.0 - url_launcher: ^5.7.10 - qr_flutter: ^3.2.0 - mask_text_input_formatter: ^1.2.1 - flutter_screenutil: ^2.3.1 - shared_preferences: ^0.5.12+4 - flutter_lock_screen: ^1.0.8 - local_auth: ^0.6.3+4 - esc_pos_bluetooth: ^0.2.8 - esc_pos_utils: ^0.3.6 # no edit for esc_pos_bluetooth: ^0.2.8 - charset_converter: ^1.0.3 - permission_handler: ^5.0.1+2 + cupertino_icons: ^1.0.4 + redux: ^5.0.0 + flutter_redux: ^0.8.2 + redux_thunk: ^0.4.0 + redux_persist: ^0.9.0 + redux_persist_flutter: ^0.9.0 + responsive_builder: ^0.4.1 + provider: ^6.0.2 + logger: ^1.1.0 + get_it: ^7.2.0 + equatable: ^2.0.3 + http: ^0.13.4 + sqflite: ^2.0.2 + path_provider: ^2.0.8 + google_fonts: ^2.2.0 + material_design_icons_flutter: ^5.0.6595 + intl: ^0.17.0 + barcode_scan2: ^4.2.0 + device_info: ^2.0.3 + vocsy_esys_flutter_share: ^1.0.0 + auto_size_text: ^3.0.0 + url_launcher: ^6.0.18 + qr_flutter: ^4.0.0 + mask_text_input_formatter: ^2.1.0 + flutter_screenutil: ^5.1.0 + shared_preferences: ^2.0.12 + flutter_lock_screen: ^2.0.1 + local_auth: ^1.1.10 + esc_pos_bluetooth: ^0.4.1 + esc_pos_utils: ^1.1.0 # no edit for esc_pos_bluetooth: ^0.2.8 + charset_converter: ^2.0.0 + permission_handler: ^8.3.0 dev_dependencies: flutter_test: sdk: flutter