[Solved] Flutter No instance of S was loaded. Try to initialize the S delegate before accessing S.current.

2023/02/12 22:53

======== Exception caught by widgets library =======================================================
The following assertion was thrown building DiaryPage(dirty, dependencies: [MediaQuery, _InheritedProviderScope<DiaryListStream?>, _InheritedProviderScope<UserInfoStream?>], state: _DiaryPageState#14a65):
No instance of S was loaded. Try to initialize the S delegate before accessing S.current.
‘package:itwi/generated/l10n.dart’:
Failed assertion: line 21 pos 12: ‘_current != null’

 

Solution

child: MaterialApp(
  localizationsDelegates: const [
    S.delegate,
    GlobalMaterialLocalizations.delegate,
    GlobalCupertinoLocalizations.delegate,
    GlobalWidgetsLocalizations.delegate,
  ],

Add ” S.delegate,” to the list.

Leave a Reply

Back to top