showPrimaryButton method
Displays the primary button for saving the profile.
Implementation
Widget showPrimaryButton() {
return Padding(
padding: const EdgeInsets.fromLTRB(30.0, 45.0, 30.0, 10.0),
child: SizedBox(
height: 40.0,
child: MaterialButton(
elevation: 5.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0),
),
color: Colors.teal,
child: const Text(
'Save',
style: TextStyle(fontSize: 17.0, color: Colors.white),
),
onPressed: () async {
Map<String, dynamic> data = {};
data["name"] = nameController.text.trim();
data["email"] = widget.doctor!.email!.trim();
debugPrint('name -> ${nameController.text}');
debugPrint('name -> ${widget.doctor!.documentId!}');
if (nameController.text.isEmpty) {
showSnackbar("Please fill your name!");
} else {
widget.doctor!.email = data["email"];
try {
await databases.updateDocument(
databaseId: AppConstants.appwriteDatabaseId,
collectionId: AppConstants.userCollectionId,
documentId: widget.doctor!.documentId!,
data: data,
);
context.pushReplacement(AppRoutes.initProfileUpdate2, extra: widget.doctor!);
} catch (e) {
debugPrint("Appwrite error: $e");
showSnackbar("Something went wrong while saving.");
}
}
}),
),
);
}