Git Product home page Git Product logo

Comments (8)

rrousselGit avatar rrousselGit commented on September 25, 2024 3

If we're going with custom annotations, I would go with a @nullable annotation instead:

@freezed
abstract class MyClass with _$MyClass {
  factory MyClass({
    @required String notNullable,
    @required @nullable String nullable,
  }) = _MyClass;
}

Thought?

from freezed.

rrousselGit avatar rrousselGit commented on September 25, 2024 1

All properties unless:

  • they are annoted with @nullable
  • they are named parameters without a @required
  • they are positional optional parameter

from freezed.

rrousselGit avatar rrousselGit commented on September 25, 2024

I didn't add it because I can't think of any good enough syntax for it.
@required cannot be used here, because we can have required nullable parameters.

Unless you have a proposal (that doesn't rely on a custom annotation), then I'd prefer to wait for non-nullable types to land.
Non-nullable types should remove the need for such an assertion.

from freezed.

carlowenig avatar carlowenig commented on September 25, 2024

Would it be possible to check if the package "non_null" is installed and if so use its @nonNull annotation?

from freezed.

passsy avatar passsy commented on September 25, 2024

I'd love to have this. This way I could replace all my "data classes" with freezed classes.
I'd add a @nonNull annotation to this project.

from freezed.

rrousselGit avatar rrousselGit commented on September 25, 2024

Now that freezed will have an annotation package, it should be fine.

from freezed.

carlowenig avatar carlowenig commented on September 25, 2024

I like it! Will only @required properties be checked for null or all properties which are not annoted with @nullable?

from freezed.

rrousselGit avatar rrousselGit commented on September 25, 2024

This will also be applied to copyWith and the future copyAs by the way.

from freezed.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.