Last updated:
0 purchases
modified localization
example #
Run in terminal : flutter pub run modified_localization:generate -o locale_keys.g.dart --source-dir /your_dir
example/resources/langs/en-EN.json #
{
"hi": "Hi !",
"welcome": "Welcome {}"
}
copied to clipboard
Will be generated strings class like this, then you can use it without .tr(), if arguments needed will be generated args function
abstract class Strings {
static String get hi => 'hi'.tr();
static String welcome(String arg0) {
return 'welcome'.tr(args: [arg0]);
}
}
copied to clipboard
example/lib/main.dart #
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(Strings.hi),
Text(Strings.welcome("Flutter")),
],
),
alignment: Alignment.center,
),
);
}
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.