onInit method
Called immediately after the widget is allocated in memory. You might use this to initialize something for the controller.
Implementation
@override
void onInit() {
super.onInit();
if (config.flowerPages == null && config.home == null) {
throw 'You need add pages or home';
}
routerDelegate = config.routerDelegate ??
createDelegate(
pages: config.flowerPages ??
[
FlowerPage(
name: cleanRouteName("/${config.home.runtimeType}"),
page: () => config.home!,
),
],
notFoundRoute: config.unknownRoute,
navigatorKey: config.navigatorKey,
navigatorObservers: (config.navigatorObservers == null
? <NavigatorObserver>[
FlowerObserver(config.routingCallback, Flower.routing)
]
: <NavigatorObserver>[
FlowerObserver(config.routingCallback, routing),
...config.navigatorObservers!
]),
);
routeInformationParser = config.routeInformationParser ??
createInformationParser(
initialRoute: config.initialRoute ??
config.flowerPages?.first.name ??
cleanRouteName("/${config.home.runtimeType}"),
);
if (config.locale != null) Flower.locale = config.locale;
if (config.fallbackLocale != null) {
Flower.fallbackLocale = config.fallbackLocale;
}
if (config.translations != null) {
Flower.addTranslations(config.translations!.keys);
} else if (config.translationsKeys != null) {
Flower.addTranslations(config.translationsKeys!);
}
customTransition = config.customTransition;
//Flower.setDefaultDelegate(routerDelegate);
Flower.smartManagement = config.smartManagement;
config.onInit?.call();
Flower.isLogEnable = config.enableLog ?? kDebugMode;
Flower.log = config.logWriterCallback ?? defaultLogger;
defaultTransition = config.defaultTransition;
defaultOpaqueRoute = config.opaqueRoute ?? true;
defaultPopGesture = config.popGesture ?? FlowerPlatform.isIOS;
defaultTransitionDuration =
config.transitionDuration ?? const Duration(milliseconds: 300);
// defaultTransitionCurve = Curves.easeOutQuad;
// defaultDialogTransitionCurve = Curves.easeOutQuad;
// defaultDialogTransitionDuration = Duration(milliseconds: 300);
// theme = ThemeData(
// fontFamily: 'IranYekan',
// // elevatedButtonTheme: ElevatedButtonThemeData(
// // style: ElevatedButton.styleFrom(
// // foregroundColor: Colors.white,
// // backgroundColor: const Color(0xE8212121),
// // padding: const EdgeInsets.all(10.0),
// // shape: RoundedRectangleBorder(
// // borderRadius: BorderRadius.circular(10.0),
// // ),
// // )),
// appBarTheme: AppBarTheme(
// backgroundColor: Colors.grey.shade200,
// foregroundColor: Colors.black54),
// colorScheme: ColorScheme.light(
// primary: _box.read<int>("primaryColor") != null
// ? Color(_box.read<int>("primaryColor")!)
// : (config.primaryColor ?? Colors.blue),
// ));
// darkTheme = ThemeData(
// fontFamily: 'IranYekan',
// elevatedButtonTheme: ElevatedButtonThemeData(
// style: ElevatedButton.styleFrom(
// foregroundColor: Colors.white,
// backgroundColor: const Color(0xE8212121),
// padding: const EdgeInsets.all(10.0),
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(10.0),
// ),
// )),
// appBarTheme: const AppBarTheme(backgroundColor: Color(0xFF282828)),
// colorScheme: ColorScheme.dark(
// primary: _box.read<int>("primaryColor") != null
// ? Color(_box.read<int>("primaryColor")!)
// : (config.primaryColor ?? Colors.blue),
// ));
}