From 9ce3f76c5353fa2caa6350adb1a2cc6f65ba92f2 Mon Sep 17 00:00:00 2001 From: allysonjp715 <30459667+allysonjp715@users.noreply.github.com> Date: Tue, 23 Feb 2021 16:41:03 +0000 Subject: [PATCH] Add a EdgeInsetsDirectional.all constructor similar to EdgeInsets.all (#76542) --- .../flutter/lib/src/painting/edge_insets.dart | 16 ++++++++++++++++ .../flutter/test/painting/edge_insets_test.dart | 2 ++ 2 files changed, 18 insertions(+) diff --git a/packages/flutter/lib/src/painting/edge_insets.dart b/packages/flutter/lib/src/painting/edge_insets.dart index 2282fdfd498..2b5ad063b26 100644 --- a/packages/flutter/lib/src/painting/edge_insets.dart +++ b/packages/flutter/lib/src/painting/edge_insets.dart @@ -663,6 +663,22 @@ class EdgeInsetsDirectional extends EdgeInsetsGeometry { this.bottom = 0.0, }); + /// Creates insets where all the offsets are `value`. + /// + /// {@tool snippet} + /// + /// Typical eight-pixel margin on all sides: + /// + /// ```dart + /// const EdgeInsetsDirectional.all(8.0) + /// ``` + /// {@end-tool} + const EdgeInsetsDirectional.all(double value) + : start = value, + top = value, + end = value, + bottom = value; + /// An [EdgeInsetsDirectional] with zero offsets in each direction. /// /// Consider using [EdgeInsets.zero] instead, since that object has the same diff --git a/packages/flutter/test/painting/edge_insets_test.dart b/packages/flutter/test/painting/edge_insets_test.dart index 09a1fdd4bfc..95223974c58 100644 --- a/packages/flutter/test/painting/edge_insets_test.dart +++ b/packages/flutter/test/painting/edge_insets_test.dart @@ -54,6 +54,8 @@ void main() { test('EdgeInsets.resolve()', () { expect(const EdgeInsetsDirectional.fromSTEB(10.0, 20.0, 30.0, 40.0).resolve(TextDirection.ltr), const EdgeInsets.fromLTRB(10.0, 20.0, 30.0, 40.0)); expect(const EdgeInsetsDirectional.fromSTEB(99.0, 98.0, 97.0, 96.0).resolve(TextDirection.rtl), const EdgeInsets.fromLTRB(97.0, 98.0, 99.0, 96.0)); + expect(const EdgeInsetsDirectional.all(50.0).resolve(TextDirection.ltr), const EdgeInsets.fromLTRB(50.0, 50.0, 50.0, 50.0)); + expect(const EdgeInsetsDirectional.all(50.0).resolve(TextDirection.rtl), const EdgeInsets.fromLTRB(50.0, 50.0, 50.0, 50.0)); expect(const EdgeInsetsDirectional.only(start: 963.25).resolve(TextDirection.ltr), const EdgeInsets.fromLTRB(963.25, 0.0, 0.0, 0.0)); expect(const EdgeInsetsDirectional.only(top: 963.25).resolve(TextDirection.ltr), const EdgeInsets.fromLTRB(0.0, 963.25, 0.0, 0.0)); expect(const EdgeInsetsDirectional.only(end: 963.25).resolve(TextDirection.ltr), const EdgeInsets.fromLTRB(0.0, 0.0, 963.25, 0.0));