I'm writing a Application, where Widgets and their State need to be saved to Disk and later be restored. In order to save a StatefulWidget
I need to access it's corresponding State<T>
object.
Here's how I imagined the code to look like:
class Block extends StatefulWidget {
const Block({Key? key}) : super(key: key);
void saveToDisk(){
// access BlockState object
// save to disk…
}
@override
BlockState createState() => BlockState();
}
class BlockState extends State<Block> {
final String _someState = ‚Hello Stackoverflow‘;
@override
Widget build(BuildContext context) {
return const Text(‚Some Text‘);
}
}
Does anybody know how to access the BlockState
object (first comment in saveToDisk()
)?