spacing_generator 0.1.0 spacing_generator: ^0.1.0 copied to clipboard
Code generation for spacings in Flutter. Automatically generate SizedBoxes and Paddings from defined sizes.
Spacing Generator #
Installation #
spacing_generator
depends on these packages to work:
In your pubspec.yaml
add the following dependencies:
dependencies:
spacing_generator_annotations: ^0.0.2
dev_dependencies:
spacing_generator: ^0.0.2
build_runner: any
Usage #
This package allows to simply generate spacings from a file like
import 'package:flutter/material.dart'; // don't forget to import material
@Spacing()
class SpaceValues {
static const tiny = 2.0;
static const small = 4.0;
}
Run the build_runner
to generate code:
dart run build_runner build
It creates an extension that allows to use spacings and paddings like:
Widget build(BuildContext context) {
return Padding(
padding: context.paddings.allTiny,
child: Column(
children: [
const Text('Hello'),
context.spacings.horizontalSmall,
const Text('World'),
]
)
);
}
For more information see the example
in the repository.