locale_sync 1.1.10 locale_sync: ^1.1.10 copied to clipboard
An easy-to-use internationalization package for Flutter
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'translations/locale_sync.dart';
void main() async {
await LocaleSync.setup(
apiToken: "eac2ddb1-8c41-418c-bd6e-8645cb6bc822",
repositoryId: "repository:zxfn0nqr1a194y69u4fa",
);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
// locale: const Locale("pt"),
supportedLocales: const [
Locale("en"),
Locale("en", "US"),
Locale("en", "CA"),
Locale("pt"),
Locale("pt", "BR"),
],
localizationsDelegates: [
LocaleSync.delegate,
GlobalCupertinoLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
LocaleSync.of(context).helloMyFriend(name: "Marian"),
),
],
),
),
);
}
}