world_countries 0.8.0 copy "world_countries: ^0.8.0" to clipboard
world_countries: ^0.8.0 copied to clipboard

Sealed world data in form of Flutter widgets (country, phone, currency pickers, etc.).

example/lib/main.dart

import "package:flutter/material.dart";
import "package:flutter_localizations/flutter_localizations.dart";
import "package:url_strategy/url_strategy.dart";
import "package:world_countries/world_countries.dart";

import "app_navigator.dart";
import "model/world_data.dart";
import "routing/delegate.dart";
import "routing/parser.dart";
import "routing/route_state.dart";
import "theme/color_schemes.g.dart";

void main() {
  setPathUrlStrategy();
  runApp(const Main());
}

class Main extends StatefulWidget {
  const Main({super.key});

  @override
  State<Main> createState() => _MainState();
}

class _MainState extends State<Main> {
  final _navigatorKey = GlobalKey<NavigatorState>();
  late final SimpleRouterDelegate _routerDelegate;
  late final TemplateRouteParser _routeParser;
  late final RouteState _routeState;

  @override
  void initState() {
    super.initState();
    _routeParser = TemplateRouteParser(allowedPaths: WorldData.paths);
    _routeState = RouteState(_routeParser);
    _routerDelegate = SimpleRouterDelegate(
      routeState: _routeState,
      builder: (_) => AppNavigator(_navigatorKey),
      navigatorKey: _navigatorKey,
    );
  }

  @override
  void dispose() {
    _routerDelegate.dispose();
    _routeState.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) => RouteStateScope(
        notifier: _routeState,
        child: MaterialApp.router(
          routeInformationParser: _routeParser,
          routerDelegate: _routerDelegate,
          theme: ThemeData(useMaterial3: true, colorScheme: lightColorScheme),
          localizationsDelegates: const [
            GlobalMaterialLocalizations.delegate,
            GlobalCupertinoLocalizations.delegate,

            /// Add this [TypedLocaleDelegate] for automatic locale detection
            /// and translations using in the pickers.
            TypedLocaleDelegate(
              localeMapResolution: [
                LocaleEntry(
                  /// Brazilian Portuguese could be mapped to Euro Portuguese.
                  Locale("pt", "BR"),
                  IsoLocale(LangPor(), country: CountryPrt()),
                ),
              ],
            ),
          ],
          supportedLocales: [
            for (final locale in kMaterialSupportedLanguages) Locale(locale),
            const Locale("pt", "PT"),
            const Locale("pt", "BR"),
          ],
        ),
      );
}
17
likes
0
pub points
80%
popularity

Publisher

verified publishertsin.is

Sealed world data in form of Flutter widgets (country, phone, currency pickers, etc.).

Repository (GitHub)
View/report issues

Topics

#picker #pickers #country-picker #country-selector #currency-picker

License

unknown (license)

Dependencies

flutter, sealed_countries

More

Packages that depend on world_countries