wyatt_component_copy_with_extension (2.0.1)

Published 2023-05-03 09:52:23 +00:00 by hugo in Wyatt-FOSS/wyatt-packages

Installation

dart pub add wyatt_component_copy_with_extension:2.0.1 --hosted-url=

About this package

Extension for component copy with feature.

Component Copy With Extension

Style: Wyatt Analysis SDK: Dart & Flutter

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.

  1. We create the component in the wyatt_ui_components , add the ComponentProxyExtension annotation and generate the code. This component does not have any specific implementation, and only have a set of properties.
  2. Now we implement the component in our ui kit, wyatt_ui_kit , add the ComponentCopyWithExtension annotation and generate the code. This component has a specific implementation and can be used in the application.
  3. 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.

Details
Pub
2023-05-03 09:52:23 +00:00
394
15 KiB
Assets (1)
2.0.1.tar.gz 15 KiB
Versions (2) View all
2.0.1 2023-05-03
2.0.0 2023-04-13