Skip to content

Object spread like TypeScript has #1781

Open
@petrnymsa

Description

@petrnymsa

Is there any chance to be able to spread objects like we can in TypeScript?

Consider following interface in TS (code simplified)

interface Props {
  a: number;
  b: number;
  c: number;
}

and React component A which accepts these Props

const componentA(props: Props) => <p>A is {props.a}> <ComponentB {...props} /> </p>

where ComponentB defines its props like

interface Props {
  b:number;
  c:number;
}

Why to have similar feature in Dart?

In Flutter especially, if we compose custom widgets I've finding myself many times passing around same arguments to nested widgets. Maintainance of such widgets becomes very troublesome.

Another significant added value is for mapping between objects like from DTO to Domain Entity where Domain Entity typically have nearly same properties + added functionality.

If such issue already exists, feel free to close it. I couldn't find it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureProposed language feature that solves one or more problems

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions