Skip to content

Proposal to add EdgeInsetsDirectional.copyWith #137475

@Craftplacer

Description

@Craftplacer

Is there an existing issue for this?

Use case

While trying to make my app RTL-aware, I noticed that it is not possible to simply swap out EdgeInsets with EdgeInsetsDirectional as it lacks the copyWith method, which is necessary for immutable data structures like this one.

Proposal

In flutter/packages/flutter/lib/src/painting/edge_insets.dart

/* ... */
class EdgeInsetsDirectional extends EdgeInsetsGeometry {
  /* ... */
	
  /// Creates a copy of this EdgeInsetsDirectional but with the given
  /// fields replaced with the new values.
  EdgeInsetsDirectional copyWith({
    double? start,
    double? top,
    double? end,
    double? bottom,
  }) {
    return EdgeInsetsDirectional.only(
      start: start ?? this.start,
      top: top ?? this.top,
      end: end ?? this.end,
      bottom: bottom ?? this.bottom,
    );
  }

  /* ... */
}
/* ... */

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions