I have this error while building Flutter app on Command Line. I tried all the above fix but it did not work.
I solve the error by reading the Xcode output error below this and I followed the instruction to fix the error. In my own case the error was:
lib/pages/cart/payment.dart:82:32: Error: The method 'showSnackBar' isn't defined for the class 'ScaffoldState'.
- 'ScaffoldState' is from 'package:flutter/src/material/scaffold.dart' ('../../../../flutter/packages/flutter/lib/src/material/scaffold.dart').
Try correcting the name to the name of an existing method, or defining a method named 'showSnackBar'.
Scaffold.of(context).showSnackBar(
I discovered that scaffold syntax is deprecated, so, I googled the right syntax and changed "Scaffold.of(content)" to "ScaffoldMessenger.of(content)".
THIS MAY NOT BE THE ERROR IN YOUR CASE, BUT CALM AND STUDY THE ERROR.