null safety

This commit is contained in:
phyothandar
2021-09-10 12:00:08 +06:30
parent a144c945b6
commit 5e672937b5
67 changed files with 901 additions and 896 deletions

View File

@@ -14,7 +14,7 @@ import 'package:provider/provider.dart';
typedef void FindCallBack();
class CustomerEditor extends StatefulWidget {
final User customer;
final User? customer;
const CustomerEditor({this.customer});
@override
_CustomerEditorState createState() => _CustomerEditorState();
@@ -34,17 +34,17 @@ class _CustomerEditorState extends State<CustomerEditor> {
children: <Widget>[
Expanded(
child: DisplayText(
text: widget.customer.phoneNumber,
text: widget.customer!.phoneNumber,
labelTextKey: "customer.phone",
iconData: Icons.phone,
)),
IconButton(
icon: Icon(Icons.open_in_new, color: primaryColor),
onPressed: () => call(context, widget.customer.phoneNumber)),
onPressed: () => call(context, widget.customer!.phoneNumber)),
],
);
final enabled = widget.customer.status != user_disabled_status;
final enabled = widget.customer!.status != user_disabled_status;
final enableBox = LocalButton(
textKey: enabled ? "customer.disable.btn" : "customer.enable.btn",
iconData: enabled ? Icons.lock : Icons.lock_open,
@@ -68,7 +68,7 @@ class _CustomerEditorState extends State<CustomerEditor> {
onPressed: () => Navigator.of(context).pop(),
),
title: Text(
widget.customer.name,
widget.customer!.name,
style: TextStyle(
fontSize: 20,
color: primaryColor,
@@ -81,26 +81,26 @@ class _CustomerEditorState extends State<CustomerEditor> {
children: <Widget>[
phoneNumberBox,
DisplayText(
text: widget.customer.fcsID,
text: widget.customer!.fcsID,
labelTextKey: "customer.fcs.id",
icon: FcsIDIcon(),
),
DisplayText(
text: widget.customer.status,
text: widget.customer!.status,
labelTextKey: "customer.status",
iconData: Icons.add_alarm,
),
SizedBox(
height: 20,
),
widget.customer.requested
widget.customer!.requested
? fcsButton(
context,
getLocalString(
context, "customer.invitation.request.confirm"),
callack: _add)
: Container(),
widget.customer.joined || widget.customer.disabled
widget.customer!.joined || widget.customer!.disabled
? enableBox
: Container()
],
@@ -119,7 +119,7 @@ class _CustomerEditorState extends State<CustomerEditor> {
CustomerModel customerModel =
Provider.of<CustomerModel>(context, listen: false);
try {
await customerModel.acceptRequest(widget.customer.id);
await customerModel.acceptRequest(widget.customer!.id);
Navigator.pop(context);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
@@ -139,7 +139,7 @@ class _CustomerEditorState extends State<CustomerEditor> {
CustomerModel customerModel =
Provider.of<CustomerModel>(context, listen: false);
try {
await customerModel.enableUser(widget.customer, enabled);
await customerModel.enableUser(widget.customer!, enabled);
Navigator.pop(context);
} catch (e) {
showMsgDialog(context, "Error", e.toString());

View File

@@ -233,11 +233,11 @@ class _CustomerListState extends State<CustomerList> {
_share(User user) async {
MainModel mainModel = Provider.of<MainModel>(context, listen: false);
String appUrl = mainModel.setting.appUrl;
final RenderBox box = context.findRenderObject();
final RenderBox? box = context.findRenderObject() as RenderBox;
await Share.share(
"Join us on FCS Logistics App. Here is the link:\n $appUrl\n" +
user.share,
subject: "Invitation to FCS Logistics App",
sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size);
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size);
}
}

View File

@@ -19,7 +19,7 @@ class _InvitationCreateState extends State<InvitationCreate> {
TextEditingController _phoneController = new TextEditingController();
bool _isLoading = false;
String dialCode;
late String dialCode;
@override
void initState() {
@@ -85,7 +85,7 @@ class _InvitationCreateState extends State<InvitationCreate> {
),
Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.grey[400], width: 1),
border: Border.all(color: Colors.grey.shade400, width: 1),
borderRadius: BorderRadius.all(Radius.circular(12.0))),
child: CountryCodePicker(
onChanged: _countryChange,
@@ -140,7 +140,7 @@ class _InvitationCreateState extends State<InvitationCreate> {
_countryChange(CountryCode countryCode) {
setState(() {
dialCode = countryCode.dialCode;
dialCode = countryCode.dialCode!;
});
}

View File

@@ -11,7 +11,7 @@ import 'package:provider/provider.dart';
typedef void FindCallBack();
class InvitationEditor extends StatefulWidget {
final User customer;
final User? customer;
const InvitationEditor({this.customer});
@override
_InvitationEditorState createState() => _InvitationEditorState();
@@ -31,13 +31,13 @@ class _InvitationEditorState extends State<InvitationEditor> {
children: <Widget>[
Expanded(
child: DisplayText(
text: widget.customer.phoneNumber,
text: widget.customer!.phoneNumber,
labelTextKey: getLocalString(context, "customer.phone"),
iconData: Icons.phone,
)),
IconButton(
icon: Icon(Icons.open_in_new, color: primaryColor),
onPressed: () => call(context, widget.customer.phoneNumber)),
onPressed: () => call(context, widget.customer!.phoneNumber)),
],
);
@@ -57,7 +57,7 @@ class _InvitationEditorState extends State<InvitationEditor> {
onPressed: () => Navigator.of(context).pop(),
),
title: Text(
widget.customer.name,
widget.customer!.name,
style: TextStyle(fontSize: 20, color: primaryColor),
),
),
@@ -87,7 +87,7 @@ class _InvitationEditorState extends State<InvitationEditor> {
CustomerModel customerModel =
Provider.of<CustomerModel>(context, listen: false);
try {
await customerModel.deleteInvite(widget.customer.phoneNumber);
await customerModel.deleteInvite(widget.customer!.phoneNumber);
Navigator.pop(context);
} catch (e) {
showMsgDialog(context, "Error", e.toString());

View File

@@ -12,8 +12,8 @@ class CustomerModel extends BaseModel {
List<User> customers = [];
List<User> invitations = [];
StreamSubscription<QuerySnapshot> customerListener;
StreamSubscription<QuerySnapshot> invitationListener;
late StreamSubscription<QuerySnapshot?> customerListener;
late StreamSubscription<QuerySnapshot?> invitationListener;
@override
void privilegeChanged() {