I have an outer scaffold with an app bar with an action button that when clicked I want to save the state of an inner Stateful widget to perm storage - what is the best way to be able to call the inner widget method from the outer app bar and also be able to do Scaffold.of(context) in the called method ?
class AISSettings extends StatelessWidget {
static const String route = 'settings/ais';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('AIS settings'),
actions: <Widget>[
IconButton(icon: Icon(Icons.check), onPressed: () => {/* call _SettingsState.saveStuff() */} ),
],
),
bottomNavigationBar: Navbar(),
body: AISSettingsForm(),
);
}
}
class AISSettingsForm extends StatefulWidget {
@override
_SettingsState createState() => _SettingsState();
}
class _SettingsState extends State<AISSettingsForm> {
final _formKey = GlobalKey<_SettingsState>();
Map<String, dynamic> _options;
saveStuff() {
// Scaffold.of(context).showSnackBar(....)
}
}