'Multi-Language application with manual language choosing
I have an app and in the first interface I need to choose one language.
I'm only using two lang.
And I want the text on the login to to be in that lang I choosed.
Should I use Localization?
This is my main.dart
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: SplashScreen(),
routes :{
'lang' : (context) => Languagepage(),
'fr_version' :(context) => LoginFormfrancais(),
'ar_version' :(context) => LoginFormarabic(),
},
);
}
}
and this is the languages page where to choose: I only have two language:
class _LanguagepageState extends State<Languagepage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color.fromARGB(255, 4, 24, 54),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Color.fromARGB(255, 228, 116, 42),
onPrimary: Color.fromARGB(255, 4, 24, 54),
shadowColor: Colors.greenAccent,
elevation: 3,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(32.0)),
minimumSize: Size(900, 100), //////// HERE
),
onPressed: () {
Navigator.pushNamed(context, 'fr_version');
},
child: Text('FRANCAIS'),
),
ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Color.fromARGB(255, 228, 116, 42),
onPrimary: Color.fromARGB(255, 4, 24, 54),
shadowColor: Colors.greenAccent,
elevation: 3,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(32.0)),
minimumSize: Size(900, 100), //////// HERE
),
onPressed: () {
Navigator.pushNamed(context, 'ar_version');
},
child: Text('العربية'),
),
])));
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|