null safety
This commit is contained in:
@@ -24,7 +24,7 @@ class _ProfileCurrencyEditState extends State<ProfileCurrencyEdit> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
MainModel mainModel = Provider.of<MainModel>(context, listen: false);
|
||||
if (mainModel.user.preferCurrency == "MMK") {
|
||||
if (mainModel.user!.preferCurrency == "MMK") {
|
||||
_currency = Currency.MMK;
|
||||
} else {
|
||||
_currency = Currency.USD;
|
||||
@@ -77,7 +77,7 @@ class _ProfileCurrencyEditState extends State<ProfileCurrencyEdit> {
|
||||
onChanged: (Currency? value) {
|
||||
if(value != null)
|
||||
setState(() {
|
||||
_currency = value!;
|
||||
_currency = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
@@ -96,7 +96,7 @@ class _ProfileCurrencyEditState extends State<ProfileCurrencyEdit> {
|
||||
onChanged: (Currency? value) {
|
||||
if(value != null)
|
||||
setState(() {
|
||||
_currency = value!;
|
||||
_currency = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
|
||||
@@ -24,7 +24,7 @@ class _ProfileEditState extends State<ProfileEdit> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
MainModel mainModel = Provider.of<MainModel>(context, listen: false);
|
||||
nameController.text = mainModel.user.name;
|
||||
nameController.text = mainModel.user!.name ?? "";
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -18,6 +18,7 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||
|
||||
import '../../helpers/theme.dart';
|
||||
|
||||
@@ -31,7 +32,7 @@ class Profile extends StatefulWidget {
|
||||
class _ProfileState extends State<Profile> {
|
||||
GlobalKey key = GlobalKey();
|
||||
bool _isLoading = false;
|
||||
String? selectedLanguage ;
|
||||
String? selectedLanguage;
|
||||
TextEditingController bizNameController = new TextEditingController();
|
||||
|
||||
static final List<String> languagesList = Translation().supportedLanguages;
|
||||
@@ -67,18 +68,19 @@ class _ProfileState extends State<Profile> {
|
||||
Provider.of<DeliveryAddressModel>(context);
|
||||
|
||||
final namebox = DisplayText(
|
||||
text: mainModel.user.name + " (${mainModel.user.status})",
|
||||
text: "${mainModel.user!.name ?? ''}" +
|
||||
" (${mainModel.user!.status ?? ''})",
|
||||
labelTextKey: "profile.name",
|
||||
iconData: Icons.person,
|
||||
);
|
||||
final currencyBox = DisplayText(
|
||||
text: mainModel.user.preferCurrency,
|
||||
text: mainModel.user!.preferCurrency ?? "",
|
||||
labelTextKey: "profile.currency",
|
||||
iconData: FontAwesome5.money_bill_alt,
|
||||
iconData: FontAwesome5Regular.money_bill_alt,
|
||||
);
|
||||
|
||||
final phonenumberbox = DisplayText(
|
||||
text: mainModel.user.phone,
|
||||
text: mainModel.user!.phone ?? "",
|
||||
labelTextKey: "profile.phone",
|
||||
iconData: Icons.phone,
|
||||
);
|
||||
@@ -86,15 +88,15 @@ class _ProfileState extends State<Profile> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: DisplayText(
|
||||
text: mainModel.user.fcsID,
|
||||
text: mainModel.user!.fcsID ?? "",
|
||||
labelTextKey: "customer.fcs.id",
|
||||
icon: FcsIDIcon(),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.content_copy, color: Colors.grey),
|
||||
onPressed: () => _copy(
|
||||
getLocalString(context, "customer.fcs.id"), mainModel.user.fcsID),
|
||||
onPressed: () => _copy(getLocalString(context, "customer.fcs.id"),
|
||||
mainModel.user!.fcsID ?? ""),
|
||||
)
|
||||
],
|
||||
);
|
||||
@@ -103,7 +105,7 @@ class _ProfileState extends State<Profile> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: DisplayText(
|
||||
text: mainModel.setting.usaAddress,
|
||||
text: mainModel.setting!.usaAddress ?? "",
|
||||
labelTextKey: "profile.usa.shipping.address",
|
||||
iconData: Icons.location_on,
|
||||
),
|
||||
@@ -112,7 +114,7 @@ class _ProfileState extends State<Profile> {
|
||||
icon: Icon(Icons.content_copy, color: Colors.grey),
|
||||
onPressed: () => _copy(
|
||||
getLocalString(context, "profile.usa.shipping.address"),
|
||||
mainModel.setting.usaAddress),
|
||||
mainModel.setting!.usaAddress ?? ""),
|
||||
)
|
||||
],
|
||||
);
|
||||
@@ -195,14 +197,14 @@ class _ProfileState extends State<Profile> {
|
||||
}
|
||||
|
||||
Widget getPrivilegeBox(BuildContext context) {
|
||||
User user = Provider.of<MainModel>(context, listen: false).user;
|
||||
User? user = Provider.of<MainModel>(context, listen: false).user;
|
||||
List<Privilege> _privileges =
|
||||
Provider.of<StaffModel>(context, listen: false).privileges;
|
||||
|
||||
if (user == null || user.isCustomer()) return Container();
|
||||
List<Privilege> privileges = [];
|
||||
user.privileges.forEach((e) {
|
||||
var p = _privileges.firstWhere((p) => p.id == e, orElse: () => null);
|
||||
var p = _privileges.firstWhere((p) => p.id == e);
|
||||
if (p != null) {
|
||||
privileges.add(p);
|
||||
}
|
||||
@@ -270,7 +272,7 @@ class _ProfileState extends State<Profile> {
|
||||
}
|
||||
|
||||
_showToast(String title) {
|
||||
final ScaffoldState scaffold = key.currentState;
|
||||
final ScaffoldState scaffold = key.currentState as ScaffoldState;
|
||||
scaffold.showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('copied "$title" data to clipboard'),
|
||||
|
||||
Reference in New Issue
Block a user