my_lang 0.0.1+1 copy "my_lang: ^0.0.1+1" to clipboard
my_lang: ^0.0.1+1 copied to clipboard

retracted

A library that provides flexible and easy-to-use localization support for Flutter applications.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:my_lang/my_lang.dart';

import 'languages/src.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await myLang.setUp(listLocale: listLocale);
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: OurLang.welcomeBack,
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: MyHomePage(title: OurLang.welcomeBackNameApp("Wong", "Lang") ?? ""),
    );
  }
}

const listLocale = [
  Locale('en'),
  Locale('vi'),
];

MyLang myLang = MyLang();

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @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(
              OurLang.youhavepushedthebuttonthismanytimes,
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headlineMedium,
            ),
            TextButton(
                onPressed: () {
                  myLang.loadFileJson(
                      locale: myLang.locale.isEnglish
                          ? const Locale("vi")
                          : const Locale("en"));
                },
                child: Text(OurLang.language))
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: OurLang.increment,
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
1
likes
0
points
18
downloads

Publisher

verified publisherwongcoupon.com

Weekly Downloads

A library that provides flexible and easy-to-use localization support for Flutter applications.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, intl, shared_preferences

More

Packages that depend on my_lang