Skip to content

Commit

Permalink
improve locale
Browse files Browse the repository at this point in the history
  • Loading branch information
lohanidamodar committed Apr 3, 2024
1 parent f425c98 commit a2d425b
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions lib/src/features/home_screen/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,23 @@ class _HomeScreenState extends State<HomeScreen> {
),
Consumer(builder: (context, ref, child) {
var locale = ref.watch(localeConfigProvider);
return DropdownButton<int>(
return DropdownButton<String>(
underline: const SizedBox(
height: 0,
),
elevation: 0,
value: locale.languageCode == 'ne' ? 1 : 2,
value: locale.languageCode,
items: [
DropdownMenuItem(
value: 1,
value: 'ne',
child: Flag.fromCode(
FlagsCode.NP,
height: 24,
width: 24,
),
),
DropdownMenuItem(
value: 2,
value: 'us',
child: Flag.fromCode(
FlagsCode.US,
width: 24,
Expand All @@ -62,15 +62,8 @@ class _HomeScreenState extends State<HomeScreen> {
),
],
onChanged: (value) {
switch (value) {
case 1:
locale = const Locale('ne', 'np');
break;
case 2:
default:
locale = Locale(Intl.systemLocale);
break;
}
if (value == null) return;
locale = Locale(value, value == 'ne' ? 'np' : 'us');
ref.read(localeConfigProvider.notifier).setLocale(locale);
});
}),
Expand Down

0 comments on commit a2d425b

Please sign in to comment.