build method
dynamic
build( - dynamic context
)
Implementation
@override
Widget build(BuildContext context) {
List<Locale> supportedLang = widget
.appAttributes
.appSettings
.supportedLocales!
.map((element) => Locale(element))
.toList();
assert(
supportedLang.length <= 2 && supportedLang.isNotEmpty,
"For now only max. 2 different lang are supported. And you need at least 1 :)",
);
Locale currentLocale = supportedLang[0];
if (widget.appAttributes.useOtherLanguageMode != null) {
if (supportedLang.length == 2) {
if ((Localizations.localeOf(context) == supportedLang[0] &&
widget.appAttributes.useOtherLanguageMode!) ||
(Localizations.localeOf(context) == supportedLang[1])) {
currentLocale = supportedLang[1];
}
}
}
return Localizations.override(
context: context,
locale: currentLocale,
child: SelectionArea(
child: Builder(
builder: (context) {
return AnimatedBuilder(
animation: widget.controller,
builder: (context, child) {
return NavigationTransition(
footer: widget.footer,
showFooter:
(widget.appAttributes.showLargeSizeLayout ||
widget.appAttributes.showMediumSizeLayout) &&
!widget.appAttributes.appSettings.disableFooter,
scaffoldKey: widget.scaffoldKey,
animationController: widget.controller,
railAnimation: widget.appAttributes.railAnimation,
appBar: _createAppBar(Localizations.localeOf(context)),
body: Expanded(child: widget.navigationShell),
navigationRail: NavigationRail(
extended: widget.appAttributes.showLargeSizeLayout,
destinations: widget.appAttributes.screenConfigurations
.getNavRailDestinations(context),
selectedIndex:
(widget.navigationShell.currentIndex <
widget.appAttributes.screenConfigurations
.getAppBarDestinations(context)
.length)
? widget.navigationShell.currentIndex
: currentNavBarIndex,
onDestinationSelected: (index) {
widget.handleChangedPageIndex(index);
currentNavBarIndex = index;
widget.navigationShell.goBranch(currentNavBarIndex);
},
trailing: Expanded(
child: Padding(
padding: const EdgeInsets.only(bottom: 20),
child: widget.appAttributes.showLargeSizeLayout
? ExpandedTrailingActions(
buttonNames: widget.appAttributes.homeConfig
.getButtonNames(context),
appAttributes: widget.appAttributes,
)
: TrailingActions(
appAttributes: widget.appAttributes,
),
),
),
),
navigationBar: NavigationBars(
screenConfigurations:
widget.appAttributes.screenConfigurations,
currentNavBarIndex:
(widget.navigationShell.currentIndex <
widget.appAttributes.screenConfigurations
.getAppBarDestinations(context)
.length)
? widget.navigationShell.currentIndex
: currentNavBarIndex,
navigationShell: widget.navigationShell,
handleChangedNavBarIndex: (index) {
currentNavBarIndex = index;
widget.navigationShell.goBranch(index);
},
),
);
},
);
},
),
),
);
}