null safety

This commit is contained in:
Phaung Phaung
2021-09-10 15:23:13 +06:30
parent 5c5e47b9ad
commit 376153e22f
14 changed files with 80 additions and 66 deletions

View File

@@ -56,7 +56,7 @@ class _StaffEditorState extends State<StaffEditor> {
title: InkWell(
onTap: () {
setState(() {
p.isChecked = p.isChecked == null ? true : !p.isChecked;
p.isChecked = p.isChecked == null ? true : !p.isChecked!;
});
},
child: new Row(
@@ -79,10 +79,10 @@ class _StaffEditorState extends State<StaffEditor> {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text(
p.name,
p.name ??"",
style: TextStyle(fontSize: 15.0, color: primaryColor),
),
Text(p.desc,
Text(p.desc ?? "",
style: TextStyle(fontSize: 13, color: Colors.grey[600]))
],
),
@@ -151,7 +151,7 @@ class _StaffEditorState extends State<StaffEditor> {
? Container()
: IconButton(
icon: Icon(Icons.open_in_new, color: primaryColor),
onPressed: () => call(context, user.phoneNumber)),
onPressed: () => call(context, user.phoneNumber!)),
],
);
@@ -227,7 +227,7 @@ class _StaffEditorState extends State<StaffEditor> {
});
StaffModel staffModel = Provider.of<StaffModel>(context, listen: false);
try {
await staffModel.updatePrivileges(this.selectedUser!.id, privilegesIDs());
await staffModel.updatePrivileges(this.selectedUser!.id!, privilegesIDs());
Navigator.pop(context);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
@@ -239,7 +239,7 @@ class _StaffEditorState extends State<StaffEditor> {
}
List<String> privilegesIDs() {
return this.privileges.where((p) => p.isChecked).map((p) => p.id).toList();
return this.privileges.where((p) => p.isChecked!).map((p) => p.id).toList();
}
_save() async {
@@ -249,7 +249,7 @@ class _StaffEditorState extends State<StaffEditor> {
if (widget.staff == null) return;
StaffModel staffModel = Provider.of<StaffModel>(context, listen: false);
try {
await staffModel.updatePrivileges(widget.staff!.id, privilegesIDs());
await staffModel.updatePrivileges(widget.staff!.id!, privilegesIDs());
Navigator.pop(context);
} catch (e) {
showMsgDialog(context, "Error", e.toString());

View File

@@ -93,13 +93,13 @@ class _StaffListState extends State<StaffList> {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text(
user.name,
user.name ?? "",
style: new TextStyle(fontSize: 15.0),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: new Text(
user.phoneNumber,
user.phoneNumber ?? "",
style: new TextStyle(
fontSize: 15.0, color: Colors.grey),
),