Did this resolve your issue?
Wrap this code:
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => AddVehiclePage(
edit: true,
data: vehicle,
),
),
).then((onValue) {
getvalue();
});
with WidgetsBinding.instance.addPostFrameCallback((_) { // Your Navigator here });. Moreover, since you're handling the BuildContext class. Therefore, you need to ensure that the current BuildContext class is currently mounted in the widget tree using context.mounted.
It should be something like this:
WidgetsBinding.instance.addPostFrameCallback((_) {
if (context.mounted) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => AddVehiclePage(
edit: true,
data: vehicle,
),
),
).then((onValue) {
getvalue();
});
}
});