equatable_macro 0.0.1-main.1 copy "equatable_macro: ^0.0.1-main.1" to clipboard
equatable_macro: ^0.0.1-main.1 copied to clipboard

A Dart library providing a macro for automatic implementation of the Equatable

equatable_macro (Pre-release: 0.0.1-main.1) #

A Dart package providing a macro to automatically make classes equatable, inspired by the equatable package. This is a pre-release version and may contain experimental features.

Features #

  • Automatically implements equality and hashCode for your classes.
  • Easy to use with minimal boilerplate.
  • Generates a toString() method to provide a string representation of your objects.

Installation #

Add the following to your pubspec.yaml:

dependencies:
  equatable_macro: ^0.0.1-main.1

Add the following to your analysis_options.yaml:

analyzer:
  enable-experiment:
    - macros

Usage #

Import the package and use the @Equatable() annotation:

import 'package:equatable_macro/equatable_macro.dart';

@Equatable() //or @Equatable(stringify: true)
class Example {
  final int id;
  final String name;

  const Example(this.id, this.name);
}

Example #

// lib/main.dart
import 'package:equatable_macro/equatable_macro.dart';

void main() {
  var a = Example(1, 'a');
  var b = Example(1, 'a');
  var c = Example(2, 'b');

  print(a == b); // true
  print(a == c); // false
}

@Equatable() //or @Equatable(stringify: true)
class Example {
  final int id;
  final String name;

  const Example(this.id, this.name);
}

Run #

dart --enable-experiment=macros run lib/main.dart
@Equatable(stringify: true) macro applied to a class Demonstration of the @Equatable(stringify: true) macro in use
Screenshot 1 Screenshot 2

Benchmarks #

Benchmarks for this package are yet to be added. Stay tuned for updates.

Special Thanks #

Contributing #

Contributions are welcome! Please submit pull requests or create issues for any improvements or bugs you find.

Github Repo

If you find this project helpful, consider sponsoring it on GitHub:

Github Sponsor

Follow on YouTube For more tutorials and project walkthroughs, subscribe to our YouTube channel:

@Antinna YouTube Channel


Maintained by Manish Gautam



Powered By Antinna

0
likes
140
points
25
downloads
screenshot

Publisher

verified publishertakeitall.news

Weekly Downloads

A Dart library providing a macro for automatic implementation of the Equatable

Repository (GitHub)
View/report issues
Contributing

Topics

#equatable #macros #utilities #hascode #equality

Documentation

Documentation
API reference

Funding

Consider supporting this project:

github.com

License

MIT (license)

Dependencies

collection, macros

More

Packages that depend on equatable_macro