You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The mobile phone system is Chinese, if the app comes in in English for the first time, I change it to Chinese, set context.setLocale, and I see it succeeds in the console, but it doesn't change to Chinese in the app; It only worked when I changed to English and then to Chinese again.
Similar: if the mobile phone system is English, just opened the app if it is Chinese, I change to English, but also the console to see the success, the app in fact has not changed.
The mobile phone system is Chinese, if the app comes in in English for the first time, I change it to Chinese, set context.setLocale, and I see it succeeds in the console, but it doesn't change to Chinese in the app; It only worked when I changed to English and then to Chinese again.
Similar: if the mobile phone system is English, just opened the app if it is Chinese, I change to English, but also the console to see the success, the app in fact has not changed.
The console print is as follows:
[🌎 Easy Localization] [DEBUG] Load asset from assets/translations
[🌎 Easy Localization] [INFO] Locale zh changed
[🌎 Easy Localization] [DEBUG] Build
[🌎 Easy Localization] [DEBUG] Init Localization Delegate
[🌎 Easy Localization] [DEBUG] Init provider
[🌎 Easy Localization] [INFO] Locale zh saved
The result is as follows: This is the point that the system is Chinese, the first time to change from English to Chinese, but it does not work
my code
`import 'dart:ffi';
import 'dart:ui';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:get/get.dart';
import 'package:indonesia_qs_management/res/assets_res.dart';
import 'package:indonesia_qs_management/utils/text_style_config.dart';
import 'package:v_components/v_components.dart';
import 'package:v_components/widgets/radiogroup/radio_group.dart';
import '../../utils/colorConfig.dart';
import '../../utils/common_util.dart';
/// FileName set_locale_page
///
/// @author ThinkPad
/// @Date 2024/9/11 16:42
///
/// @description 更改语言
class SetLocalePage extends BasePage {
@OverRide
CommonBasePageState createBaseState() => _SetLocalePageState();
}
class _SetLocalePageState extends CommonBasePageState {
late String _currentLocaleStr;
List locals = [
// {"name": "language_system", "value": "system"},
{"name": "language_zh", "value": "zh","locale":const Locale("zh","")},
{"name": "language_en", "value": "en","locale":const Locale("en","")},
{"name": "language_id", "value": "id","locale":const Locale("id","")}
];
int currentIndex=-1;
int selectIndex=-1;
@OverRide
Widget buildPageWidget(BuildContext context) {
return Scaffold(
backgroundColor: ColorsUtil.hex2Color(pageBgColor),
appBar: CommonUtils.getAppBar(context,
title: context.tr("multilingual"),
actionView: InkWell(
onTap: ()async{
if(selectIndex==currentIndex)return;
}
@OverRide
void initBaseParams() {}
@OverRide
void initPageData() {
_currentLocaleStr = context.locale.toString();
VLog.w(context.deviceLocale.toString());
VLog.w(_currentLocaleStr);
}
_createLocales() {
return List.generate(locals.length, (index) {
return InkWell(
onTap: (){
setState(() {
selectIndex=index;
});
},
child: Container(
height: 50,
padding: const EdgeInsets.only(left: 10, right: 10),
decoration:
BoxDecoration(color: Colors.white, border: Border(bottom: BorderSide(color: ColorsUtil.hex2Color(filedBorderColor), width: 0.5))),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
context.tr(locals[index]["name"]),
style: style13Black,
),
Icon(
Icons.check_rounded,
size: 35,
color: selectIndex != index ? Colors.white : ColorsUtil.hex2Color(primaryColor),
)
],
),
),
);
});
}
}
`
The text was updated successfully, but these errors were encountered: