fluent_localization 1.6.1 copy "fluent_localization: ^1.6.1" to clipboard
fluent_localization: ^1.6.1 copied to clipboard

Package that allows you to set up and use translations in an easy and quick way

example/lib/main.dart

import 'package:fluent_localization/fluent_localization.dart';
import 'package:fluent_localization_example/localization_keys.g.dart';
import 'package:flutter/material.dart';

void main() async {
  await Fluent.build([LocalizationModule()]);
  runApp(MainApp(localizationApi: Fluent.get()));
}

class MainApp extends StatelessWidget {
  const MainApp({super.key, required this.localizationApi});

  final LocalizationApi localizationApi;

  @override
  Widget build(BuildContext context) {
    // Define your supported locales
    final locales = [const Locale("en"), const Locale("es")];
    // Get localization delegates
    final localizationDelegates = localizationApi.getDelegates(locales);

    return MaterialApp(
      localizationsDelegates: localizationDelegates,
      supportedLocales: locales,
      home: Scaffold(
        appBar: AppBar(
          title: Builder(builder: (context) => Text(context.loc.homeTitle)),
        ),
        body: Builder(
          builder: (context) {
            return Center(
              child: Column(
                mainAxisAlignment: MainManager.center,
                children: [
                  Text(context.loc.welcome),
                  const SizedBox(height: 16),
                  Text(context.loc.hello(name: 'Developer')),
                  const SizedBox(height: 16),
                  Text(
                    context.loc.homeDescription,
                    style: const TextStyle(fontStyle: FontStyle.italic),
                  ),
                ],
              ),
            );
          },
        ),
      ),
    );
  }
}

class MainManager {
  static const center = MainAxisAlignment.center;
}
1
likes
0
points
428
downloads

Publisher

unverified uploader

Weekly Downloads

Package that allows you to set up and use translations in an easy and quick way

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

fluent_localization_api, fluent_logger_api, fluent_sdk, flutter, flutter_localizations

More

Packages that depend on fluent_localization