question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[flutter-freezed] Can't handle multiple line comments

See original GitHub issue
  1. Wrong part code generated Expected part 'app_models.freezed.dart'; Actual part 'app_models.dart';
  2. Can’t handle multiline comments
  3. @JsonKey in enums missing " and , end of the line Expected @JsonKey(name: "ACCOUNT_NOT_CONFIRMED") account_not_confirmed, Actual @JsonKey(name: ACCOUNT_NOT_CONFIRMED) account_not_confirmed
  4. Some key words generated in enums (in,is,do,void,default) but it’s depends on what graphql server gives https://demo.saleor.io/graphql/

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:3
  • Comments:18 (10 by maintainers)

github_iconTop GitHub Comments

5reactions
auaicncommented, Oct 22, 2022

I handled some issues on my branch and also updated tests.

  • 1. addFreezedImportStatements
  • 2. Every block generates its own comments, freezed Class block, factory block, parameter block
  • 3. @JsonKey
  • 4. Not sure I understand what you said here, please elaborate on that for me

Regarding Issue numbered 4 by @endigo

Some key words generated in enums (in,is,do,void,default) but it’s depends on what graphql server gives

What @endigo says might be explained with below example

@unfreezed
class NestedIntFilter with _$NestedIntFilter {
  const NestedIntFilter._();

  const factory NestedIntFilter({
    int? equals,
    int? gt,
    int? gte,
-   List<int>? in, // current result. It's as expected, but causes error
    int? lt,
    int? lte,
    NestedIntFilter? not,
    List<int>? notIn,
  }) = _NestedIntFilter;

  factory NestedIntFilter.fromJson(Map<String, Object?> json) => _NestedIntFilterFromJson(json);
}

There’s a lot of reserved keyword on dart language. see here dart language keywords

abstract, else, import, show, as, enum, in, static, assert, export, interface, super, async, extends, is, switch, await, extension, late, sync, break, external, library, this, case, factory, mixin, throw, catch, false, new, true, class, final, null, try, const, finally, on, typedef, continue, for, operator, var,

Is it okay if I append _(underscore) after like this?

@unfreezed
class NestedIntFilter with _$NestedIntFilter {
  const NestedIntFilter._();

  const factory NestedIntFilter({
    int? equals,
    int? gt,
    int? gte,
-   List<int>? in, // current result. It's as expected, but causes error
+   List<int>? in_,
    int? lt,
    int? lte,
    NestedIntFilter? not,
    List<int>? notIn,
  }) = _NestedIntFilter;

  factory NestedIntFilter.fromJson(Map<String, Object?> json) => _NestedIntFilterFromJson(json);
}

If there’s better solution, let me know.

Another handled Issues

@unfreezed
class NestedIntFilter with _$NestedIntFilter {
  const NestedIntFilter._();

  const factory NestedIntFilter({
    int? equals,
    int? gt,
    int? gte,
   List<int>? in,
    int? lt,
    int? lte,
    NestedIntFilter? not,
    List<int>? notIn,
  }) = _NestedIntFilter;

-  factory NestedIntFilter.fromJson(Map<String, Object?> json) => _NestedIntFilterFromJson(json); // current result, but not follows freezed spec
+  factory NestedIntFilter.fromJson(Map<String, Object?> json) => _$NestedIntFilterFromJson(json); // follows current freezed spec
}

@Parables It would be appreciate if you reply to me!

4reactions
Parablescommented, Oct 20, 2022

@charlypoly @endigo, I know of these issues because I am also using the plugin for my project. However, I am currently occupied with other activities that is why I haven’t fixed these issues.

@endigo, the plugin is quite simple, I would be very grateful if you could submit a PR for these fixes on the fluter-freezed-v3.0.0 branch.

As a guide, find the related codes to the issues you mentioned here

  1. addFreezedImportStatements
  2. Every block generates its own comments, freezed Class block, factory block, parameter block
  3. @JsonKey
  4. Not sure I understand what you said here, please elaborate on that for me

Thank you for fishing out these issues. Your contribution is greatly appreciated 🙏

@auaicn please find the source of these issues in the comment quoted above.

I’m currently under lots of pressure to meet multiple deadlines so I will be very grateful if you can help me out with a PR for these fixes

Read more comments on GitHub >

github_iconTop Results From Across the Web

dart - Flutter: Compilation issues with the packages Freezed ...
As per freezed documentation: The changes necessary to make it compatible with json_serializable consists of two lines: a new part: part ...
Read more >
freezed | Dart Package - Pub.dev
Implementing all of this can take hundreds of lines, which are error-prone and affect the readability of your model significantly. Freezed tries to...
Read more >
Unable to fold multiline method signatures and calls ... - GitHub
It looks like DartFoldingBuilder does not handle multi-line method signatures. (Although I didn't look too closely.) The Flutter plugin does ...
Read more >
How to use Freezed with Flutter - developer.school
If you're new to Flutter or haven't used immutable classes before, you may not see an immediate value in using freezed .
Read more >
Data Modeling with Flutter using freezed package
It wouldn't make sense to create data models when the data model you created does not reflect in the backend. Take a look...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found