flutter_fonts_jp 0.1.0
flutter_fonts_jp: ^0.1.0 copied to clipboard

Japanese fonts for flutter apps.

flutter_fonts_jp #

Japanese fonts for flutter apps.

Motivation #

By default, flutter test uses the font called Ahem that simply shows spaces, makes golden tests less valuable. flutter_fonts_jp provides Japanese fonts for testing.

Usage #

First, add flutter_fonts_jp to dev_dependencies:

# pubspec.yaml
dev_dependences:
    flutter_fonts_jp:

Next, make sure that flutter.assets in pubspec.yaml contains at least one file/directory. This is required to tells flutter to bundle fonts. If you app does not use any assets, add a dummy (empty) directory.

# pbuspec.yaml
flutter:
    assets:
        - images/

Lastly call loadJapaneseFont in tests.

testWidgets('golden test', (WidgetTester tester) async {
    await loadJapaneseFont();
    await tester.pumpWidget(App());
    await expectLater(find.byType(App), matchesGoldenFile('app.png'));
});

A golden file look something like this (it uses the real font instead of the blank one).

golden_file.png

Gotchas #

Golden files can differ based on flutter version or platform https://github.com/flutter/flutter/issues/36667. We use linux and the latest stable flutter version for golden files.

0
likes
80
pub points
2%
popularity

Publisher

anipos.co.jp

Japanese fonts for flutter apps.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache 2.0 (LICENSE)

Dependencies

flutter, flutter_test

More

Packages that depend on flutter_fonts_jp