-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrapping MaterialApp with another builder resulting error: No Parent InheritedWidget of type [TopReactiveStateless ] is found #290
Comments
also InjectedTheme with DynamicColorBuilder support would be awesome. |
I have another problem again, I was using the injected theme feature, but in the end, I want user to add custom color/image to generate their own preffered theme. the injected theme feature doesnt have ability to dynamically add a new theme (maybe for next feature update?). So I change my code from above to something like this: class MainApp extends TopStatelessWidget {
const MainApp({super.key});
@override
List<Future<void>>? ensureInitialization() {
return [
authBloc.init(),
];
}
@override
Widget? splashScreen() {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Container(),
),
);
}
@override
Widget build(BuildContext context) {
// return DynamicColorBuilder(builder: (
// lightColorScheme,
// darkColorScheme,
// ) {
return OnReactive(() {
return MaterialApp.router(
routeInformationParser: navigator.routeInformationParser,
routerDelegate: navigator.routerDelegate,
locale: i18nRM.locale,
localeResolutionCallback: i18nRM.localeResolutionCallback,
localizationsDelegates: i18nRM.localizationsDelegates,
theme: ThemeData(
colorSchemeSeed: themeController.themeSelectionMethod.state ==
ThemeSelectionMethod.colorSeed
? themeController.selectedColorSeed.state.color
: themeController.colorScheme.state.primary,
brightness:
themeController.isDark.state ? Brightness.dark : Brightness.light,
textTheme: kNunitoTextTheme,
useMaterial3: true,
),
debugShowCheckedModeBanner: false,
);
});
// });
}
}
I have the same error like when using dynamicColorBuilder
Wrapping material app with another builder resulting those error, maybe for now I will use other localization plugin outside stateRebuilder. |
my workaround for now, without using injected localization import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_gen/gen_l10n/app_localizations_en.dart';
import 'package:flutter_gen/gen_l10n/app_localizations_id.dart';
import 'package:states_rebuilder/states_rebuilder.dart';
@immutable
class Localization {
final locale = RM.inject(
() => const Locale("en"),
debugPrintWhenNotifiedPreMessage: "Localization Service",
persist: () => PersistState<Locale>(
key: "__locale__",
fromJson: (json) => Locale(json),
toJson: (s) => s.toString(),
),
);
late final _i18n = RM.inject(() => localizations.state[locale.state]!);
AppLocalizations get i18n => _i18n.state;
final localizations = RM.inject(() => {
const Locale("en"): AppLocalizationsEn(),
const Locale("id"): AppLocalizationsId(),
});
void changeLocale(Locale newLocale) {
locale.setToHasData(newLocale);
_i18n.refresh();
}
}
final localization = Localization();
class MainApp extends TopStatelessWidget {
const MainApp({super.key});
@override
List<Future<void>>? ensureInitialization() {
return [
authService.init(),
];
}
@override
Widget? splashScreen() {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Container(),
),
);
}
@override
Widget build(BuildContext context) {
return OnReactive(
() {
return MaterialApp.router(
key: key,
routeInformationParser: router.routeInformationParser,
routerDelegate: router.routerDelegate,
locale: localization.locale.state,
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
theme: ThemeData(
colorSchemeSeed: themeService.themeSelectionMethod.state ==
ThemeSelectionMethod.colorSeed
? themeService.selectedColorSeed.state.color
: themeService.colorScheme.state.primary,
brightness:
themeService.isDark.state ? Brightness.dark : Brightness.light,
textTheme: kNunitoTextTheme,
useMaterial3: true,
),
debugShowCheckedModeBanner: false,
);
},
);
}
}
|
I get this error when using localization and DynamicColorBuilder,
No Parent InheritedWidget of type [TopReactiveStateless ] is found
.Removing dynamicColorBuilder fix this problem. Is there is a way to use both?
The text was updated successfully, but these errors were encountered: