FlutterのBuildContextとは何か - Qiita
flutter - Scaffold.of() called with a context that does not contain a Scaffold - Stack Overflow
理由
This exception happens because you are using the context of the widget that instantiated Scaffold. Not the context of a child of Scaffold.