createScaffold method
Widget
createScaffold(
- BuildContext context,
- _AppRouteDemoState stateWidget,
- L10nLocale currentLocale
Implementation
Widget createScaffold(BuildContext context, _AppRouteDemoState stateWidget,
L10nLocale currentLocale) {
final isLTR = currentLocale.getTextDirection(context) == TextDirection.ltr;
return Scaffold(
appBar: AppBar(
title: Stack(
children: <Widget>[
Container(
height: kToolbarHeight,
alignment: isLTR ? Alignment.centerLeft : Alignment.centerRight,
child: const Text(L10nApp.title,
style: TextStyle(color: Colors.white)),
),
Container(
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 0),
alignment: isLTR ? Alignment.centerRight : Alignment.centerLeft,
child: DropdownButton<L10nLocale>(
underline: const Text(''),
icon: const Icon(
Icons.language,
color: Colors.white,
),
onChanged: (L10nLocale? locale) {
stateWidget.changeLocale(locale);
},
value: currentLocale,
items: demo3Settings.locales
.map<DropdownMenuItem<L10nLocale>>(
(l) => DropdownMenuItem<L10nLocale>(
value: l,
child: Row(
children: <Widget>[WidgetHelper.getLocaleText(l)],
),
),
)
.toList(),
),
),
],
),
),
drawer: Drawer(
child: ListView(
children: AppRouteDemo.routes.keys
.map<ListTile>((key) => ListTile(
enabled: key != route,
title: Text(L10nApp.titles[key]!.$),
onTap: () {
if (Navigator.canPop(context)) {
Navigator.pushReplacementNamed(context, key);
}
}))
.toList(),
),
),
body: Scaffold(
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 10),
Center(
child:
Text(content.$, style: const TextStyle(fontSize: 20))),
const SizedBox(height: 30),
createBody()
],
),
),
));
}