wyatt_component_copy_with_extension (2.0.1)
Installation
dart pub add wyatt_component_copy_with_extension:2.0.1 --hosted-url=
About this package
Component Copy With Extension
This package provides annotations for generating code and simplifying the use of an UI kit within a Flutter application. The package contains only the annotation classes.
This package does not contain Flutter specific code, but there is no sense in using it without Flutter.
Summary
ComponentProxyExtension
- Annotation class for generating a proxy of a component of an UI kit.ComponentCopyWithExtension
- Annotation class for generating the copyWith method of a component implementation.
For example, let's say we have a component of an UI kit that we want to use in our application.
- We create the component in the
wyatt_ui_components
, add theComponentProxyExtension
annotation and generate the code. This component does not have any specific implementation, and only have a set of properties. - Now we implement the component in our ui kit,
wyatt_ui_kit
, add theComponentCopyWithExtension
annotation and generate the code. This component has a specific implementation and can be used in the application. - But we can implement multiple ui kits, and each of them can have their own implementation of the same component. And at the top of the application tree we can use the
wyatt_ui_components
package, which contains only the proxy of the component.
In that way, the application is UI kit agnostic, and we can easily change the UI kit without changing the code of the application.
We will use the LoaderComponent
component as an example in this documentation.
Annotation Classes
ComponentProxyExtension
This annotation class is used to annotate a new component of an UI kit in the wyatt_ui_components
package. It generates the abstract proxy of the component and allows access to all its properties in different packages and throughout the application.
part 'loader_component.g.dart';
@ComponentProxyExtension()
abstract class LoaderComponent extends Component
with CopyWithMixin<$LoaderComponentCWProxy> {
const LoaderComponent({
...
});
}
ComponentCopyWithExtension
This annotation class is used to annotate the implementation of components directly in the application. It generates the implementation of the proxy and the mixin to ensure that the component meets the specifications defined in the wyatt_ui_components package
.
part 'loader.g.dart';
@ComponentCopyWithExtension()
class Loader extends LoaderComponent with $LoaderCWMixin {
const Loader({
...
});
}
Additional features
The skipFields field allows you to directly and specifically change a field. This makes it easier to use. You can disable it through annotation.