diff --git a/lib/core/base/base_service.dart b/lib/core/base/base_service.dart index fc5dfb0..0b4dc62 100644 --- a/lib/core/base/base_service.dart +++ b/lib/core/base/base_service.dart @@ -3,9 +3,11 @@ import 'package:logger/logger.dart'; import '../utils/logger.dart'; class BaseService { - Logger log; + Logger log = getLogger( + 'BaseService', + ); - 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 e61445d..4ffbf0c 100644 --- a/lib/core/entity/Category.dart +++ b/lib/core/entity/Category.dart @@ -6,11 +6,11 @@ const String CategoryColumnAppCompanyId = 'app_company_id'; const String CategoryColumnUpdatedAt = 'updated_at'; class Category { - int id; - int parentId; - String name; - int appCompanyId; - String updatedAt; + int? id; + int? parentId; + String? name; + int? appCompanyId; + String? updatedAt; Map toMap() { var map = { diff --git a/lib/core/entity/Goods.dart b/lib/core/entity/Goods.dart index 3eccea1..11b1b3e 100644 --- a/lib/core/entity/Goods.dart +++ b/lib/core/entity/Goods.dart @@ -12,17 +12,17 @@ const String GoodColumnUpdatedAt = 'updated_at'; const String GoodColumnAppCompanyId = 'app_company_id'; class Good { - int id; - int categoryId; - String name; - String ean; - int articul; - num price; - num optPrice; - num basePrice; - int divisible; - String updatedAt; - int appCompanyId; + int? id; + int? categoryId; + String? name; + String? ean; + int? articul; + num? price; + num? optPrice; + num? basePrice; + int? divisible; + String? updatedAt; + int? appCompanyId; Map toMap() { var map = { diff --git a/lib/core/entity/Transaction.dart b/lib/core/entity/Transaction.dart index 8c6966a..72e31c0 100644 --- a/lib/core/entity/Transaction.dart +++ b/lib/core/entity/Transaction.dart @@ -14,13 +14,13 @@ const int TransactionStatusPrepare = 0; class Transaction { - int id; - String uuid; - int type; - int status; - String data; - int appCompanyId; - String createdAt; + int? id; + String? uuid; + int? type; + int? status; + String? data; + int? appCompanyId; + String? createdAt; Map toMap() { var map = { diff --git a/lib/core/models/auth/auth_response.dart b/lib/core/models/auth/auth_response.dart index b202386..ebc890d 100644 --- a/lib/core/models/auth/auth_response.dart +++ b/lib/core/models/auth/auth_response.dart @@ -8,17 +8,17 @@ /// operation : true class AuthResponse { - int userId; - int companyId; - int kassaId; - String token; - String authAt; - int shard; - String message; - bool operation; + int? userId; + int? companyId; + int? kassaId; + String? token; + String? authAt; + int? shard; + String? message; + bool? operation; - static AuthResponse fromMap(Map map) { + static AuthResponse? fromMap(Map map) { if (map == null) return null; AuthResponse authResponseBean = AuthResponse(); authResponseBean.userId = map['user_id']; diff --git a/lib/core/models/dialog_models.dart b/lib/core/models/dialog_models.dart index bc7a325..c2f6592 100644 --- a/lib/core/models/dialog_models.dart +++ b/lib/core/models/dialog_models.dart @@ -1,11 +1,11 @@ import 'package:flutter/foundation.dart'; class DialogRequest { - final String title; - final String description; - final String buttonTitle; - final String cancelTitle; - final String formatType; + final String? title; + final String? description; + final String? buttonTitle; + final String? cancelTitle; + final String? formatType; DialogRequest( {@required this.title, @@ -18,8 +18,8 @@ class DialogRequest { class DialogResponse { //final String fieldOne; //final String fieldTwo; - final String responseText; - final bool confirmed; + final String? responseText; + final bool? confirmed; DialogResponse({ //this.fieldOne, diff --git a/lib/core/models/dictionary/category_response.dart b/lib/core/models/dictionary/category_response.dart index cc04da4..86aa2bb 100644 --- a/lib/core/models/dictionary/category_response.dart +++ b/lib/core/models/dictionary/category_response.dart @@ -4,12 +4,12 @@ /// updated_at : "2021-01-06 14:20:47" class CategoryResponse { - int id; - int parentId; - String name; - String updatedAt; + int? id; + int? parentId; + String? name; + String? updatedAt; - static CategoryResponse fromMap(Map map) { + static CategoryResponse? fromMap(Map map) { if (map == null) return null; CategoryResponse categoryResponseBean = CategoryResponse(); categoryResponseBean.id = map['id']; diff --git a/lib/core/models/dictionary/good_response.dart b/lib/core/models/dictionary/good_response.dart index d871cc9..bea75cb 100644 --- a/lib/core/models/dictionary/good_response.dart +++ b/lib/core/models/dictionary/good_response.dart @@ -10,18 +10,18 @@ /// updated_at : "2021-02-03 11:37:34" class GoodResponse { - int id; - int categoryId; - String name; - String ean; - int articul; - int price; - int optPrice; - int basePrice; - int divisible; - String updatedAt; + int? id; + int? categoryId; + String? name; + String? ean; + int? articul; + int? price; + int? optPrice; + int? basePrice; + int? divisible; + String? updatedAt; - static GoodResponse fromMap(Map map) { + static GoodResponse? fromMap(Map map) { if (map == null) return null; GoodResponse goodResponseBean = GoodResponse(); goodResponseBean.id = map['id']; diff --git a/lib/core/models/flow/product_dao.dart b/lib/core/models/flow/product_dao.dart index 78816ea..b103c42 100644 --- a/lib/core/models/flow/product_dao.dart +++ b/lib/core/models/flow/product_dao.dart @@ -1,14 +1,14 @@ class ProductDao { - int id; - int categoryId; - num count; - num price; - String productName; - String categoryName; - String eanCode; - int article; - String excise; - int transactionId; + int? id; + int? categoryId; + num? count; + num? price; + String? productName; + String? categoryName; + String? eanCode; + int? article; + String? excise; + int? transactionId; Map toMap() { diff --git a/lib/core/models/flow/transaction_state.dart b/lib/core/models/flow/transaction_state.dart index cba2a48..73b0f85 100644 --- a/lib/core/models/flow/transaction_state.dart +++ b/lib/core/models/flow/transaction_state.dart @@ -1,3 +1,3 @@ class TransactionState { - String uuid; + String? uuid; } \ No newline at end of file diff --git a/lib/core/models/response.dart b/lib/core/models/response.dart index 22cf2a8..37398b3 100644 --- a/lib/core/models/response.dart +++ b/lib/core/models/response.dart @@ -2,17 +2,16 @@ /// message : "" /// operation : true -class Response { - List list; - String message; - bool operation; +class Response { + List? list; + String? message; + bool? operation; Response(); - factory Response.fromMapList(Map map, Function parser) { - if (map == null) return null; + factory Response.fromMapList(Map map, Function? parser) { - List list = []; + List list = []; if (map['list'] != null) { (map['list'] as List).forEach((element) { if(parser == null) diff --git a/lib/core/redux/actions/sell_actions.dart b/lib/core/redux/actions/sell_actions.dart index 1d47d5b..8b0619e 100644 --- a/lib/core/redux/actions/sell_actions.dart +++ b/lib/core/redux/actions/sell_actions.dart @@ -28,15 +28,15 @@ final Logger log = getLogger('SetSellStateAction'); final DbService _dbService = locator(); -ThunkAction addSellItem({Good good, String excise}) { +ThunkAction addSellItem({required Good good, String? excise}) { return (Store store) async { log.i('addSellItem'); - int appCompanyId = store.state.userState.auth.companyId; - String uuid = store.state.sellState.transactionState.uuid; + int? appCompanyId = store.state.userState!.auth!.companyId; + String? uuid = store.state.sellState!.transactionState!.uuid; - Transaction transaction; + Transaction? transaction; - if (uuid != null && good != null) { + if (uuid != null ) { List> set = await _dbService.queryRowsWithWhere( TransactionTableName, '$TransactionColumnAppCompanyId = ? and $TransactionColumnStatus = ? and ${TransactionColumnType} = ?', @@ -45,7 +45,7 @@ ThunkAction addSellItem({Good good, String excise}) { if (set.isNotEmpty) { for (Map map in set) { Transaction _transaction = Transaction.fromMap(map); - ProductDao _product = ProductDao.fromMap(jsonDecode(_transaction.data)); + ProductDao _product = ProductDao.fromMap(jsonDecode(_transaction.data!)); if (_product.id == good.id && _product.excise == excise) { transaction = _transaction; break; @@ -55,8 +55,8 @@ ThunkAction addSellItem({Good good, String excise}) { } if (transaction != null) { - ProductDao item = ProductDao.fromMap(jsonDecode(transaction.data)); - item..count = item.count + 1; + ProductDao item = ProductDao.fromMap(jsonDecode(transaction.data!)); + item..count = item.count! + 1; transaction.data = jsonEncode(item.toMap()); transaction.createdAt = DateTime.now().toIso8601String(); _dbService.update(TransactionTableName, transaction.toMap()); @@ -100,11 +100,11 @@ ThunkAction addSellItem({Good good, String excise}) { }; } -ThunkAction removeSellItem({int transactionId}) { +ThunkAction removeSellItem({required int transactionId}) { return (Store store) async { - int appCompanyId = store.state.userState.auth.companyId; - String uuid = store.state.sellState.transactionState.uuid; + int? appCompanyId = store.state.userState!.auth!.companyId; + String? uuid = store.state.sellState!.transactionState!.uuid; int count = await _dbService.delete(TransactionTableName, transactionId); log.i('removeSellItem ${count} by transactionId:${transactionId}'); @@ -131,8 +131,8 @@ ThunkAction removeSellItem({int transactionId}) { Future removeAllSellData(Store store) async { try { log.i('removeAllSellData'); - int appCompanyId = store.state.userState.auth.companyId; - String uuid = store.state.sellState.transactionState.uuid; + int? appCompanyId = store.state.userState!.auth!.companyId; + String? uuid = store.state.sellState!.transactionState!.uuid; await _dbService.deleteByWhere( TransactionTableName, '$TransactionColumnAppCompanyId = ? ' @@ -149,18 +149,18 @@ Future removeAllSellData(Store store) async { Future loadSellData(Store store) async { try { log.i('loadSellData'); - int appCompanyId = store.state.userState.auth.companyId; + int? appCompanyId = store.state.userState!.auth!.companyId; List> set = await _dbService.queryRowsWithWhere( TransactionTableName, '$TransactionColumnAppCompanyId = ? and $TransactionColumnStatus = ? and ${TransactionColumnType} = ?', [appCompanyId, TransactionStatusPrepare, TransactionTypeSell], orderBy: '$TransactionColumnCreatedAt desc'); List list = []; - String uuid; + String? uuid; for (Map map in set) { Transaction transaction = Transaction.fromMap(map); uuid = transaction.uuid; - ProductDao productDao = ProductDao.fromMap(jsonDecode(transaction.data)); + ProductDao productDao = ProductDao.fromMap(jsonDecode(transaction.data!)); productDao.transactionId = transaction.id; list.add(productDao); } diff --git a/lib/core/redux/actions/user_actions.dart b/lib/core/redux/actions/user_actions.dart index 57610ee..975b48e 100644 --- a/lib/core/redux/actions/user_actions.dart +++ b/lib/core/redux/actions/user_actions.dart @@ -29,13 +29,13 @@ ThunkAction authenticate(String email, String password) { store.dispatch(SetUserStateAction(UserState(isLoading: true))); try { AuthResponse result = await _api.login(email, password); - if (result.operation) { - _api.token = result.token; + if ( result.operation!) { + _api.token = result.token!; store.dispatch(SetUserStateAction(UserState(isLoading: false, auth: result))); _navigation.replace(MainViewRoute); _afterAuth(store); } else { - _dialogService.showDialog(title: 'Внимание', buttonTitle: 'Ok', description: result.message); + _dialogService.showDialog(title: 'Внимание', buttonTitle: 'Ok', description: result.message!); } } catch (e) { print(e); @@ -48,13 +48,13 @@ ThunkAction authenticate(String email, String password) { Future auth(Store store) async { store.dispatch(SetUserStateAction(UserState(isLoading: true))); try { - UserState state = store.state.userState; - if(state.auth.operation == false) { + UserState? state = store.state.userState; + if(state!.auth!.operation == false) { _navigation.replace(LoginViewRoute); } else { - AuthResponse response = await _api.auth(state.auth.token); - if(response.operation){ - _api.token = response.token; + AuthResponse response = await _api.auth(state.auth!.token!); + if(response.operation!){ + _api.token = response.token!; _navigation.replace(MainViewRoute); _afterAuth(store); } else { @@ -72,12 +72,12 @@ Future logout(Store store) async { store.dispatch(SetUserStateAction(UserState(isLoading: true))); try { AuthResponse result = await _api.logout(); - if (result.operation) { + if (result.operation!) { _api.token = null; store.dispatch(SetUserStateAction(UserState(isLoading: false, auth: AuthResponse()))); _navigation.replace(LoginViewRoute); } else { - _dialogService.showDialog(title: 'Внимание', buttonTitle: 'Ok', description: result.message); + _dialogService.showDialog(title: 'Внимание', buttonTitle: 'Ok', description: result.message!); } } catch (e) { print(e); diff --git a/lib/core/redux/reducers/nav_reducer.dart b/lib/core/redux/reducers/nav_reducer.dart index ca3a000..1cb9b7d 100644 --- a/lib/core/redux/reducers/nav_reducer.dart +++ b/lib/core/redux/reducers/nav_reducer.dart @@ -6,7 +6,7 @@ import 'package:satu/core/redux/state/user_state.dart'; navReducer(NavState prevState, SetNavStateAction action) { final payload = action.navState; return prevState.copyWith( - drawerViewClass: payload.drawerViewClass, - selectedTabIndex: payload.selectedTabIndex, + drawerViewClass: payload.drawerViewClass!, + selectedTabIndex: payload.selectedTabIndex!, ); } diff --git a/lib/core/redux/state/nav_state.dart b/lib/core/redux/state/nav_state.dart index ca30dc1..9b07437 100644 --- a/lib/core/redux/state/nav_state.dart +++ b/lib/core/redux/state/nav_state.dart @@ -3,8 +3,8 @@ import 'package:satu/views/work/work_view.dart'; @immutable class NavState { - final Type drawerViewClass; - final int selectedTabIndex; + final Type? drawerViewClass; + final int? selectedTabIndex; NavState({this.drawerViewClass, this.selectedTabIndex}); @@ -14,8 +14,8 @@ class NavState { ); NavState copyWith({ - @required int selectedTabIndex, - @required Type drawerViewClass, + required int? selectedTabIndex, + required Type? drawerViewClass, }) { return NavState( selectedTabIndex: selectedTabIndex ?? this.selectedTabIndex, diff --git a/lib/core/redux/state/sell_state.dart b/lib/core/redux/state/sell_state.dart index eaf7794..9755875 100644 --- a/lib/core/redux/state/sell_state.dart +++ b/lib/core/redux/state/sell_state.dart @@ -5,8 +5,8 @@ import 'package:satu/core/models/flow/transaction_state.dart'; @immutable class SellState { - final List items; - final TransactionState transactionState; + final List? items; + final TransactionState? transactionState; SellState({this.items, this.transactionState}); @@ -15,7 +15,7 @@ class SellState { transactionState: TransactionState(), ); - SellState copyWith({@required List items, @required TransactionState transactionState}) { + SellState copyWith({required List? items, required TransactionState? transactionState}) { return SellState(items: items ?? this.items, transactionState: transactionState ?? this.transactionState); } } diff --git a/lib/core/redux/state/user_state.dart b/lib/core/redux/state/user_state.dart index 55e167d..9288698 100644 --- a/lib/core/redux/state/user_state.dart +++ b/lib/core/redux/state/user_state.dart @@ -5,9 +5,9 @@ import 'package:satu/core/models/auth/auth_response.dart'; @immutable class UserState { - final bool isError; - final bool isLoading; - final AuthResponse auth; + final bool? isError; + final bool? isLoading; + final AuthResponse? auth; UserState( @@ -16,16 +16,16 @@ class UserState { this.auth, }); - factory UserState.initial(UserState payload) => UserState( + factory UserState.initial(UserState? payload) => UserState( isLoading: false, isError: false, auth: payload?.auth ?? (AuthResponse()..operation=false), ); UserState copyWith({ - @required bool isError, - @required bool isLoading, - @required AuthResponse auth + required bool? isError, + required bool? isLoading, + required AuthResponse? auth }) { return UserState( isError: isError ?? this.isError, @@ -34,7 +34,7 @@ class UserState { ); } - static UserState fromJson(dynamic json) { + static UserState? fromJson(dynamic? json) { return json != null ? UserState( auth: AuthResponse.fromMap(json['auth']), @@ -44,7 +44,7 @@ class UserState { dynamic toJson() { return { - "auth": auth != null ? auth.toJson() : null, + "auth": auth != null ? auth!.toJson() : null, }; } } diff --git a/lib/core/redux/store.dart b/lib/core/redux/store.dart index 68cf624..c668bcb 100644 --- a/lib/core/redux/store.dart +++ b/lib/core/redux/store.dart @@ -20,15 +20,15 @@ import 'actions/user_actions.dart'; AppState appReducer(AppState state, dynamic action) { if (action is SetUserStateAction) { /** UserAction **/ - final nextState = userReducer(state.userState, action); + final nextState = userReducer(state.userState!, action); return state.copyWith(userState: nextState); } else if (action is SetNavStateAction) { /** NavAction **/ - final nextState = navReducer(state.navState, action); + final nextState = navReducer(state.navState!, action); return state.copyWith(navState: nextState); } else if (action is SetSellStateAction) { /** NavAction **/ - final nextState = sellReducer(state.sellState, action); + final nextState = sellReducer(state.sellState!, action); return state.copyWith(sellState: nextState); } return state; @@ -37,9 +37,9 @@ AppState appReducer(AppState state, dynamic action) { //Main State @immutable class AppState { - final UserState userState; - final NavState navState; - final SellState sellState; + final UserState? userState; + final NavState? navState; + final SellState? sellState; AppState({ @@ -50,9 +50,9 @@ class AppState { //stable work AppState copyWith({ - UserState userState, - NavState navState, - SellState sellState, + @required UserState? userState, + @required NavState? navState, + @required SellState? sellState, }) { return AppState( userState: userState ?? this.userState, @@ -61,7 +61,7 @@ class AppState { ); } - static AppState fromJson(dynamic json){ + static AppState? fromJson(dynamic json){ return json !=null ? AppState( userState: UserState.fromJson(json['userState']), @@ -71,15 +71,15 @@ class AppState { dynamic toJson() { return { - "userState" : userState.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 { @@ -96,7 +96,7 @@ class Redux { ); final initialState = await persist.load(); - final userStateInitial = UserState.initial(initialState?.userState); + final userStateInitial = UserState.initial(initialState!.userState!); final navStateInitial = NavState.initial(); final sellStateInitial = SellState.initial(); diff --git a/lib/core/services/api_service.dart b/lib/core/services/api_service.dart index 592f15b..1483e75 100644 --- a/lib/core/services/api_service.dart +++ b/lib/core/services/api_service.dart @@ -14,13 +14,13 @@ class ApiService extends BaseService { var client = new http.Client(); //TOKEN - String _token; + String? _token; - String get token => this._token; + String? get token => this._token; - set token(String value) => this._token = value; + set token(String? value) => this._token = value; - Future _get(String point, {Map requestBody, Map header}) async { + Future _get(String point, {Map? requestBody, Map? header}) async { Map headers = { HttpHeaders.contentTypeHeader: "application/json", HttpHeaders.cacheControlHeader: "no-cache" @@ -33,7 +33,7 @@ class ApiService extends BaseService { return response.body; } - Future _post(String point, {Map requestBody, Map header}) async { + Future _post(String point, {Map? requestBody, Map? header}) async { Map headers = { HttpHeaders.contentTypeHeader: "application/json", HttpHeaders.cacheControlHeader: "no-cache" @@ -55,7 +55,7 @@ class ApiService extends BaseService { AuthResponse result; try { String response = await _post('/login', requestBody: requestBody); - result = AuthResponse.fromMap(json.decode(response)); + result = AuthResponse.fromMap(json.decode(response))!; } catch (e, stack) { log.e("login", e, stack); result = new AuthResponse() @@ -70,7 +70,7 @@ class ApiService extends BaseService { AuthResponse result; try { String response = await _post('/authorization', requestBody: requestBody); - result = AuthResponse.fromMap(json.decode(response)); + result = AuthResponse.fromMap(json.decode(response))!; } catch (e, stack) { log.e("authorization", e, stack); result = new AuthResponse() @@ -85,7 +85,7 @@ class ApiService extends BaseService { AuthResponse result; try { String response = await _post('/auth', header: headers); - result = AuthResponse.fromMap(json.decode(response)); + result = AuthResponse.fromMap(json.decode(response))!; } catch (e, stack) { log.e("auth", e, stack); result = new AuthResponse() @@ -100,7 +100,7 @@ class ApiService extends BaseService { AuthResponse result; try { String response = await _post('/logout', header: headers); - result = AuthResponse.fromMap(json.decode(response)); + result = AuthResponse.fromMap(json.decode(response))!; } catch (e, stack) { log.e("auth", e, stack); result = new AuthResponse() diff --git a/lib/core/services/db_service.dart b/lib/core/services/db_service.dart index ad079d5..eea3c24 100644 --- a/lib/core/services/db_service.dart +++ b/lib/core/services/db_service.dart @@ -18,9 +18,9 @@ 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 { + Future get database async { if (_database != null) return _database; // lazily instantiate the db the first time it is accessed _database = await _initDatabase(); @@ -89,64 +89,64 @@ class DbService extends BaseService { // and the value is the column value. The return value is the id of the // inserted row. Future insert(String table, Map row) async { - Database db = await instance.database; - return await db.insert(table, row); + Database? db = await instance.database; + return await db!.insert(table, row); } // All of the rows are returned as a list of maps, where each map is // a key-value list of columns. Future>> queryAllRows(String table) async { - Database db = await instance.database; - return await db.query(table); + Database? db = await instance.database; + return await db!.query(table); } Future>> queryRaw(String sql, List args) async { - Database db = await instance.database; - return await db.rawQuery(sql, args ); + Database? db = await instance.database; + return await db!.rawQuery(sql, args ); } Future>> queryAllRowsOrderBy(String table, String orderBy) async { - Database db = await instance.database; - return await db.query(table, orderBy: orderBy); + Database? db = await instance.database; + return await db!.query(table, orderBy: orderBy); } Future>> queryRowsWithWhere( - String table, String where, List args, { String orderBy }) async { - Database db = await instance.database; - return await db.query(table, where: where, whereArgs: args, orderBy: orderBy); + String table, String where, List args, { String? orderBy }) async { + Database? db = await instance.database; + return await db!.query(table, where: where, whereArgs: args, orderBy: orderBy); } // 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 { - Database db = await instance.database; + Future queryRowCount(String table) async { + Database? db = await instance.database; return Sqflite.firstIntValue( - await db.rawQuery('SELECT COUNT(*) FROM $table')); + await db!.rawQuery('SELECT COUNT(*) FROM $table')); } // We are assuming here that the id column in the map is set. The other // column values will be used to update the row. Future update(String table, Map row) async { - Database db = await instance.database; + Database? db = await instance.database; int id = row['id']; - return await db.update(table, row, where: 'id = ?', whereArgs: [id]); + return await db!.update(table, row, where: 'id = ?', whereArgs: [id]); } // Deletes the row specified by the id. The number of affected rows is // returned. This should be 1 as long as the row exists. Future delete(String table, int id) async { - Database db = await instance.database; - return await db.delete(table, where: 'id = ?', whereArgs: [id]); + Database? db = await instance.database; + return await db!.delete(table, where: 'id = ?', whereArgs: [id]); } Future deleteAll(String table) async { - Database db = await instance.database; - return await db.delete(table); + Database? db = await instance.database; + return await db!.delete(table); } Future deleteByWhere(String table, String where, List args) async { - Database db = await instance.database; - return await db.delete(table, where: where, whereArgs: args); + Database? db = await instance.database; + return await db!.delete(table, where: where, whereArgs: args); } Future close() async => instance.close(); diff --git a/lib/core/services/dialog_service.dart b/lib/core/services/dialog_service.dart index 12c4f5f..427382c 100644 --- a/lib/core/services/dialog_service.dart +++ b/lib/core/services/dialog_service.dart @@ -5,11 +5,11 @@ import 'package:satu/core/models/dialog_models.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, + 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, + {String? title, + 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, + 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/dictionary_service.dart b/lib/core/services/dictionary_service.dart index 7880c6f..cb69690 100644 --- a/lib/core/services/dictionary_service.dart +++ b/lib/core/services/dictionary_service.dart @@ -24,11 +24,11 @@ class DictionaryService extends BaseService { Future refreshCategory() async { try { - int appCompanyId = Redux.store.state.userState.auth.companyId; + int? appCompanyId = Redux.store!.state.userState!.auth!.companyId; Response categories = await _api.dictionaries('/categories'); - if (categories.operation && categories.list.isNotEmpty) { - for (dynamic map in categories.list) { - CategoryResponse cat = CategoryResponse.fromMap(map); + if (categories.operation! && categories.list!.isNotEmpty) { + for (dynamic map in categories.list!) { + CategoryResponse cat = CategoryResponse.fromMap(map)!; Category entity = new Category() ..id = cat.id ..name = cat.name @@ -46,7 +46,7 @@ class DictionaryService extends BaseService { Future> getCategoryByParentId(int parentId ) async { List list = []; try { - int appCompanyId = Redux.store.state.userState.auth.companyId; + int? appCompanyId = Redux.store!.state.userState!.auth!.companyId; List> elements = await _db.queryRowsWithWhere(CategoryTableName, '$CategoryColumnAppCompanyId = ? and $CategoryColumnParentIn = ?', [appCompanyId, parentId]); elements.forEach((element) { list.add(Category.fromMap(element)); @@ -60,7 +60,7 @@ class DictionaryService extends BaseService { Future> getGoodsByCategoryId(int categoryId ) async { List list = []; try { - int appCompanyId = Redux.store.state.userState.auth.companyId; + int? appCompanyId = Redux.store!.state.userState!.auth!.companyId; List> elements = await _db.queryRowsWithWhere(GoodTableName, '$GoodColumnAppCompanyId = ? and $GoodColumnCategoryId = ?', [appCompanyId, categoryId]); elements.forEach((element) { list.add(Good.fromMap(element)); @@ -74,7 +74,7 @@ class DictionaryService extends BaseService { Future> getGoodsByNameOrEan( String query ) async { List list = []; try { - int appCompanyId = Redux.store.state.userState.auth.companyId; + int? appCompanyId = Redux.store!.state.userState!.auth!.companyId; String where = '( $GoodColumnAppCompanyId = ? and $GoodColumnName like ? ) '; List args = [appCompanyId, '%$query%']; if(_isNumericInt(query)){ @@ -100,11 +100,11 @@ class DictionaryService extends BaseService { Future refreshGood() async { try { - int appCompanyId = Redux.store.state.userState.auth.companyId; + int? appCompanyId = Redux.store!.state.userState!.auth!.companyId; Response categories = await _api.dictionaries('/goods'); - if (categories.operation && categories.list.isNotEmpty) { - for (dynamic map in categories.list) { - GoodResponse good = GoodResponse.fromMap(map); + if (categories.operation! && categories.list!.isNotEmpty) { + for (dynamic map in categories.list!) { + GoodResponse good = GoodResponse.fromMap(map)!; Good entity = new Good() ..id = good.id ..name = good.name diff --git a/lib/core/services/navigator_service.dart b/lib/core/services/navigator_service.dart index cc47dc1..255389d 100644 --- a/lib/core/services/navigator_service.dart +++ b/lib/core/services/navigator_service.dart @@ -8,27 +8,27 @@ class NavigatorService extends BaseService { Future push(String routeName, {dynamic arguments}) { log.d('routeName: $routeName'); - return navigatorKey.currentState + return navigatorKey.currentState! .pushNamed(routeName, arguments: arguments); } Future replace(String routeName, {dynamic arguments}) { log.d('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.d('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.d('navigateToPageWithReplacement: ' 'pageRoute: ${pageRoute.settings.name}'); @@ -36,15 +36,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.d('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/utils/logger.dart b/lib/core/utils/logger.dart index 7d2cba4..de5ee34 100644 --- a/lib/core/utils/logger.dart +++ b/lib/core/utils/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,8 +33,8 @@ class SimpleLogPrinter extends LogPrinter { } } - String formatStackTrace(StackTrace stackTrace, int methodPosition) { - var lines = stackTrace.toString()?.split('\n'); + String? formatStackTrace(StackTrace stackTrace, int methodPosition) { + var lines = stackTrace.toString().split('\n'); var formatted = []; var count = 0; for (var line in lines) { @@ -61,7 +61,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) { @@ -69,8 +69,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/utils/utilsParse.dart b/lib/core/utils/utilsParse.dart index a5d21ea..c5ec54d 100644 --- a/lib/core/utils/utilsParse.dart +++ b/lib/core/utils/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 6d31a7a..c6b3a8d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -34,7 +34,7 @@ class MainApplication extends StatelessWidget { Widget build(BuildContext context) { return StoreProvider( - store: Redux.store, + store: Redux.store!, child: ScreenUtilInit( designSize: Size(411.43, 683.43), builder: () => MaterialApp( @@ -51,7 +51,7 @@ class MainApplication extends StatelessWidget { builder: (context, child) => Navigator( key: locator().dialogNavigationKey, onGenerateRoute: (settings) => MaterialPageRoute( - builder: (context) => DialogManager(child: child)), + builder: (context) => DialogManager(child: child!)), ), navigatorKey: locator().navigatorKey, home: StartUpView(), // first page diff --git a/lib/routes/router.dart b/lib/routes/router.dart index 2a79d80..b818563 100644 --- a/lib/routes/router.dart +++ b/lib/routes/router.dart @@ -14,32 +14,32 @@ Route generateRoute(RouteSettings settings) { case LoginViewRoute: //LoginModel model = settings.arguments as LoginModel; return _getPageRoute( - routeName: settings.name, + routeName: settings.name!, viewToShow: LoginView(), ); case WorkViewRoute: return _getPageRoute( - routeName: settings.name, + routeName: settings.name!, viewToShow: WorkView(), ); case MainViewRoute: return _getPageRoute( - routeName: settings.name, + routeName: settings.name!, viewToShow: MainView(), ); case AddProductViewRoute: return _getPageRoute( - routeName: settings.name, + routeName: settings.name!, viewToShow: AddProductView(), ); case AddByBarcodeViewRoute: return _getPageRoute( - routeName: settings.name, + routeName: settings.name!, viewToShow: AddByBarcodeView(title: 'Scanner',), ); case SettingPrinterBluetoothViewRoute: return _getPageRoute( - routeName: settings.name, + routeName: settings.name!, //viewToShow: PrinterSelectView(title: 'Принтер печати чеков',), ); // case ImageShowRoute: @@ -58,21 +58,21 @@ Route generateRoute(RouteSettings settings) { } } -PageRoute _getPageRoute({String routeName, Widget viewToShow}) { +PageRoute _getPageRoute({String? routeName, Widget? viewToShow}) { return MaterialPageRoute( settings: RouteSettings( name: routeName, ), - builder: (_) => viewToShow); + builder: (_) => viewToShow!); } class SlideRightRoute extends PageRouteBuilder { - final Widget widget; + final Widget? widget; SlideRightRoute({this.widget}) : super( pageBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation) { - return widget; + return widget!; }, transitionsBuilder: (BuildContext context, Animation animation, diff --git a/lib/views/add_by_barcode/add_by_barcode_view.dart b/lib/views/add_by_barcode/add_by_barcode_view.dart index da1d06e..f0db8dd 100644 --- a/lib/views/add_by_barcode/add_by_barcode_view.dart +++ b/lib/views/add_by_barcode/add_by_barcode_view.dart @@ -4,11 +4,11 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; class AddByBarcodeView extends StatefulWidget { - final String title; - final int transactionId; + final String? title; + final int? transactionId; const AddByBarcodeView({ - Key key, + Key? key, this.title, this.transactionId, }) : super(key: key); @@ -30,7 +30,7 @@ class _AddByBarcodeViewState extends State { child: Center( child: Hero( tag: 'text', - child: Text(widget.title)), + child: Text(widget.title ?? '')), ), ); } diff --git a/lib/views/add_product/add_product_view.dart b/lib/views/add_product/add_product_view.dart index 30e0dd5..f01d781 100644 --- a/lib/views/add_product/add_product_view.dart +++ b/lib/views/add_product/add_product_view.dart @@ -22,13 +22,13 @@ class AddProductView extends StatefulWidget { class _AddProductViewState extends State { final DictionaryService _dictionaryService = locator(); final NavigatorService _navigatorService = locator(); - TextEditingController _searchTextController; + late TextEditingController _searchTextController; final FocusNode _searchFocusNode = new FocusNode(); - List _history; - List _categories; - List _goods; + List? _history; + List? _categories; + List? _goods; @override @@ -78,7 +78,7 @@ class _AddProductViewState extends State { itemCount: catSize + goodSize, itemBuilder: (BuildContext context, int index) { if (index < catSize) { - Category category = _categories[index]; + Category category = _categories![index]; return AddCategoryListItem( name: category.name, isOdd: index % 2 == 0, @@ -86,14 +86,14 @@ class _AddProductViewState extends State { onPress: () => onCategoryPress(category), ); } - Good good = _goods[index - catSize]; + Good good = _goods![index - catSize]; return AddProductListItem( key: Key('product_${good.id}'), ean: good.ean, isOdd: index % 2 == 0, name: good.name, price: good.price, - categoryName: _history.last?.name, + categoryName: _history?.last?.name!, onPress: () => onGoodPress(good), ); }, @@ -107,21 +107,21 @@ class _AddProductViewState extends State { } onCategoryPress(Category category) { - _history.add(category); - navigateCategory(category.id); + _history!.add(category); + navigateCategory(category.id!); } onGoodPress(Good good) { - Redux.store.dispatch(addSellItem(good: good)); + Redux.store!.dispatch(addSellItem(good: good)); _navigatorService.pop(); } List actions() { return [ - if(_history.length > 1) + if(_history!.length > 1) FlatButton(onPressed: () { - _history.removeLast(); - navigateCategory(_history.last.id); + _history!.removeLast(); + navigateCategory(_history!.last.id!); }, child: Text('Назад', style: TextStyle(color: Colors.black),),), FlatButton(onPressed: reset, child: Text('Сбросить', style: TextStyle(color: Colors.black),),) diff --git a/lib/views/add_product/component/add_category_list_item.dart b/lib/views/add_product/component/add_category_list_item.dart index 141e6ca..667b59a 100644 --- a/lib/views/add_product/component/add_category_list_item.dart +++ b/lib/views/add_product/component/add_category_list_item.dart @@ -5,17 +5,17 @@ import 'package:satu/shared/shared_styles.dart'; import 'package:satu/shared/ui_helpers.dart'; class AddCategoryListItem extends StatelessWidget { - final String name; - final bool isOdd; - final Function onPress; + final String? name; + final bool? isOdd; + final Function? onPress; - const AddCategoryListItem({Key key, this.name, this.isOdd, this.onPress }) : super(key: key); + const AddCategoryListItem({Key? key, this.name, this.isOdd, this.onPress }) : super(key: key); @override Widget build(BuildContext context) { return Card( child: ListTile( - onTap: onPress, + onTap: () => onPress, contentPadding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0), title: Padding( padding: const EdgeInsets.only(top: 4.0), @@ -23,7 +23,7 @@ class AddCategoryListItem extends StatelessWidget { height: 50, child: Center( child: Text( - name, + name!, style: productTextStyle, overflow: TextOverflow.ellipsis, maxLines: 3, @@ -31,7 +31,7 @@ class AddCategoryListItem extends StatelessWidget { ) ), ), - tileColor: !isOdd ? fillColor : backgroundColor, + tileColor: !isOdd! ? fillColor : backgroundColor, trailing: Icon( Icons.arrow_right, color: yellowColor, diff --git a/lib/views/add_product/component/add_product_list_item.dart b/lib/views/add_product/component/add_product_list_item.dart index f4d1e7f..dee6833 100644 --- a/lib/views/add_product/component/add_product_list_item.dart +++ b/lib/views/add_product/component/add_product_list_item.dart @@ -5,21 +5,21 @@ import 'package:satu/shared/shared_styles.dart'; import 'package:satu/shared/ui_helpers.dart'; class AddProductListItem extends StatelessWidget { - final String name; - final String ean; - final String categoryName; - final num price; - final num count; - final bool isOdd; - final Function onPress; + final String? name; + final String? ean; + final String? categoryName; + final num? price; + final num? count; + final bool? isOdd; + final Function? onPress; - const AddProductListItem({Key key, this.name, this.ean, this.categoryName, this.price, this.count, this.isOdd, this.onPress}) : super(key: key); + const AddProductListItem({Key? key, this.name, this.ean, this.categoryName, this.price, this.count, this.isOdd, this.onPress}) : super(key: key); @override Widget build(BuildContext context) { return Card( child: ListTile( - onTap: onPress, + onTap: () => onPress, contentPadding: const EdgeInsets.symmetric( horizontal: 8.0 ,vertical: 4.0 ), title: Padding( padding: const EdgeInsets.all(4.0), @@ -32,12 +32,12 @@ class AddProductListItem extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(name , style: productTextStyle, overflow: TextOverflow.ellipsis, maxLines: 2,), + Text(name! , style: productTextStyle, overflow: TextOverflow.ellipsis, maxLines: 2,), verticalSpaceTiny, if(ean!=null) Text('Штрих-код: $ean' , style: productSubTextStyle,), if(categoryName!=null) - Text(categoryName, style: productSubTextStyle,), + Text(categoryName!, style: productSubTextStyle,), ], ), ), @@ -54,7 +54,7 @@ class AddProductListItem extends StatelessWidget { ], ), ), - tileColor: !isOdd ? fillColor : backgroundColor, + tileColor: !isOdd! ? fillColor : backgroundColor, ), ); } diff --git a/lib/views/add_product/component/app_bar.dart b/lib/views/add_product/component/app_bar.dart index a983f02..ed24588 100644 --- a/lib/views/add_product/component/app_bar.dart +++ b/lib/views/add_product/component/app_bar.dart @@ -4,14 +4,14 @@ import 'package:satu/core/utils/locator.dart'; import 'package:satu/shared/app_colors.dart'; class AddProductAppBar extends StatelessWidget implements PreferredSizeWidget { - final String title; - final List actions; + final String? title; + final List? actions; - const AddProductAppBar({Key key, this.title, this.actions}) : super(key: key); + const AddProductAppBar({Key? key, this.title, this.actions}) : super(key: key); @override Widget build(BuildContext context) { return AppBar( - title: Text(title, style: const TextStyle(fontWeight: FontWeight.w700, color: Colors.black, fontSize: 25)), + title: Text(title!, style: const TextStyle(fontWeight: FontWeight.w700, color: Colors.black, fontSize: 25)), backgroundColor: Colors.transparent, elevation: 0.0, actions: actions diff --git a/lib/views/login/login_view.dart b/lib/views/login/login_view.dart index 6cf0562..f568e3d 100644 --- a/lib/views/login/login_view.dart +++ b/lib/views/login/login_view.dart @@ -1,9 +1,5 @@ import 'dart:ui'; -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:flutter/services.dart'; import 'package:flutter_redux/flutter_redux.dart'; import 'package:flutter/material.dart'; @@ -26,9 +22,9 @@ class LoginView extends StatefulWidget { } class _LoginViewState extends State { - TextEditingController emailController; + late TextEditingController emailController; - TextEditingController passwordController; + late TextEditingController passwordController; final FocusNode passwordNode = new FocusNode(); @@ -56,7 +52,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, @@ -110,7 +106,7 @@ class _LoginViewState extends State { width: 150, child: BusyButton( title: 'Войти', - busy: vm.isLoading, + busy: vm.isLoading!, onPressed: _pressBtnEnter, mainColor: yellowColor, ), @@ -135,38 +131,38 @@ class _LoginViewState extends State { } _pressBtnEnter() async { - Redux.store.dispatch(authenticate(emailController.text, passwordController.text)); + Redux.store!.dispatch(authenticate(emailController.text, passwordController.text)); } Future scan() async { - try { - var options = ScanOptions(strings: { - "cancel": 'Отмена', - "flash_on": 'Вкл фонарик', - "flash_off": 'Выкл фонарик', - }); - var result = await BarcodeScanner.scan(options: options); - print(result.type); // The result type (barcode, cancelled, failed) - print(result.rawContent); // The barcode content - print(result.format); // The barcode format (as enum) - print(result.formatNote); // If a unknown format was scanned this field contains a note - if (result.type == ResultType.Barcode && result.rawContent?.length == 60) { - //Redux.store.dispatch(authenticateToken(result.rawContent)); - } else if (result.type == ResultType.Error) { - _dialogService.showDialog(description: 'Не верный формат QR кода'); - } - } on PlatformException catch (e) { - var result = ScanResult.create(); - result.type = ResultType.Error; - result.format = BarcodeFormat.unknown; - if (e.code == BarcodeScanner.cameraAccessDenied) { - result.rawContent = 'The user did not grant the camera permission!'; - _dialogService.showDialog(description: 'Нет доступа до камеры устройства'); - } else { - result.rawContent = 'Unknown error: $e'; - _dialogService.showDialog(description: 'Неизвестная ошибка: $e'); - } - } + // try { + // var options = ScanOptions(strings: { + // "cancel": 'Отмена', + // "flash_on": 'Вкл фонарик', + // "flash_off": 'Выкл фонарик', + // }); + // var result = await BarcodeScanner.scan(options: options); + // print(result.type); // The result type (barcode, cancelled, failed) + // print(result.rawContent); // The barcode content + // print(result.format); // The barcode format (as enum) + // print(result.formatNote); // If a unknown format was scanned this field contains a note + // if (result.type == ResultType.Barcode && result.rawContent?.length == 60) { + // //Redux.store.dispatch(authenticateToken(result.rawContent)); + // } else if (result.type == ResultType.Error) { + // _dialogService.showDialog(description: 'Не верный формат QR кода'); + // } + // } on PlatformException catch (e) { + // var result = ScanResult.create(); + // result.type = ResultType.Error; + // result.format = BarcodeFormat.unknown; + // if (e.code == BarcodeScanner.cameraAccessDenied) { + // result.rawContent = 'The user did not grant the camera permission!'; + // _dialogService.showDialog(description: 'Нет доступа до камеры устройства'); + // } else { + // result.rawContent = 'Unknown error: $e'; + // _dialogService.showDialog(description: 'Неизвестная ошибка: $e'); + // } + // } } } @@ -175,5 +171,5 @@ class LoginModel { final String login; final String password; - LoginModel({this.authType, this.login, this.password}); + LoginModel({required this.authType, required this.login, required this.password}); } diff --git a/lib/views/main/main_view.dart b/lib/views/main/main_view.dart index 177bba2..5665314 100644 --- a/lib/views/main/main_view.dart +++ b/lib/views/main/main_view.dart @@ -37,9 +37,9 @@ class _MainViewState extends State { key: _navigatorService.scaffoldDrawerKey, drawer: AppDrawer(), body: StoreConnector( - converter: (store) => store.state.navState, + converter: (store) => store.state.navState!, builder: (_, vm) { - return _body(vm.drawerViewClass); + return _body(vm.drawerViewClass!); }) ); } diff --git a/lib/views/settings/component/setting_item.dart b/lib/views/settings/component/setting_item.dart index 3445e90..6680f5d 100644 --- a/lib/views/settings/component/setting_item.dart +++ b/lib/views/settings/component/setting_item.dart @@ -2,11 +2,11 @@ import 'package:flutter/material.dart'; class SettingItem extends StatefulWidget { - final String name; - final String value; - final Function onTap; + final String? name; + final String? value; + final Function? onTap; - SettingItem({Key key, this.name, this.value, this.onTap}) : super(key: key); + SettingItem({Key? key, this.name, this.value, this.onTap}) : super(key: key); @override _SettingItemState createState() => _SettingItemState(); @@ -17,10 +17,10 @@ class _SettingItemState extends State { Widget build(BuildContext context) { return Card( child: ListTile( - title: Text(widget.name), - subtitle: widget.value !=null ? Text(widget.value) : null, + title: Text(widget.name ?? ''), + subtitle: widget.value !=null ? Text(widget.value ?? '') : null, trailing: Icon(Icons.chevron_right), - onTap: widget.onTap, + onTap: () => widget.onTap, ), ); } diff --git a/lib/views/start_up/start_up_view.dart b/lib/views/start_up/start_up_view.dart index f731ee5..6177e9c 100644 --- a/lib/views/start_up/start_up_view.dart +++ b/lib/views/start_up/start_up_view.dart @@ -30,7 +30,7 @@ class _StartUpViewState extends State { @override Widget build(BuildContext context) { return StoreConnector( - converter: (store) => store.state.userState, + converter: (store) => store.state.userState!, builder: (context, userState) { return Scaffold( body: Center( @@ -56,6 +56,6 @@ class _StartUpViewState extends State { void redirect() async { await Future.delayed(Duration(milliseconds: 100)); - Redux.store.dispatch(auth); + Redux.store!.dispatch(auth); } } diff --git a/lib/views/work/tabs/component/custom_field.dart b/lib/views/work/tabs/component/custom_field.dart index ab3a74b..4d2c7df 100644 --- a/lib/views/work/tabs/component/custom_field.dart +++ b/lib/views/work/tabs/component/custom_field.dart @@ -2,9 +2,9 @@ import 'package:flutter/material.dart'; class CustomField extends StatelessWidget { - final String hintText; - final IconData iconData; - final String label; + final String? hintText; + final IconData? iconData; + final String? label; CustomField({@required this.hintText, @required this.iconData, this.label}); diff --git a/lib/views/work/tabs/component/option_pill.dart b/lib/views/work/tabs/component/option_pill.dart index 551dc5b..5649a44 100644 --- a/lib/views/work/tabs/component/option_pill.dart +++ b/lib/views/work/tabs/component/option_pill.dart @@ -6,7 +6,7 @@ class OptionPill extends StatelessWidget { final String text; final bool selected; - OptionPill({@required this.text, @required this.selected}); + OptionPill({required this.text, required this.selected}); @override Widget build(BuildContext context) { diff --git a/lib/views/work/tabs/component/product_list_item.dart b/lib/views/work/tabs/component/product_list_item.dart index 6531b28..f030d32 100644 --- a/lib/views/work/tabs/component/product_list_item.dart +++ b/lib/views/work/tabs/component/product_list_item.dart @@ -11,16 +11,16 @@ import 'package:satu/shared/ui_helpers.dart'; import 'package:satu/views/add_by_barcode/add_by_barcode_view.dart'; class ProductListItem extends StatefulWidget { - final String name; - final String ean; - final String categoryName; - final num price; - final num count; - final bool isOdd; - final int transactionId; + final String? name; + final String? ean; + final String? categoryName; + final num? price; + final num? count; + final bool? isOdd; + final int? transactionId; const ProductListItem( - {Key key, this.name, this.ean, this.categoryName, this.price, this.count, this.isOdd, this.transactionId}) + {Key? key, this.name, this.ean, this.categoryName, this.price, this.count, this.isOdd, this.transactionId}) : super(key: key); @override @@ -73,9 +73,9 @@ class _ProductListItemState extends State { }, onDismissed: (direction) { print(direction); - Redux.store.dispatch(removeSellItem(transactionId: this.widget.transactionId)); + Redux.store!.dispatch(removeSellItem(transactionId: this.widget.transactionId!)); }, - key: Key(widget.name), + key: Key(widget.name ?? ''), child: ListTile( onTap: () => _onItemTapped(context), contentPadding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 4.0), @@ -91,7 +91,7 @@ class _ProductListItemState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - widget.name, + widget.name ?? '', style: const TextStyle(fontWeight: FontWeight.w500), overflow: TextOverflow.ellipsis, maxLines: 2, @@ -127,7 +127,7 @@ class _ProductListItemState extends State { ], ), ), - tileColor: !widget.isOdd ? fillColor : backgroundColor, + tileColor: !widget.isOdd! ? fillColor : backgroundColor, ), ); } diff --git a/lib/views/work/tabs/component/products_app_bar.dart b/lib/views/work/tabs/component/products_app_bar.dart index 57f551d..3db68ab 100644 --- a/lib/views/work/tabs/component/products_app_bar.dart +++ b/lib/views/work/tabs/component/products_app_bar.dart @@ -5,14 +5,14 @@ import 'package:satu/shared/app_colors.dart'; import 'package:satu/views/work/tabs/component/products_header_bar.dart'; class ProductsAppBar extends StatelessWidget implements PreferredSizeWidget { - final String title; - final List actions; - final Widget child; - final int childHeight; - final num elevation; - final Color backgroundColor; + final String? title; + final List? actions; + final Widget? child; + final int? childHeight; + final double elevation; + final Color? backgroundColor; - const ProductsAppBar({Key key, this.title, this.actions, this.child,this.childHeight = 0, this.elevation = 0.0, this.backgroundColor = Colors.transparent }) : super(key: key); + const ProductsAppBar({Key? key, this.title, this.actions, this.child,this.childHeight = 0, this.elevation = 0.0, this.backgroundColor = Colors.transparent }) : super(key: key); @override Widget build(BuildContext context) { return Material( @@ -21,20 +21,20 @@ class ProductsAppBar extends StatelessWidget implements PreferredSizeWidget { child: Column( children: [ AppBar( - title: Text(title), + title: Text(title ?? ''), backgroundColor: Colors.transparent, elevation: 0.0, leading: IconButton( icon: Icon(Icons.menu, color: yellowColor,), onPressed: () { - locator().scaffoldDrawerKey.currentState.openDrawer(); + locator().scaffoldDrawerKey.currentState!.openDrawer(); }, ), actions: actions , ), - if(child !=null && childHeight > 0) - child, + if(child !=null && childHeight! > 0) + child!, ], ), ); @@ -42,6 +42,6 @@ class ProductsAppBar extends StatelessWidget implements PreferredSizeWidget { @override Size get preferredSize { - return new Size.fromHeight(60.0 + childHeight); + return new Size.fromHeight(60.0 + childHeight!); } } diff --git a/lib/views/work/tabs/component/products_header_bar.dart b/lib/views/work/tabs/component/products_header_bar.dart index c278a5f..c2d8255 100644 --- a/lib/views/work/tabs/component/products_header_bar.dart +++ b/lib/views/work/tabs/component/products_header_bar.dart @@ -2,13 +2,13 @@ import 'package:flutter/material.dart'; import 'package:satu/shared/app_colors.dart'; import 'package:satu/shared/shared_styles.dart'; import 'package:satu/widgets/dialog/modal_select_dialog.dart'; -import 'package:searchable_dropdown/searchable_dropdown.dart'; + class ProductHeaderBar extends StatelessWidget { final int count; final num sum; - const ProductHeaderBar({Key key, this.count, this.sum}) : super(key: key); + const ProductHeaderBar({Key? key, required this.count, required this.sum}) : super(key: key); @override Widget build(BuildContext context) { @@ -37,20 +37,21 @@ class ProductHeaderBar extends StatelessWidget { showDialog( context: context, builder: (BuildContext context) { - return DropdownDialog( - dialogBox: true, - multipleSelection: false, - items: ['Частное лицо', 'ИП Иванов', 'ТО "Рога и копыта"', 'Network Energy'] - .map>((String value) { - return DropdownMenuItem( - value: value, - child: Text(value), - ); - }).toList(), - selectedItems: selected, - hint: Text('Выберите контрагента'), - closeButton: 'Отмена', - ); + return Container(); + // return DropdownDialog( + // dialogBox: true, + // multipleSelection: false, + // items: ['Частное лицо', 'ИП Иванов', 'ТО "Рога и копыта"', 'Network Energy'] + // .map>((String value) { + // return DropdownMenuItem( + // value: value, + // child: Text(value), + // ); + // }).toList(), + // selectedItems: selected, + // hint: Text('Выберите контрагента'), + // closeButton: 'Отмена', + // ); }).then((value) => { print(selected) }); diff --git a/lib/views/work/tabs/component/transaction_item.dart b/lib/views/work/tabs/component/transaction_item.dart index b62f1d3..3a671a4 100644 --- a/lib/views/work/tabs/component/transaction_item.dart +++ b/lib/views/work/tabs/component/transaction_item.dart @@ -7,7 +7,7 @@ class TransactionItem extends StatelessWidget { final String amount; final bool received; - TransactionItem({@required this.fullName, @required this.status, @required this.amount, @required this.received}); + TransactionItem({required this.fullName, required this.status, required this.amount, required this.received}); @override Widget build(BuildContext context) { diff --git a/lib/views/work/tabs/sell_view.dart b/lib/views/work/tabs/sell_view.dart index 9c258d3..5ce57f8 100644 --- a/lib/views/work/tabs/sell_view.dart +++ b/lib/views/work/tabs/sell_view.dart @@ -22,7 +22,7 @@ class SellView extends StatelessWidget { @override Widget build(BuildContext context) { return StoreConnector( - converter: (store) => store.state.sellState, + converter: (store) => store.state.sellState!, builder: (_, state) { return Scaffold( appBar: ProductsAppBar( @@ -30,17 +30,17 @@ class SellView extends StatelessWidget { actions: actions(), elevation: 2.0, child: ProductHeaderBar( - count: state.items.length, - sum: sumProducts(state.items), + count: state.items!.length, + sum: sumProducts(state.items!), ), backgroundColor: backgroundColor, childHeight: 80, ), body: ListView.builder( physics: BouncingScrollPhysics(), - itemCount: state.items.length, + itemCount: state.items!.length, itemBuilder: (BuildContext context, int index) { - ProductDao product = state.items.elementAt(index); + ProductDao product = state.items!.elementAt(index); return ProductListItem( key: UniqueKey(), ean: product.eanCode, @@ -61,7 +61,7 @@ class SellView extends StatelessWidget { Widget floatingActionButtonRender() { return StoreConnector( - converter: (store) => store.state.sellState, + converter: (store) => store.state.sellState!, builder: (_, snapshot) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 16.0), @@ -70,7 +70,7 @@ class SellView extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.end, children: [ Visibility( - visible: snapshot.items.isNotEmpty, + visible: snapshot.items!.isNotEmpty, child: FloatingActionButton( elevation: 2, backgroundColor: greenColor, @@ -111,7 +111,7 @@ class SellView extends StatelessWidget { child: IconButton( icon: Icon(Icons.delete, size: 30.0, color: yellowColor), onPressed: () { - Redux.store.dispatch(removeAllSellData); + Redux.store!.dispatch(removeAllSellData); }), ) ]; diff --git a/lib/views/work/tabs/utils/ProductUtils.dart b/lib/views/work/tabs/utils/ProductUtils.dart index 1ea28c7..bb24851 100644 --- a/lib/views/work/tabs/utils/ProductUtils.dart +++ b/lib/views/work/tabs/utils/ProductUtils.dart @@ -4,7 +4,7 @@ num sumProducts(List list) { num result = 0.0; if (list.isNotEmpty) { list.forEach((product) { - result += (product.price * product.count); + result += (product.price! * product.count!); }); } diff --git a/lib/views/work/work_view.dart b/lib/views/work/work_view.dart index 33a249e..a69c0f9 100644 --- a/lib/views/work/work_view.dart +++ b/lib/views/work/work_view.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; + import 'package:satu/core/redux/actions/sell_actions.dart'; import 'package:satu/core/redux/store.dart'; import 'package:satu/shared/app_colors.dart'; @@ -8,9 +9,9 @@ import 'package:satu/views/work/tabs/journal_view.dart'; import 'package:satu/views/work/tabs/sell_view.dart'; class WorkView extends StatefulWidget { - final String text; + final String? text; - const WorkView({Key key, this.text}) : super(key: key); + const WorkView({Key? key, this.text}) : super(key: key); @override _WorkViewState createState() => _WorkViewState(); } @@ -30,7 +31,7 @@ class _WorkViewState extends State { void initState() { super.initState(); // state sell view - Redux.store.dispatch(loadSellData); + Redux.store!.dispatch(loadSellData); } void _onItemTapped(int index) { diff --git a/lib/widgets/buttons/aman_icon_button.dart b/lib/widgets/buttons/aman_icon_button.dart index 2d17a3f..8fcb71b 100644 --- a/lib/widgets/buttons/aman_icon_button.dart +++ b/lib/widgets/buttons/aman_icon_button.dart @@ -8,17 +8,17 @@ class AmanIconButton extends StatefulWidget { final bool busy; final String title; final Function onPressed; - final bool enabled; + final bool? enabled; final Color mainColor; 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 @@ -31,7 +31,11 @@ class _AmanIconButtonState extends State { return GestureDetector( child: InkWell( borderRadius: BorderRadius.circular(6), - onTap: widget.busy ? () {} : widget.onPressed, + onTap: () { + if(!widget.busy) { + widget.onPressed(); + } + }, child: Container( //height: 75, width: 120, diff --git a/lib/widgets/buttons/busy_button.dart b/lib/widgets/buttons/busy_button.dart index 046c7ea..02712da 100644 --- a/lib/widgets/buttons/busy_button.dart +++ b/lib/widgets/buttons/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,10 @@ class _BusyButtonState extends State { child: Material( type: MaterialType.transparency, child: InkWell( - onTap: widget.busy || !widget.enabled ? null : widget.onPressed, + onTap: () { + if(!(widget.busy || !widget.enabled)) + widget.onPressed(); + }, child: AnimatedContainer( height: widget.busy ? 45 : 45, //width: widget.busy ? 40 : 40, diff --git a/lib/widgets/dialog/dialog_manager.dart b/lib/widgets/dialog/dialog_manager.dart index df319da..f597ba9 100644 --- a/lib/widgets/dialog/dialog_manager.dart +++ b/lib/widgets/dialog/dialog_manager.dart @@ -8,14 +8,14 @@ import 'package:satu/core/utils/locator.dart'; class DialogManager extends StatefulWidget { final Widget child; - DialogManager({Key key, this.child}) : super(key: key); + DialogManager({Key? key, required this.child}) : super(key: key); _DialogManagerState createState() => _DialogManagerState(); } class _DialogManagerState extends State { final DialogService _dialogService = locator(); - TextEditingController _controller; + late TextEditingController _controller; @override void initState() { @@ -48,24 +48,24 @@ class _DialogManagerState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - request.title, + request.title!, style: TextStyle(fontWeight: FontWeight.bold), ), //Divider(), ], ), - content: Text(request.description), + content: Text(request.description!), actions: [ if (isConfirmationDialog) FlatButton( - child: Text(request.cancelTitle), + child: Text(request.cancelTitle!), onPressed: () { _dialogService .dialogComplete(DialogResponse(confirmed: false)); }, ), FlatButton( - child: Text(request.buttonTitle), + child: Text(request.buttonTitle!), onPressed: () { _dialogService .dialogComplete(DialogResponse(confirmed: true)); @@ -95,7 +95,7 @@ class _DialogManagerState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - request.title, + request.title!, style: TextStyle(fontWeight: FontWeight.bold), ), //Divider(), @@ -131,7 +131,7 @@ class _DialogManagerState extends State { RaisedButton( //color: redColor, child: Text( - request.cancelTitle, + request.cancelTitle!, style: TextStyle(fontSize: 18), ), onPressed: () { @@ -145,7 +145,7 @@ class _DialogManagerState extends State { RaisedButton( //color: primaryColor, child: Text( - request.buttonTitle, + request.buttonTitle!, style: TextStyle(fontSize: 18), ), onPressed: () { @@ -162,7 +162,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/dialog/modal_select_dialog.dart b/lib/widgets/dialog/modal_select_dialog.dart index f5d3120..e4b9eae 100644 --- a/lib/widgets/dialog/modal_select_dialog.dart +++ b/lib/widgets/dialog/modal_select_dialog.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; class DialogModalSelect extends StatefulWidget { - final String title; - final String descriptions; - final String text; + final String? title; + final String? descriptions; + final String? text; - const DialogModalSelect({Key key, this.title, this.descriptions, this.text}) + const DialogModalSelect({Key? key, this.title, this.descriptions, this.text}) : super(key: key); @override @@ -50,14 +50,14 @@ class _DialogModalSelectState extends State { mainAxisSize: MainAxisSize.min, children: [ Text( - widget.title, + widget.title ?? '', style: TextStyle(fontSize: 22, fontWeight: FontWeight.w600), ), SizedBox( height: 15, ), Text( - widget.descriptions, + widget.descriptions ?? '', style: TextStyle(fontSize: 14), textAlign: TextAlign.center, ), @@ -71,7 +71,7 @@ class _DialogModalSelectState extends State { Navigator.of(context).pop(); }, child: Text( - widget.text, + widget.text ?? '', style: TextStyle(fontSize: 18), )), ), diff --git a/lib/widgets/drawer/app_drawer.dart b/lib/widgets/drawer/app_drawer.dart index 898138b..4e39c07 100644 --- a/lib/widgets/drawer/app_drawer.dart +++ b/lib/widgets/drawer/app_drawer.dart @@ -3,8 +3,7 @@ import 'package:flutter/material.dart'; import 'package:satu/core/redux/actions/nav_actions.dart'; import 'package:satu/core/redux/actions/user_actions.dart'; import 'package:satu/core/redux/store.dart'; -import 'package:satu/core/services/api_service.dart'; -import 'package:satu/core/utils/locator.dart'; + import 'package:satu/shared/app_colors.dart'; import 'package:satu/shared/ui_helpers.dart'; import 'package:satu/views/settings/setting_view.dart'; @@ -20,7 +19,7 @@ class AppDrawer extends StatelessWidget { _createHeader(), _createDrawerItem(icon: Icons.contacts, text: 'Касса', onTap: () { Navigator.of(context).pop(); - Redux.store.dispatch(navigateDrawer(WorkView)); + Redux.store!.dispatch(navigateDrawer(WorkView)); }), Divider(), ExpansionTile( @@ -49,13 +48,13 @@ class AppDrawer extends StatelessWidget { ), _createDrawerItem(icon: Icons.settings, text: 'Настройки', onTap: () { Navigator.of(context).pop(); - Redux.store.dispatch(navigateDrawer(SettingsView)); + Redux.store!.dispatch(navigateDrawer(SettingsView)); }), Divider(), _createDrawerItem(icon: Icons.bug_report, text: 'Сообщить об ошибке'), verticalSpaceMedium, _createDrawerItem(icon: Icons.exit_to_app, text: 'Выйти из аккаунта', onTap: () async { - Redux.store.dispatch(logout); + Redux.store!.dispatch(logout); }), ListTile( title: Text('0.0.1'), @@ -91,7 +90,7 @@ class AppDrawer extends StatelessWidget { } Widget _createDrawerItem( - {IconData icon, String text, GestureTapCallback onTap}) { + {required IconData icon, required String text, GestureTapCallback? onTap}) { return ListTile( title: Row( children: [ diff --git a/lib/widgets/fields/dropdown_field.dart b/lib/widgets/fields/dropdown_field.dart index 9bd0c40..ca528c9 100644 --- a/lib/widgets/fields/dropdown_field.dart +++ b/lib/widgets/fields/dropdown_field.dart @@ -3,25 +3,25 @@ import 'package:flutter/services.dart'; import 'package:satu/shared/app_colors.dart'; import 'package:satu/shared/shared_styles.dart'; import 'package:satu/shared/ui_helpers.dart'; -import 'package:searchable_dropdown/searchable_dropdown.dart'; + import 'note_text.dart'; class DropDownField extends StatefulWidget { final bool isReadOnly; final String placeholder; - final String validationMessage; + final String? validationMessage; final bool smallVersion; - final FocusNode fieldFocusNode; - final FocusNode nextFocusNode; - final String additionalNote; - final Function(String) onChanged; - final String initialValue; - final String labelText; + final FocusNode? fieldFocusNode; + final FocusNode? nextFocusNode; + final String? additionalNote; + final Function(String)? onChanged; + final String? initialValue; + final String? labelText; DropDownField( { - @required this.placeholder, + required this.placeholder, this.fieldFocusNode, this.nextFocusNode, this.additionalNote, @@ -48,7 +48,7 @@ class _DropDownFieldState 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), @@ -56,39 +56,39 @@ class _DropDownFieldState extends State { padding: fieldPadding, decoration: widget.isReadOnly ? disabledFieldDecoration : fieldDecoration, child: Expanded( - child: - SearchableDropdown.single( - items: ['Частное лицо', 'ИП Иванов', 'ТО "Рога и копыта"', 'Network Energy'] - .map>((String value) { - return DropdownMenuItem( - value: value, - child: Text(value), - ); - }).toList(), - value: widget.initialValue, - readOnly: widget.isReadOnly, - hint: "Контрагент", - searchHint: "Укажите контрагента", - underline: Container( - height: 1.0, - decoration: BoxDecoration( - border: Border(bottom: BorderSide(color: yellowColor, width: 3.0)) - ), - ), - onChanged: (value) { - print(value); - }, - isExpanded: true, - ), + child: Container() + // SearchableDropdown.single( + // items: ['Частное лицо', 'ИП Иванов', 'ТО "Рога и копыта"', 'Network Energy'] + // .map>((String value) { + // return DropdownMenuItem( + // value: value, + // child: Text(value), + // ); + // }).toList(), + // value: widget.initialValue, + // readOnly: widget.isReadOnly, + // hint: "Контрагент", + // searchHint: "Укажите контрагента", + // underline: Container( + // height: 1.0, + // decoration: BoxDecoration( + // border: Border(bottom: BorderSide(color: yellowColor, width: 3.0)) + // ), + // ), + // onChanged: (value) { + // print(value); + // }, + // isExpanded: true, + // ), ), ), 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/input_field.dart b/lib/widgets/fields/input_field.dart index d784892..0c9ad9d 100644 --- a/lib/widgets/fields/input_field.dart +++ b/lib/widgets/fields/input_field.dart @@ -13,23 +13,23 @@ class InputField extends StatefulWidget { final bool search; 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, @@ -51,8 +51,8 @@ class InputField extends StatefulWidget { } class _InputFieldState extends State { - bool isPassword; - bool isSearch; + late bool isPassword; + late bool isSearch; double fieldHeight = 55; @override @@ -61,8 +61,8 @@ class _InputFieldState extends State { isPassword = widget.password; isSearch = widget.search; if(widget.search == true) { - widget.fieldFocusNode.addListener(() { - if(widget.fieldFocusNode.hasFocus){ + widget.fieldFocusNode!.addListener(() { + if(widget.fieldFocusNode!.hasFocus){ setState(() { isSearch = !isSearch; }); @@ -76,7 +76,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), @@ -97,16 +97,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, @@ -137,10 +137,10 @@ class _InputFieldState extends State { GestureDetector( onTap: () { if(isSearch) { - widget.fieldFocusNode.requestFocus(); + widget.fieldFocusNode!.requestFocus(); } else { FocusScope.of(context).requestFocus(new FocusNode()); //remove focus - WidgetsBinding.instance.addPostFrameCallback((_) => widget.controller.clear()); // clear content + WidgetsBinding.instance!.addPostFrameCallback((_) => widget.controller.clear()); // clear content } setState(() { isSearch = !isSearch; @@ -161,11 +161,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 50e8d3c..6a7f99e 100644 --- a/lib/widgets/fields/note_text.dart +++ b/lib/widgets/fields/note_text.dart @@ -3,9 +3,9 @@ import 'package:satu/shared/app_colors.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/pubspec.lock b/pubspec.lock index 079616b..8683275 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,41 +1,20 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - archive: - dependency: transitive - description: - 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" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.6.1" auto_size_text: dependency: "direct main" description: name: auto_size_text url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" - barcode_scan: - dependency: "direct main" - description: - name: barcode_scan - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.1" + version: "3.0.0-nullsafety.0" boolean_selector: dependency: transitive description: @@ -78,62 +57,41 @@ 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" - csslib: - dependency: transitive - description: - name: csslib - url: "https://pub.dartlang.org" - source: hosted - version: "0.16.2" + version: "3.0.1" cupertino_icons: dependency: "direct main" description: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "1.0.3" device_info: dependency: "direct main" description: name: device_info url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" device_info_platform_interface: dependency: transitive description: name: device_info_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.1" equatable: dependency: "direct main" description: name: equatable url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" - esc_pos_utils: - dependency: "direct main" - description: - name: esc_pos_utils - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.0" + version: "2.0.3" fake_async: dependency: transitive description: @@ -147,21 +105,14 @@ packages: name: ffi url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.2" file: dependency: transitive description: name: file url: "https://pub.dartlang.org" source: hosted - version: "6.1.0" - fixnum: - dependency: transitive - description: - name: fixnum - url: "https://pub.dartlang.org" - source: hosted - version: "0.10.11" + version: "6.1.2" flutter: dependency: "direct main" description: flutter @@ -180,7 +131,7 @@ packages: name: flutter_screenutil url: "https://pub.dartlang.org" source: hosted - version: "5.0.0" + version: "5.0.0+2" flutter_test: dependency: "direct dev" description: flutter @@ -191,34 +142,13 @@ packages: description: flutter source: sdk version: "0.0.0" - gbk_codec: - dependency: transitive - description: - name: gbk_codec - url: "https://pub.dartlang.org" - source: hosted - version: "0.3.2" get_it: dependency: "direct main" description: name: get_it url: "https://pub.dartlang.org" source: hosted - version: "7.1.2" - hex: - dependency: transitive - description: - name: hex - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.2" - html: - dependency: transitive - description: - name: html - url: "https://pub.dartlang.org" - source: hosted - version: "0.14.0+4" + version: "7.1.3" http: dependency: "direct main" description: @@ -233,13 +163,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.0.0" - image: - dependency: transitive - description: - name: image - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.19" implicitly_animated_reorderable_list: dependency: "direct main" description: @@ -274,7 +197,7 @@ packages: name: mask_text_input_formatter url: "https://pub.dartlang.org" source: hosted - version: "1.2.1" + version: "2.0.0" matcher: dependency: transitive description: @@ -288,7 +211,7 @@ packages: name: material_design_icons_flutter url: "https://pub.dartlang.org" source: hosted - version: "4.0.5955" + version: "5.0.5955-rc.1" material_floating_search_bar: dependency: "direct main" description: @@ -323,7 +246,7 @@ packages: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.2" path_provider_linux: dependency: transitive description: @@ -344,7 +267,7 @@ packages: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.1" path_provider_windows: dependency: transitive description: @@ -358,14 +281,7 @@ packages: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.11.0" - petitparser: - dependency: transitive - description: - name: petitparser - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.0" + version: "1.11.1" platform: dependency: transitive description: @@ -379,7 +295,7 @@ packages: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "2.0.0" process: dependency: transitive description: @@ -387,13 +303,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.2.1" - protobuf: - dependency: transitive - description: - name: protobuf - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" provider: dependency: "direct main" description: @@ -407,7 +316,7 @@ packages: name: qr url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" qr_flutter: dependency: "direct main" description: @@ -450,20 +359,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.4.1" - searchable_dropdown: - dependency: "direct main" - description: - name: searchable_dropdown - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.3" shared_preferences: dependency: "direct main" description: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.0.6" shared_preferences_linux: dependency: transitive description: @@ -510,7 +412,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" sqflite: dependency: "direct main" description: @@ -566,7 +468,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.3.0" typed_data: dependency: transitive description: @@ -580,49 +482,49 @@ packages: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "5.7.10" + version: "6.0.7" 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.0" 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.0" 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.3" url_launcher_web: dependency: transitive description: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.5+1" + version: "2.0.1" 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.0" uuid: dependency: "direct main" description: name: uuid url: "https://pub.dartlang.org" source: hosted - version: "2.2.2" + version: "3.0.4" vector_math: dependency: transitive description: @@ -636,7 +538,7 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.2.4" xdg_directories: dependency: transitive description: @@ -644,13 +546,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.2.0" - xml: - dependency: transitive - description: - name: xml - url: "https://pub.dartlang.org" - source: hosted - version: "4.5.1" sdks: - dart: ">=2.12.0 <3.0.0" - flutter: ">=1.24.0-10" + dart: ">=2.13.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index b0b06d1..bc99125 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.7.0 <3.0.0" + sdk: ">=2.12.0 <3.0.0" dependencies: flutter: @@ -41,21 +41,18 @@ dependencies: http: ^0.13.3 sqflite: ^2.0.0+3 path_provider: ^2.0.1 - material_design_icons_flutter: ^4.0.5955 + material_design_icons_flutter: 5.0.5955-rc.1 intl: ^0.17.0 - barcode_scan: ^3.0.1 device_info: ^2.0.0 - auto_size_text: ^2.1.0 - url_launcher: ^5.7.10 + auto_size_text: ^3.0.0-nullsafety.0 + url_launcher: ^6.0.7 qr_flutter: ^4.0.0 - mask_text_input_formatter: ^1.2.1 + mask_text_input_formatter: ^2.0.0 flutter_screenutil: ^5.0.0 shared_preferences: ^2.0.5 - searchable_dropdown: ^1.1.3 material_floating_search_bar: ^0.3.4 implicitly_animated_reorderable_list: ^0.4.0 - esc_pos_utils: ^1.0.0 - uuid: ^2.2.2 #for esc_pos_utils: ^1.0.0 + uuid: ^3.0.4 charset_converter: ^2.0.0 dev_dependencies: flutter_test: