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

queen support for localization in flutter, part of queen

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:nations/nations.dart';

import 'page2.dart';

Future<void> main() async {
  // TODO :: (2)
  await Nations.boot();
  runApp(
    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
120
points
221
downloads

Publisher

unverified uploader

Weekly Downloads

queen support for localization in flutter, part of queen

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_localizations, flutter_readable, nations_assets, shared_preferences

More

Packages that depend on nations