Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add operator==, hashCode and debugFillProperties. #19

Closed
InAnadea opened this issue Jun 28, 2022 · 3 comments
Closed

How to add operator==, hashCode and debugFillProperties. #19

InAnadea opened this issue Jun 28, 2022 · 3 comments

Comments

@InAnadea
Copy link

flutter 3.0.2
theme_tailor_annotation 1.0.0
theme_tailor 1.0.1

Example code:

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:theme_tailor_annotation/theme_tailor_annotation.dart';

part 'ng_theme.tailor.dart';

@Tailor(
  themes: ['light'],
  themeGetter: ThemeGetter.onBuildContext,
)
class _$NgTheme {
  static const List<Color> test = [Colors.black];
}

Generated code:

// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint, unused_element

part of 'ng_theme.dart';

// **************************************************************************
// ThemeTailorGenerator
// **************************************************************************

class NgTheme extends ThemeExtension<NgTheme> {
  NgTheme({
    required this.test,
  });

  final Color test;

  static final NgTheme light = NgTheme(
    test: _$NgTheme.test[0],
  );

  @override
  NgTheme copyWith({
    Color? test,
  }) {
    return NgTheme(
      test: test ?? this.test,
    );
  }

  @override
  NgTheme lerp(ThemeExtension<NgTheme>? other, double t) {
    if (other is! NgTheme) return this;
    return NgTheme(
      test: Color.lerp(test, other.test, t)!,
    );
  }
}

extension NgThemeBuildContext on BuildContext {
  NgTheme get ngTheme => Theme.of(this).extension<NgTheme>()!;
}

Expected result:
debugFillProperties must be generated
operator == must be generated
hashCode must be generated

@Rongix
Copy link
Collaborator

Rongix commented Jun 29, 2022

Hello there, thanks for opening the issue.
Both of the mentioned features are already developed and will be available in the next release (very soon);
Hash code and == operator: #18
Flutter's diagnosticable (debug fill properties): #15

@Rongix
Copy link
Collaborator

Rongix commented Jun 29, 2022

There is a new release with the mentioned features available. Please upgrade packages to the newest versions. There are a lot of changes, so please read the release notes and updated readme. In summary, to add support for 'debugFillProperties'; add the following import to the file:

import 'package:flutter/foundation.dart';

theme_tailor_annotation 1.0.1
theme_tailor 1.0.2

@InAnadea
Copy link
Author

Thank you!

@Rongix Rongix closed this as completed Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants