sound_fonts

Creator: coderz1093

Last updated:

0 purchases

TODO
Add to Cart

Description:

sound fonts

sound_fonts #
sound_fonts is a build_runner package generating Fonts class to encapsulate all the fonts your Flutter application uses with the easy and understandable namings.

Getting started
Usage

Getting started #
Simply add the package to your pubspec.yaml:
dependencies:
sound_fonts: ^0.1.1
copied to clipboard
or from GitHub directly:
dependencies:
sound_fonts:
git: https://github.com/lapuske/sound_fonts
copied to clipboard
Usage #
Detailed example is placed under /example directory.
Basically you define the annotation and run the build_runner:
import 'package:flutter/rendering.dart';
import 'package:sound_fonts/sound_fonts.dart';

part 'main.g.dart';

@SoundFonts({
'largest': {
'bold': ['onBackground', 'primary'],
'regular': ['onBackground', 'primary'],
},
'large': {
'bold': ['onBackground', 'primary', 'secondary'],
'regular': ['onBackground', 'onPrimary'],
},
})
class AnnotatedFonts {}
copied to clipboard
This generates a file with the following class (getters and lerp omitted):
class Fonts {
Fonts({
required TextStyle style,
required double largest,
required double large,
required FontWeight bold,
required FontWeight regular,
required Color onBackground,
required Color primary,
required Color secondary,
required Color onPrimary,
}) : largest = Largest(
style: style.copyWith(fontSize: largest),
bold: bold,
regular: regular,
onBackground: onBackground,
primary: primary,
),
large = Large(
style: style.copyWith(fontSize: large),
bold: bold,
regular: regular,
onBackground: onBackground,
primary: primary,
secondary: secondary,
onPrimary: onPrimary,
);

final Largest largest;
final Large large;
}
copied to clipboard
Your application is expected to construct it with the parameters it requires:
final fonts = Fonts(
style: TextStyle(fontFamily: '123'),
largest: 27,
large: 24,
bold: FontWeight.bold,
regular: FontWeight.regular,
onBackground: Colors.white,
primary: Colors.blue,
secondary: Colors.grey,
onPrimary: Colors.black,
);
copied to clipboard
The generated class may even be included to your Theme.of in the ThemeExtension form:
class FontsExtension extends ThemeExtension<Fonts> {
// ...
}

void main() {
runApp(
MaterialApp(
theme: ThemeData.light().copyWith(
extensions: [FontsExtension()],
),
),
);
}
copied to clipboard
Then, throughout the application you may use the fonts in the following manner:
@override
Widget build(BuildContext context) {
return Text('Hello', style: );
}
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files:

Customer Reviews

There are no reviews.