I have tried to make each order unique by making the unique id the current date. Since the user can choose the same service multiple times, I want the repeated order to be written to the database as a different order.
I can't strong text make the child as current date. What is the problem? Kindly help me out.
onPressed: () {
final User _firebaseUser = firebaseAuth.currentUser;
databaseReference
.child("users")
.child(_firebaseUser.uid)
.child("orders")
.child(DateTime.now().toString())
.set({
"service_type" : widget.serviceType.trim(),
"service_price" : widget.servicePrice,
"first_name" : firstNameController.text.trim(),
"last_name" : lastNameController.text.trim(),
"phone" : phoneController.text.trim(),
"county" : countyNameController.text.trim(),
"sub_county" : subCountyNameController.text.trim(),
"exact_location" : _currentLocation.trim(),
});
showInSnackBar('Your order will be added in less thhan 1 hour');
Navigator.push(context, MaterialPageRoute(builder: (context) => HomeScreen()),);
},