restartAndRestore method Null safety

Future<void> restartAndRestore()

Simulates restoring the state of the widget tree after the application is restarted.

The method grabs the current serialized restoration data from the RestorationManager, takes down the widget tree to destroy all in-memory state, and then restores the widget tree from the serialized restoration data.


Future<void> restartAndRestore() async {
    'The current widget tree did not inject the root bucket of the RestorationManager and '
    'therefore no restoration data has been collected to restore from. Did you forget to wrap '
    'your widget tree in a RootRestorationScope?',
  final Widget widget = ((binding.renderViewElement! as RenderObjectToWidgetElement<RenderObject>).widget as RenderObjectToWidgetAdapter<RenderObject>).child!;
  final TestRestorationData restorationData = binding.restorationManager.restorationData;
  runApp(Container(key: UniqueKey()));
  await pump();
  return pumpWidget(widget);