main_app_strings 0.0.1
main_app_strings: ^0.0.1 copied to clipboard
is a localization package for Flutter applications that provides easy and efficient handling of translations. It supports dynamic loading of language resources based on the app's locale, with robust f [...]
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:main_app_strings/main_app_strings.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
supportedLocales: const [
Locale('en'),
Locale('ar'),
],
locale: const Locale('ar'),
localeResolutionCallback: (locale, supportedLocales) =>
supportedLocales.contains(locale) ? locale : const Locale('ar'),
localizationsDelegates: const [
MainAppStrings.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate
],
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(AppStrings.home),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
AppStrings.company,
style: const TextStyle(fontSize: 14),
),
Text(
AppStrings.confirmNewPassword,
style: const TextStyle(fontSize: 14),
),
Text(
AppStrings.country,
style: const TextStyle(fontSize: 14),
),
Text(
AppStrings.confirmAcceptCookies,
style: const TextStyle(fontSize: 14),
),
],
),
),
);
}
}