initPersistence method

void initPersistence()

Initializes the persistence system.

Implementation

void initPersistence() {
  if (!MastroInit.isInitialized) {
    try {
      throw StateError('''

╔════════════════════════════════════════════════════════════════════════════╗
║                              PERSISTRO ERROR                               ║
╠════════════════════════════════════════════════════════════════════════════╣
║ Cannot create Persistent state before Mastro initialization!               ║
║                                                                            ║
║ Please initialize Mastro before creating Persistent states:                ║
║                                                                            ║
║ void main() async {                                                        ║
║   WidgetsFlutterBinding.ensureInitialized();                               ║
║   await MastroInit.initialize();                                           ║
║   ...                                                                      ║
║   runApp(MaterialApp(                                                      ║
║     home: YourHomeWidget(),                                                ║
║   ));                                                                      ║
║ }                                                                          ║
╚════════════════════════════════════════════════════════════════════════════╝
    ''');
    } catch (e) {
      debugPrint(e.toString(), wrapWidth: 1024);
      return; // Adjust wrapWidth as needed
    }
  }

  if (autoSave) {
    addListener(_handleAutoSave);
  }
  restore();
}