nations 0.0.4 copy "nations: ^0.0.4" to clipboard
nations: ^0.0.4 copied to clipboard

outdated

queen support for localization in flutter, part of queen framework

example/lib/main.dart

import 'package:example/config/lang.dart';
import 'package:example/page2.dart';
import 'package:flutter/material.dart';

import 'package:nations/nations.dart';

Future<void> main() async {
  // TODO :: (2)
  await Nations.boot(AppLangConfig());

  // wrap your `MaterialApp` with NationsRoot
  runApp(
    // NationsRoot(
    //   child: const MyApp(),
    // ),
    NationsBuilder(
      builder: (ctx) => const MyApp(),
    ),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      // TODO :: (3) pass these parameters
      locale: Nations.locale,
      localizationsDelegates: Nations.delegates,
      supportedLocales: Nations.supportedLocales,
      builder: (context, child) => child!,

      /// end ot Nations params
      home: const MySc(),
    );
  }
}

class MySc extends StatelessWidget {
  const MySc({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    void _updateLocale() {
      //  TODO ::(5) update the locale
      // Nations.updateLocale(Locale(
      //   Nations.locale.languageCode == 'ar' ? 'en' : 'ar',
      // ));
      Navigator.push(
          context,
          MaterialPageRoute(
            builder: (context) => const PageTwo(),
          ));
    }

    return Scaffold(
      appBar: AppBar(title: const Text('امم  Nations')),
      body: const Center(
        child: Text('Go To Page 2'),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _updateLocale,
        child: const Icon(Icons.translate),
      ),
    );
  }
}
16
likes
0
points
221
downloads

Publisher

unverified uploader

Weekly Downloads

queen support for localization in flutter, part of queen framework

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

collection, flutter, flutter_localizations, shared_preferences

More

Packages that depend on nations