Skip to content

if-null operator disables type checking #3843

Open
@abdallah-elsehaily

Description

@abdallah-elsehaily

When using if-null operator ?? in property initialization of a class properties it disables the type checking as I will be able to assign bool to int as follows

class CustomerDetails {
  int numOfDays;

  CustomerDetails.fromJson(Map<String, dynamic> json)
      : numOfDays = false ?? json['numOfDays'] ?? false;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    requestRequests to resolve a particular developer problemtype-inferenceType inference, issues or improvements

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions