Flutter plugin for scanning and generating QR codes using the ZXing library, supporting Android, iOS, and desktop platforms
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

46 lines
1.4 KiB

import 'package:flutter/material.dart';
import '../configs/app_store.dart';
import '../generated/l10n.dart';
import '../utils/extensions.dart';
class LanguageWidget extends StatelessWidget {
const LanguageWidget({super.key, required this.onChanged});
final Function(Locale) onChanged;
@override
Widget build(BuildContext context) {
return DropdownButton<Locale>(
value: appStore.selectedLanguage.parseLocale(),
underline: const SizedBox(),
onChanged: (Locale? value) async {
if (value != null) {
await S.load(value);
appStore.setLanguage(value.toString());
onChanged(value);
}
},
selectedItemBuilder: (BuildContext context) {
return S.delegate.supportedLocales
.map((Locale e) => DropdownMenuItem<Locale>(
value: e,
child: SizedBox(
width: 80,
child: Text(
e.countryCode?.toLangIcon() ?? '',
style: Theme.of(context).textTheme.headline5,
textAlign: TextAlign.right,
),
),
))
.toList();
},
items: S.delegate.supportedLocales
.map((Locale e) => DropdownMenuItem<Locale>(
value: e,
child: Text(e.countryCode?.toLangName() ?? ''),
))
.toList(),
);
}
}