easy_localization_yaml 0.1.2 copy "easy_localization_yaml: ^0.1.2" to clipboard
easy_localization_yaml: ^0.1.2 copied to clipboard

YAML loader for easy_localization package. Supports assets from packages and ignoring errors. No redundant dependencies.

example/lib/main.dart

import 'package:easy_localization/easy_localization.dart';
import 'package:easy_localization_yaml/easy_localization_yaml.dart';
import 'package:flutter/material.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await EasyLocalization.ensureInitialized();

  runApp(
    EasyLocalization(
      assetLoader: const YamlAssetLoader(directory: 'assets/translations'),
      fallbackLocale: const Locale('en'),
      path: 'unused',
      startLocale: const Locale('en'),
      supportedLocales: const [Locale('en')],
      child: MyApp(),
    ),
  );
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'easy_localization_yaml',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: MyHomePage(),

      // NEW
      locale: context.locale,
      localizationsDelegates: context.localizationDelegates,
      supportedLocales: context.supportedLocales,
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text('hello'.tr()),
      ),
    );
  }
}
1
likes
160
pub points
59%
popularity

Publisher

verified publisherainkin.com

YAML loader for easy_localization package. Supports assets from packages and ignoring errors. No redundant dependencies.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT-0 (license)

Dependencies

easy_localization, flutter, yaml

More

Packages that depend on easy_localization_yaml