Unverified Commit 43dc3fcf authored by Tirth's avatar Tirth Committed by GitHub

Added EdgeInsetsDirectional.copyWith (#137559)

Added `EdgeInsetsDirectional.copyWith` named constructor.

Fixes #137475
parent b1f5d96a
......@@ -904,6 +904,22 @@ class EdgeInsetsDirectional extends EdgeInsetsGeometry {
return EdgeInsets.fromLTRB(start, top, end, bottom);
}
}
/// 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,
);
}
}
class _MixedEdgeInsets extends EdgeInsetsGeometry {
......
......@@ -279,4 +279,10 @@ void main() {
expect(const EdgeInsetsDirectional.only(top: 4.0).add(const EdgeInsets.only(right: 3.0)).toString(), 'EdgeInsets(0.0, 4.0, 3.0, 0.0)');
expect(const EdgeInsetsDirectional.only(start: 4.0).add(const EdgeInsets.only(left: 3.0)).toString(), 'EdgeInsets(3.0, 0.0, 0.0, 0.0) + EdgeInsetsDirectional(4.0, 0.0, 0.0, 0.0)');
});
test('EdgeInsetsDirectional copyWith', () {
const EdgeInsetsDirectional sourceEdgeInsets = EdgeInsetsDirectional.only(start: 1.0, top: 2.0, bottom: 3.0, end: 4.0);
final EdgeInsetsDirectional copy = sourceEdgeInsets.copyWith(start: 5.0, top: 6.0);
expect(copy, const EdgeInsetsDirectional.only(start: 5.0, top: 6.0, bottom: 3.0, end: 4.0));
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment