locale_settings 1.0.0 copy "locale_settings: ^1.0.0" to clipboard
locale_settings: ^1.0.0 copied to clipboard

A plugin which supports to change the current language on an os level.

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:locale_settings/locale_settings.dart';

void main() {
  runApp(const MyApp());
}

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

  final _localeSettingsPlugin = const LocaleSettings();

  @override
  Widget build(BuildContext context) {
    final controller = TextEditingController();

    return LocaleListener(
      builder: (final _, final locale) {
        return MaterialApp(
          home: Scaffold(
            appBar: AppBar(
              title: const Text('Plugin example app'),
            ),
            body: Center(
              child: Column(
                mainAxisSize: MainAxisSize.min,
                children: [
                  Text('Locale: $locale'),
                  TextField(controller: controller),
                  TextButton(
                    onPressed: () async {
                      final parts = controller.text.split('-');
                      _localeSettingsPlugin.setCurrentLocale(Locale(parts[0], parts[1]));
                    },
                    child: const Text('Change Language'),
                  ),
                ],
              ),
            ),
          ),
        );
      }
    );
  }
}
1
likes
140
points
43
downloads

Publisher

verified publisheropdehipt.com

Weekly Downloads

A plugin which supports to change the current language on an os level.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on locale_settings