BuildContext is not a reference to your widget. It's a reference to the location of the widget in the widget tree.
BuildContext is tied to the location of a widget, not the widget itself. If the widget is rebuilt or moved, that context may no longer be valid.
At initState(), your widget hasn't been inserted into the widget tree yet. So trying to use context-dependent methods like Theme.of(context) or Provider.of(context) will crash.
Best Practices with BuildContext: If you’re in doubt, wrap your widget in a Builder to get a fresh, local context.