r_flutter 0.1.0 r_flutter: ^0.1.0 copied to clipboard
Generate constants for resources which require using them as a String like fonts and assets.
R.Flutter #
Generate constants for resources which require using them as a String like fonts and assets.
Images
Instead of writing:
Image(image: AssetImage("assets/path/to/image.png"))
you can write:
Image(image: Images.image)
Fonts
Instead of writing:
TextStyle(
fontFamily: "Roboto",
)
you can write:
TextStyle(
fontFamily: Fonts.roboto,
)
Fonts
Instead of writing:
await rootBundle.loadString("assets/path/to/data.json")
you can write:
await rootBundle.loadString(Assets.data)
Generate code #
flutter packages pub run r_flutter:generate
Optional Parameters:
pubspec-file (pubspec.yaml)
Specify the pubspec file of the project
ignore-assets
Specify asset folder which should be ignored for generating constants. Seperated by ","
intl-file
Specify intl arb file to generate bindings for.
output-file (lib/r.g.dart)
Specify the output file.