From 062946d2e172ce04aeb7cc3c9ce743914e7de440 Mon Sep 17 00:00:00 2001 From: tzw Date: Mon, 13 Sep 2021 11:20:35 +0630 Subject: [PATCH] update discount --- lib/pages/customer/invitation_create.dart | 9 ++++----- lib/pages/discount/model/discount_model.dart | 20 ++++++++++---------- lib/pages/signin/signin_page.dart | 4 +--- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/lib/pages/customer/invitation_create.dart b/lib/pages/customer/invitation_create.dart index e2bb37a..f058c9b 100644 --- a/lib/pages/customer/invitation_create.dart +++ b/lib/pages/customer/invitation_create.dart @@ -85,7 +85,8 @@ class _InvitationCreateState extends State { ), Container( decoration: BoxDecoration( - border: Border.all(color: Colors.grey.shade400, width: 1), + border: + Border.all(color: Colors.grey.shade400, width: 1), borderRadius: BorderRadius.all(Radius.circular(12.0))), child: CountryCodePicker( onChanged: _countryChange, @@ -94,9 +95,7 @@ class _InvitationCreateState extends State { showCountryOnly: false, showOnlyCountryWhenClosed: false, alignLeft: false, - textStyle: TextStyle( - fontSize: 16, - ), + textStyle: TextStyle(fontSize: 16, color: Colors.black87), ), ), SizedBox( @@ -172,7 +171,7 @@ class _InvitationCreateState extends State { } isDataChanged() { - String userName = _nameController.text; + String userName = _nameController.text; String phoneNumber = _phoneController.text; return userName != "" || phoneNumber != ""; } diff --git a/lib/pages/discount/model/discount_model.dart b/lib/pages/discount/model/discount_model.dart index 415aad1..ce2b478 100644 --- a/lib/pages/discount/model/discount_model.dart +++ b/lib/pages/discount/model/discount_model.dart @@ -14,10 +14,11 @@ class DiscountModel extends BaseModel { StreamSubscription? listener; List _discounts = []; - List get discounts => - _selectedIndex == 1 ? _discounts : List.from(_used.values); + List get discounts => _selectedIndex == 1 + ? _discounts + : List.from(_used?.values ?? []); - late Paginator _used; + Paginator? _used; bool isLoading = false; int _selectedIndex = 1; set selectedIndex(int index) { @@ -31,7 +32,7 @@ class DiscountModel extends BaseModel { _selectedIndex = 1; _load(); if (_getUsed() != null) _used = _getUsed(); - _used.load(); + _used?.load(); } void initUser(user) { @@ -49,8 +50,7 @@ class DiscountModel extends BaseModel { .listen((snaps) { _discounts.clear(); snaps.docs.forEach((d) { - _discounts - .add(Discount.fromMap(d.data() as Map, d.id)); + _discounts.add(Discount.fromMap(d.data(), d.id)); }); notifyListeners(); }); @@ -94,10 +94,10 @@ class DiscountModel extends BaseModel { } Future loadMore() async { - if (_used.ended || _selectedIndex == 1) return; + if (_used!.ended || _selectedIndex == 1) return; isLoading = true; notifyListeners(); - await _used.load(onFinished: () { + await _used!.load(onFinished: () { isLoading = false; notifyListeners(); }); @@ -105,7 +105,7 @@ class DiscountModel extends BaseModel { Future refresh() async { if (_selectedIndex == 1) return; - await _used.refresh(onFinished: () { + await _used!.refresh(onFinished: () { notifyListeners(); }); } @@ -113,7 +113,7 @@ class DiscountModel extends BaseModel { @override logout() async { if (listener != null) await listener!.cancel(); - if (_used != null) _used.close(); + if (_used != null) _used!.close(); _discounts = []; } diff --git a/lib/pages/signin/signin_page.dart b/lib/pages/signin/signin_page.dart index 6eaeca8..5c72ec9 100644 --- a/lib/pages/signin/signin_page.dart +++ b/lib/pages/signin/signin_page.dart @@ -90,9 +90,7 @@ class _SigninPageState extends State { showCountryOnly: false, showOnlyCountryWhenClosed: false, alignLeft: false, - textStyle: TextStyle( - fontSize: 16, - ), + textStyle: TextStyle(fontSize: 16, color: Colors.black87), ), ), SizedBox(