-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_localization_screen.dart
37 lines (34 loc) · 1.05 KB
/
test_localization_screen.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import '../main.dart';
class TestLocalizationScreen extends StatelessWidget {
const TestLocalizationScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('test_screen').tr(),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text('hello').tr(),
ElevatedButton(
onPressed: () {
String newLocale =
Localizations.localeOf(context).languageCode == 'en'
? 'ar'
: 'en';
EasyLocalization.of(context)?.setLocale(Locale(newLocale)).then((value) {
preferences.setString('lang', newLocale);
});
},
child: const Text('click').tr(),
),
],
),
),
);
}
}