Покупка +

null-safety-migration
suvaysov 2022-11-15 19:22:49 +06:00
parent 94b1e7a79a
commit 69c98ca7c8
2 changed files with 15 additions and 9 deletions

View File

@ -185,7 +185,6 @@ Future<void> removeAllSellData(Store<AppState> store) async {
Future<void> loadSellData(Store<AppState> store) async { Future<void> loadSellData(Store<AppState> store) async {
try { try {
log.i('loadSellData');
final int? appCompanyId = store.state.userState!.auth!.companyId; final int? appCompanyId = store.state.userState!.auth!.companyId;
final List<Map<String, dynamic>> set = await _dbService.queryRowsWithWhere( final List<Map<String, dynamic>> set = await _dbService.queryRowsWithWhere(
transactionTableName, transactionTableName,

View File

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:satu/core/models/inventarization/response/inventarization_response.dart'; import 'package:satu/core/models/inventarization/response/inventarization_response.dart';
import 'package:satu/core/services/dialog_service.dart';
import 'package:satu/core/services/inventarization_service.dart'; import 'package:satu/core/services/inventarization_service.dart';
import 'package:satu/core/services/navigator_service.dart'; import 'package:satu/core/services/navigator_service.dart';
import 'package:satu/core/utils/locator.dart'; import 'package:satu/core/utils/locator.dart';
@ -22,14 +23,14 @@ class InventarizationView extends StatefulWidget {
} }
class _InventarizationViewState extends State<InventarizationView> { class _InventarizationViewState extends State<InventarizationView> {
final InventarizationService _service = locator<InventarizationService>(); final InventarizationService _service = locator<InventarizationService>();
final NavigatorService _navigatorService = locator<NavigatorService>(); final NavigatorService _navigatorService = locator<NavigatorService>();
final DialogService _dialogService = locator<DialogService>();
static const _pageSize = 20; static const _pageSize = 20;
final PagingController<int, InventarizationResponse> _pagingController = final PagingController<int, InventarizationResponse> _pagingController =
PagingController(firstPageKey: 1); PagingController(firstPageKey: 1);
final DateFormat formatterDay = DateFormat('dd.MM.yyyy'); final DateFormat formatterDay = DateFormat('dd.MM.yyyy');
@ -58,7 +59,7 @@ class _InventarizationViewState extends State<InventarizationView> {
children: [ children: [
verticalSpaceSmall, verticalSpaceSmall,
Padding( Padding(
padding: const EdgeInsets.only( left: 15.0), padding: const EdgeInsets.only(left: 15.0),
child: SizedBox( child: SizedBox(
width: double.infinity, width: double.infinity,
child: Row( child: Row(
@ -99,12 +100,18 @@ class _InventarizationViewState extends State<InventarizationView> {
); );
}, },
pagingController: _pagingController, pagingController: _pagingController,
builderDelegate: PagedChildBuilderDelegate<InventarizationResponse>( builderDelegate:
itemBuilder: (BuildContext context, InventarizationResponse item, PagedChildBuilderDelegate<InventarizationResponse>(
int index) { itemBuilder: (BuildContext context,
InventarizationResponse item, int index) {
return DictionaryTile( return DictionaryTile(
key: Key('category_${item.id}'), key: Key('category_${item.id}'),
onPress: () async { onPress: () async {
if (item.act != null) {
return _dialogService.showDialog(
description:
'В обработанный акт нельзя добавить товары');
}
final dynamic result = await _navigatorService final dynamic result = await _navigatorService
.push(inventarizationEditRoute, arguments: item); .push(inventarizationEditRoute, arguments: item);
if (result != null && true == (result as bool)) { if (result != null && true == (result as bool)) {
@ -144,8 +151,8 @@ class _InventarizationViewState extends State<InventarizationView> {
} }
Future<void> _fetchData(int pageKey, int perPage) async { Future<void> _fetchData(int pageKey, int perPage) async {
final List<InventarizationResponse> newItems = await _service final List<InventarizationResponse> newItems =
.getList(page: pageKey, perpage: perPage); await _service.getList(page: pageKey, perpage: perPage);
final isLastPage = newItems.length < _pageSize; final isLastPage = newItems.length < _pageSize;
if (isLastPage) { if (isLastPage) {
_pagingController.appendLastPage(newItems); _pagingController.appendLastPage(newItems);