diff --git a/.pubignore b/.pubignore index a4d4961e0..f183cb319 100644 --- a/.pubignore +++ b/.pubignore @@ -1,4 +1,4 @@ -demo -website -widgetbook -tool \ No newline at end of file +demo/ +website/ +widgetbook/ +tool/ \ No newline at end of file diff --git a/analysis_options.yaml b/analysis_options.yaml index aacc11fd0..db7d4b7f2 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -15,14 +15,14 @@ analyzer: dart_code_metrics: extends: - - package:dart_code_metrics_presets/all.yaml + - package:dart_code_metrics_presets/recommended.yaml metrics-exclude: - test/** rules-exclude: - "test/**" rules: - no-object-declaration: false prefer-match-file-name: false + no-object-declaration: false prefer-single-widget-per-file: false parameters-ordering: false prefer-dedicated-media-query-methods: false @@ -35,7 +35,6 @@ dart_code_metrics: prefer-widget-private-members: false prefer-static-class: false avoid-late-keyword: false - avoid-barrel-files: false avoid-declaring-call-method: false avoid-long-parameter-list: false avoid-recursive-calls: false @@ -45,9 +44,8 @@ dart_code_metrics: prefer-correct-identifier-length: false avoid-unsafe-collection-methods: false avoid-similar-names: false - format-comment: false no-equal-arguments: false - prefer_initializing_formals: false + prefer-prefixed-global-constants: false avoid-returning-widgets: false avoid-nested-conditional-expressions: acceptable-level: 3 diff --git a/lib/src/attributes/border/border_radius_dto.dart b/lib/src/attributes/border/border_radius_dto.dart index e7fe14055..901b1dcdc 100644 --- a/lib/src/attributes/border/border_radius_dto.dart +++ b/lib/src/attributes/border/border_radius_dto.dart @@ -14,7 +14,6 @@ import '../../theme/tokens/radius_token.dart'; /// /// See also: /// - [BorderRadiusGeometry], which is the Flutter counterpart of this class. - @immutable class BorderRadiusGeometryDto extends Dto with Mergeable { diff --git a/lib/src/attributes/border/border_radius_util.dart b/lib/src/attributes/border/border_radius_util.dart index 98d670000..c0e5b1921 100644 --- a/lib/src/attributes/border/border_radius_util.dart +++ b/lib/src/attributes/border/border_radius_util.dart @@ -15,7 +15,7 @@ import 'border_radius_dto.dart'; /// /// Example usage: /// -/// ```dar +/// ```dart /// final attribute = borderRadius(10.0); /// ``` /// @@ -30,87 +30,43 @@ class BorderRadiusGeometryUtility const BorderRadiusGeometryUtility(super.builder) : super(valueToDto: BorderRadiusGeometryDto.from); - /// Returns a [BorderRadiusDirectionalUtility] to manipulate [BorderRadiusDirectional]. - /// - /// Example usage: - /// - /// ```dart - /// final attribute = borderRadius.directional(10.0); - /// ``` - /// - /// See also: - /// * [BorderRadiusDirectionalUtility], the utility class for manipulating [BorderRadiusDirectional] - /// * [BorderRadiusDirectionalAttribute], the attribute class for [BorderRadiusDirectional] - BorderRadiusDirectionalUtility get directional { + BorderRadiusDirectionalUtility get _directional { return BorderRadiusDirectionalUtility(builder); } - /// Returns a [RadiusUtility] to manipulate [Radius]. - /// - /// Example usage: - /// - /// ```dart - /// final attribute = borderRadius.circular(10.0); - /// ``` - /// - /// See also: - /// * [RadiusUtility], the utility class for manipulating [Radius] + /// Returns a [RadiusUtility] to manipulate [Radius] for bottomLeft corner. RadiusUtility get bottomLeft { return RadiusUtility((radius) => only(bottomLeft: radius)); } - /// Returns a [RadiusUtility] to manipulate [Radius]. - /// - /// Example usage: - /// - /// ```dart - /// final attribute = borderRadius.circular(10.0); - /// ``` - /// - /// See also: - /// * [RadiusUtility], the utility class for manipulating [Radius] + /// Returns a [RadiusUtility] to manipulate [Radius] for topStart corner. + RadiusUtility get topStart => _directional.topStart; + + /// Returns a [RadiusUtility] to manipulate [Radius] for topEnd corner. + RadiusUtility get topEnd => _directional.topEnd; + + /// Returns a [RadiusUtility] to manipulate [Radius] for bottomStart corner. + RadiusUtility get bottomStart => _directional.bottomStart; + + /// Returns a [RadiusUtility] to manipulate [Radius] for bottomEnd corner. + RadiusUtility get bottomEnd => _directional.bottomEnd; + + /// Returns a [RadiusUtility] to manipulate [Radius] for bottomRight corner. RadiusUtility get bottomRight { return RadiusUtility((radius) => only(bottomRight: radius)); } - /// Returns a [RadiusUtility] to manipulate [Radius]. - /// - /// Example usage: - /// - /// ```dart - /// final attribute = borderRadius.circular(10.0); - /// ``` - /// - /// See also: - /// * [RadiusUtility], the utility class for manipulating [Radius] + /// Returns a [RadiusUtility] to manipulate [Radius] for topLeft corner. RadiusUtility get topLeft { return RadiusUtility((radius) => only(topLeft: radius)); } - /// Returns a [RadiusUtility] to manipulate [Radius]. - /// - /// Example usage: - /// - /// ```dart - /// final attribute = borderRadius.circular(10.0); - /// ``` - /// - /// See also: - /// * [RadiusUtility], the utility class for manipulating [Radius] + /// Returns a [RadiusUtility] to manipulate [Radius] for topRight corner. RadiusUtility get topRight { return RadiusUtility((radius) => only(topRight: radius)); } - /// Applies radius to all corners. - /// - /// Example usage: - /// - /// ```dart - /// final attribute = borderRadius.all(10.0); - /// ``` - /// - /// See also: - /// * [RadiusUtility], the utility class for manipulating [Radius] + /// Returns a [RadiusUtility] to manipulate [Radius] for all corners. RadiusUtility get all { return RadiusUtility((radius) => only( topLeft: radius, @@ -120,136 +76,47 @@ class BorderRadiusGeometryUtility )); } - /// Applies radius to topRight and topLeft corners. - /// - /// Example usage: - /// - /// ```dart - /// final attribute = borderRadius.top(10.0); - /// ``` - /// - /// See also: - /// * [RadiusUtility], the utility class for manipulating [Radius] + /// Returns a [RadiusUtility] to manipulate [Radius] for topLeft and topRight corner. RadiusUtility get top { return RadiusUtility( (radius) => only(topLeft: radius, topRight: radius), ); } - /// Applies radius to bottomRight and bottomLeft corners. - /// - /// Example usage: - /// - /// ```dart - /// final attribute = borderRadius.bottom(10.0); - /// ``` - /// - /// See also: - /// * [RadiusUtility], the utility class for manipulating [Radius] + /// Returns a [RadiusUtility] to manipulate [Radius] for bottomLeft and bottomRight corner. RadiusUtility get bottom { return RadiusUtility( (radius) => only(bottomLeft: radius, bottomRight: radius), ); } - /// Applies radius to topLeft and bottomLeft corners. - /// - /// Example usage: - /// - /// ```dart - /// final attribute = borderRadius.left(10.0); - /// ``` - /// - /// See also: - /// * [RadiusUtility], the utility class for manipulating [Radius] + /// Returns a [RadiusUtility] to manipulate [Radius] for topLeft and bottomLeft corner. RadiusUtility get left { return RadiusUtility( (radius) => only(topLeft: radius, bottomLeft: radius), ); } - /// Applies radius to topRight and bottomRight corners. - /// - /// Example usage: - /// - /// ```dart - /// final attribute = borderRadius.right(10.0); - /// ``` - /// - /// See also: - /// * [RadiusUtility], the utility class for manipulating [Radius] + /// Returns a [RadiusUtility] to manipulate [Radius] for topRight and bottomRight corner. RadiusUtility get right { return RadiusUtility( (radius) => only(topRight: radius, bottomRight: radius), ); } - /// Applies radius topStart corner - /// - /// Example usage: - /// - /// ```dart - /// final attribute = borderRadius.topStart(10.0); - /// ``` - /// - /// See also: - /// * [RadiusUtility], the utility class for manipulating [Radius] - RadiusUtility get topStart { - return RadiusUtility((radius) => only(topStart: radius)); - } - - /// Applies radius topEnd corner - /// - /// Example usage: - /// - /// ```dart - /// final attribute = borderRadius.topEnd(10.0); - /// ``` - /// - /// See also: - /// * [RadiusUtility], the utility class for manipulating [Radius] - RadiusUtility get topEnd { - return RadiusUtility((radius) => only(topEnd: radius)); - } - - /// Applies radius bottomStart corner - /// - /// Example usage: - /// - /// ```dart - /// final attribute = borderRadius.bottomStart(10.0); - /// ``` - /// - /// See also: - /// * [RadiusUtility], the utility class for manipulating [Radius] - RadiusUtility get bottomStart { - return RadiusUtility((radius) => only(bottomStart: radius)); + /// Sets a circular [Radius] for all corners. + T circular(double radius) { + return all.circular(radius); } - /// Applies radius bottomEnd corner - /// - /// Example usage: - /// - /// ```dart - /// final attribute = borderRadius.bottomEnd(10.0); - /// ``` - /// - /// See also: - /// * [RadiusUtility], the utility class for manipulating [Radius] - RadiusUtility get bottomEnd { - return RadiusUtility((radius) => only(bottomEnd: radius)); + /// Sets an elliptical [Radius] for all corners. + T elliptical(double x, double y) { + return all.elliptical(x, y); } - /// Applies a Radius.zero to all corners - /// - /// Will apply to radius 0 to topLeft, topRight, bottomLeft and bottomRight + /// Sets a zero [Radius] for all corners. T zero() { - return only( - topLeft: Radius.zero, - topRight: Radius.zero, - bottomLeft: Radius.zero, - bottomRight: Radius.zero, - ); + return all.zero(); } // Only specific corners @@ -258,10 +125,6 @@ class BorderRadiusGeometryUtility Radius? topRight, Radius? bottomLeft, Radius? bottomRight, - Radius? topStart, - Radius? topEnd, - Radius? bottomStart, - Radius? bottomEnd, }) { return builder( BorderRadiusGeometryDto( @@ -269,36 +132,10 @@ class BorderRadiusGeometryUtility topRight: topRight, bottomLeft: bottomLeft, bottomRight: bottomRight, - topStart: topStart, - topEnd: topEnd, - bottomStart: bottomStart, - bottomEnd: bottomEnd, ), ); } - /// Sets the border radius for each corner of a [BorderRadiusGeometry]. - /// - /// This method allows setting distinct radii for each corner. Each parameter - /// represents a corner's radius, starting from top-left and moving clockwise. - /// - /// Parameters: - /// - [topLeft]: Radius for the top-left corner. - /// - [topRight]: Radius for the top-right corner. Defaults to [topLeft] if not provided. - /// - [bottomLeft]: Radius for the bottom-left corner. Defaults to [topLeft] if not provided. - /// - [bottomRight]: Radius for the bottom-right corner. Defaults to [topLeft] if not provided. - /// - /// Example usage: - /// ```dart - /// final borderRadiusUtility = BorderRadiusGeometryUtility(builder); - /// final attribute = borderRadiusUtility( - /// topLeft: 10.0, - /// topRight: 12.0, - /// bottomLeft: 8.0, - /// bottomRight: 10.0, - /// ); - /// ``` - T call(double p1, [double? p2, double? p3, double? p4]) { double topLeft = p1; double topRight = p1; @@ -338,16 +175,7 @@ class BorderRadiusDirectionalUtility const BorderRadiusDirectionalUtility(super.builder) : super(valueToDto: BorderRadiusGeometryDto.from); - /// Applies radius to all corners. - /// - /// Example usage: - /// - /// ```dart - /// final attribute = borderRadius.all(10.0); - /// ``` - /// - /// See also: - /// * [RadiusUtility], the utility class for manipulating [Radius] + /// Returns a [RadiusUtility] to manipulate [Radius] for all corners. RadiusUtility get all { return RadiusUtility((radius) => only( topStart: radius, @@ -357,30 +185,63 @@ class BorderRadiusDirectionalUtility )); } - /// Applies radius to topStart and topEnd corners. - /// - /// Example usage: - /// - /// ```dart - /// final attribute = borderRadius.top(10.0); - /// ``` - /// - /// See also: - /// * [RadiusUtility], the utility class for manipulating [Radius] - T get top { - return only(topStart: Radius.zero, topEnd: Radius.zero); + /// Returns a [RadiusUtility] to manipulate [Radius] for topStart and topEnd corner. + RadiusUtility get top { + return RadiusUtility((radius) => only(topStart: radius, topEnd: radius)); } - /// Applies radius to bottomStart and bottomEnd corners. - /// - /// Example usage: - /// - /// ```dart - /// final attribute = borderRadius.bottom(10.0); - /// ``` - /// - /// See also: - /// * [RadiusUtility], the utility class for manipulating [Radius] + /// Returns a [RadiusUtility] to manipulate [Radius] for bottomStart and bottomEnd corner. + RadiusUtility get bottom { + return RadiusUtility( + (radius) => only(bottomStart: radius, bottomEnd: radius), + ); + } + + /// Returns a [RadiusUtility] to manipulate [Radius] for topStart and bottomStart corner. + RadiusUtility get start { + return RadiusUtility( + (radius) => only(topStart: radius, bottomStart: radius), + ); + } + + /// Returns a [RadiusUtility] to manipulate [Radius] for topEnd and bottomEnd corner. + RadiusUtility get end { + return RadiusUtility( + (radius) => only(topEnd: radius, bottomEnd: radius), + ); + } + + /// Returns a [RadiusUtility] to manipulate [Radius] for topStart corner. + RadiusUtility get topStart { + return RadiusUtility((radius) => only(topStart: radius)); + } + + /// Returns a [RadiusUtility] to manipulate [Radius] for topEnd corner. + RadiusUtility get topEnd { + return RadiusUtility((radius) => only(topEnd: radius)); + } + + /// Returns a [RadiusUtility] to manipulate [Radius] for bottomStart corner. + RadiusUtility get bottomStart { + return RadiusUtility((radius) => only(bottomStart: radius)); + } + + /// Returns a [RadiusUtility] to manipulate [Radius] for bottomEnd corner. + RadiusUtility get bottomEnd { + return RadiusUtility((radius) => only(bottomEnd: radius)); + } + + T circular(double radius) { + return all.circular(radius); + } + + T elliptical(double x, double y) { + return all.elliptical(x, y); + } + + T zero() { + return all.zero(); + } T call(double p1, [double? p2, double? p3, double? p4]) { double topStart = p1; @@ -417,7 +278,14 @@ class BorderRadiusDirectionalUtility ); } - // Only specific corners + /// Creates a [BorderRadiusGeometryDto] with the specified radius values for each corner. + /// + /// The [topStart] parameter represents the radius of the top-left corner. + /// The [topEnd] parameter represents the radius of the top-right corner. + /// The [bottomStart] parameter represents the radius of the bottom-left corner. + /// The [bottomEnd] parameter represents the radius of the bottom-right corner. + /// + /// Returns the created [T] object. T only({ Radius? topStart, Radius? topEnd, @@ -433,6 +301,4 @@ class BorderRadiusDirectionalUtility ), ); } - - T zero() => all.zero(); } diff --git a/lib/src/attributes/border/border_util.dart b/lib/src/attributes/border/border_util.dart index 4595e5bf2..c577473e2 100644 --- a/lib/src/attributes/border/border_util.dart +++ b/lib/src/attributes/border/border_util.dart @@ -7,16 +7,16 @@ import '../color/color_util.dart'; import '../scalars/scalar_util.dart'; import 'border_dto.dart'; -/// Utility class for creating and manipulating [BoxBorder] attributes. +/// Utility class for creating and manipulating [BorderSideDto] attributes. /// -/// Accepts a [builder] function that takes a [BoxBorderDto] and returns an object of type [T]. +/// Accepts a [builder] function that takes a [BorderSideDto] and returns an object of type [T]. /// /// Example usage: /// /// ```dart -/// final border = BoxBorderUtility(builder); +/// final borderSide = BorderSideUtility(builder); /// -/// final attribute = border( +/// final attribute = borderSide( /// color: Colors.red, /// width: 2.0, /// style: BorderStyle.solid, @@ -24,14 +24,63 @@ import 'border_dto.dart'; /// ); /// ``` /// +/// `attribute` will hold a [T] with a [BorderSideDto] that has color as red, width as 2.0, and BorderStyle as solid. +/// /// See also: -/// * [BoxBorder], which is a class for creating box borders. -/// * [BoxBorderDto], which is a data transfer object for [BoxBorder]. -class BoxBorderUtility +/// * [BorderSideDto], which is a data transfer object for [BorderSide]. +class BorderSideUtility + extends MixUtility { + const BorderSideUtility(super.builder); + + T _only({ + ColorDto? color, + double? width, + BorderStyle? style, + double? strokeAlign, + }) { + return builder(BorderSideDto( + color: color, + strokeAlign: strokeAlign, + style: style, + width: width, + )); + } + + /// Returns a [ColorUtility] to manipulate [Color] of the [BorderSideDto] + ColorUtility get color => ColorUtility((color) => _only(color: color)); + + /// Returns a [BorderStyleUtility] to manipulate [BorderStyle] of the [BorderSideDto] + BorderStyleUtility get style => + BorderStyleUtility((style) => _only(style: style)); + + /// Sets the width of the [BorderSideDto] + T width(double width) => call(width: width); + + /// Sets the stroke align of the [BorderSideDto] + T strokeAlign(double strokeAlign) => call(strokeAlign: strokeAlign); + + /// Creates a [BorderSideDto] with the provided parameters and calls the [builder] function. + T call({ + Color? color, + double? width, + BorderStyle? style, + double? strokeAlign, + }) { + final side = BorderSideDto( + color: color?.toDto(), + strokeAlign: strokeAlign, + style: style, + width: width, + ); + + return builder(side); + } +} + +class BorderUtility extends DtoUtility { /// Constructor for creating an instance of the class. - const BoxBorderUtility(super.builder) : super(valueToDto: BoxBorderDto.from); - + const BorderUtility(super.builder) : super(valueToDto: BoxBorderDto.from); BoxBorderDto _symmetric({ BorderSideDto? vertical, BorderSideDto? horizontal, @@ -48,265 +97,64 @@ class BoxBorderUtility return BoxBorderDto(top: side, bottom: side, left: side, right: side); } + T _only({ + BorderSideDto? top, + BorderSideDto? bottom, + BorderSideDto? left, + BorderSideDto? right, + }) { + return builder( + BoxBorderDto(top: top, bottom: bottom, left: left, right: right), + ); + } + + BorderDirectionalUtility get _directional => + BorderDirectionalUtility((border) => builder(border)); + + /// Method to set the border on the start side + BorderSideUtility get start => _directional.start; + + /// Method to set the border on the end side + BorderSideUtility get end => _directional.end; + /// Method to set the border on all sides. - /// - /// Returns a `BorderSideUtility` object for applying border attributes - /// to all sides of a box. This method is useful for setting consistent border styles - /// around the entire box. - /// - /// Example usage: - /// - /// ```dart - /// final attribute = border.all( - /// color: Colors.red, - /// width: 2.0, - /// ); - /// ``` - /// - /// `attribute` will hold a [T] with a [BorderAttribute] that applies - /// a red color and a width of 2.0 uniformly to all border sides. - /// - /// See also: - /// * [BorderSideUtility], which is effective for simultaneously configuring [BorderSide] attributes on all sides. BorderSideUtility get all { return BorderSideUtility((side) => builder(_fromBorderSide(side))); } /// Method to set the border on the bottom side. - /// - /// Returns a `BorderSideUtility` object for configuring border attributes - /// specifically for the bottom side of a box. This utility enables precise control - /// over the appearance of the bottom border. - /// - /// Example usage: - /// - /// ```dart - /// final attribute = border.bottom( - /// color: Colors.blue, - /// width: 3.0, - /// style: BorderStyle.solid, - /// strokeAlign: 0.5, - /// ); - /// ``` - /// - /// `attribute` will create a [T] with a [BorderAttribute] for the bottom border, - /// - /// See also: - /// * [BorderSideUtility], which offers specialized manipulation of individual [BorderSide] attributes. BorderSideUtility get bottom { - return BorderSideUtility((side) => only(bottom: side)); + return BorderSideUtility((side) => _only(bottom: side)); } /// Method to set the border on the top side. - /// - /// Returns a `BorderSideUtility` object for configuring border attributes - /// specifically for the top side of a box. This utility enables precise control - /// over the appearance of the top border. - /// - /// Example usage: - /// - /// ```dart - /// final attribute = border.top( - /// color: Colors.blue, - /// width: 3.0, - /// style: BorderStyle.solid, - /// strokeAlign: 0.5, - /// ); - /// ``` - /// - /// `attribute` will create a [T] with a [BorderAttribute] for the top border, - /// - /// See also: - /// * [BorderSideUtility], which offers specialized manipulation of individual [BorderSide] attributes. BorderSideUtility get top { - return BorderSideUtility((side) => only(top: side)); + return BorderSideUtility((side) => _only(top: side)); } /// Method to set the border on the left side. - /// - /// Returns a `BorderSideUtility` object for configuring border attributes - /// specifically for the left side of a box. This utility enables precise control - /// over the appearance of the left border. - /// - /// Example usage: - /// - /// ```dart - /// final attribute = border.left( - /// color: Colors.blue, - /// width: 3.0, - /// style: BorderStyle.solid, - /// strokeAlign: 0.5, - /// ); - /// ``` - /// - /// `attribute` will create a [T] with a [BoxBorderDto] for the left border, - /// - /// See also: - /// * [BorderSideUtility], which offers specialized manipulation of individual [BorderSide] attributes. BorderSideUtility get left { - return BorderSideUtility((side) => only(left: side)); + return BorderSideUtility((side) => _only(left: side)); } /// Method to set the border on the right side. - /// - /// Returns a `BorderSideUtility` object for configuring border attributes - /// specifically for the right side of a box. This utility enables precise control - /// over the appearance of the right border. - /// - /// Example usage: - /// - /// ```dart - /// final attribute = border.right( - /// color: Colors.blue, - /// width: 3.0, - /// style: BorderStyle.solid, - /// strokeAlign: 0.5, - /// ); - /// ``` - /// - /// `attribute` will create a [T] with a [BoxBorderDto] for the right border, - /// - /// See also: - /// * [BorderSideUtility], which offers specialized manipulation of individual [BorderSide] attributes. BorderSideUtility get right { - return BorderSideUtility((side) => only(right: side)); + return BorderSideUtility((side) => _only(right: side)); } - /// Method to set the border on the start side in a directional context. - /// - /// Returns a `BorderSideUtility` designed for applying border attributes - /// specifically to the start side of a directional box layout. - /// - /// Example usage: - /// - /// ```dart - /// final boxBorder = BoxBorderUtility(builder); - /// final attribute = boxBorder.start( - /// color: Colors.purple, - /// width: 2.5, - /// ); - /// ``` - /// - /// In this example, `attribute` will be built with a [BoxBorderDto] - /// that applies a purple color and a width of 2.5 to the start side of the border. - /// - /// See also: - /// * [BorderSideUtility], which is utilized for modifying [BorderSide] attributes. - BorderSideUtility get start => - BorderSideUtility((side) => only(start: side)); - - /// Method to set the border on the end side in a directional context. - /// - /// Creates a `BorderSideUtility` object for applying border attributes - /// to the end side of a directional box layout. - /// - /// Example usage: - /// - /// ```dart - /// final boxBorder = BoxBorderUtility(builder); - /// final attribute = boxBorder.end( - /// color: Colors.orange, - /// width: 2.0, - /// ); - /// ``` - /// - /// Here, `attribute` will be built with a [BoxBorderDto] configured - /// with an orange color and a width of 2.0 for the end border side. - /// - /// See also: - /// * [BorderSideUtility], which helps in configuring [BorderSide] attributes for directional layouts. - BorderSideUtility get end => BorderSideUtility((side) => only(end: side)); - /// Method to set the borders on the vertical sides. - /// - /// Returns a `BorderSideUtility` object for applying border attributes - /// to both the left and right sides of a box at the same time. - /// - /// Example usage: - /// - /// ```dart - /// final attribute = border.vertical( - /// color: Colors.indigo, - /// width: 1.5, - /// style: BorderStyle.solid, - /// strokeAlign: 0.5, - /// ); - /// - /// In this instance, `attribute` will be built with a [BoxBorderDto] - /// that applies an indigo color and a width of 1.5 to both the left and right border sides. - /// - /// See also: - /// * [BorderSideUtility], which aids in setting [BorderSide] attributes for vertical borders. BorderSideUtility get vertical { return BorderSideUtility((side) => builder(_symmetric(vertical: side))); } /// Method to set the borders on the horizontal sides. - /// - /// Returns a `BorderSideUtility` object for applying border attributes - /// to both the top and bottom sides of a box simultaneously. - /// - /// Example usage: - /// - /// ```dart - /// final attribute = border.horizontal( - /// color: Colors.teal, - /// width: 1.0, - /// style: BorderStyle.solid, - /// strokeAlign: 0.5, - /// ); - /// - /// `attribute` will contain a [T] with a [BoxBorderDto] that applies - /// a teal color and a width of 1.0 to both the top and bottom border sides. - /// - /// See also: - /// * [BorderSideUtility], which facilitates simultaneous configuration of horizontal [BorderSide] attributes. BorderSideUtility get horizontal { return BorderSideUtility( (side) => builder(_symmetric(horizontal: side)), ); } - BoxBorderDto fromBorderSide(BorderSideDto side) { - return BoxBorderDto(top: side, bottom: side, left: side, right: side); - } - - T only({ - BorderSideDto? top, - BorderSideDto? bottom, - BorderSideDto? left, - BorderSideDto? right, - BorderSideDto? start, - BorderSideDto? end, - }) { - return builder( - BoxBorderDto( - top: top, - bottom: bottom, - left: left, - right: right, - start: start, - end: end, - ), - ); - } - /// Creates a [BoxBorderDto] with the provided parameters and calls the [builder] function. - /// - /// Example usage: - /// - /// ```dart - /// final boxBorder = BoxBorderUtility(builder); - /// final attribute = boxBorder( - /// color: Colors.red, - /// width: 2.0, - /// style: BorderStyle.solid, - /// strokeAlign: 0.5, - /// ); - /// ``` - /// - /// Attribute now holds a [StyleAttribute] with a [BoxBorderDto] that - /// has color as red, width as 2.0, and BorderStyle as solid. T call({ Color? color, double? width, @@ -322,140 +170,85 @@ class BoxBorderUtility } } -/// Utility class for creating and manipulating [BorderSideDto] attributes. -/// -/// Accepts a [builder] function that takes a [BorderSideDto] and returns an object of type [T]. -/// -/// Example usage: -/// -/// ```dart -/// final borderSide = BorderSideUtility(builder); -/// -/// final attribute = borderSide( -/// color: Colors.red, -/// width: 2.0, -/// style: BorderStyle.solid, -/// strokeAlign: 0.5, -/// ); -/// ``` -/// -/// `attribute` will hold a [T] with a [BorderSideDto] that has color as red, width as 2.0, and BorderStyle as solid. -/// -/// See also: -/// * [BorderSideDto], which is a data transfer object for [BorderSide]. -class BorderSideUtility - extends MixUtility { - const BorderSideUtility(super.builder); +class BorderDirectionalUtility + extends DtoUtility { + /// Constructor for creating an instance of the class. + const BorderDirectionalUtility(super.builder) + : super(valueToDto: BoxBorderDto.from); + + BoxBorderDto _symmetric({ + BorderSideDto? vertical, + BorderSideDto? horizontal, + }) { + return BoxBorderDto( + top: horizontal, + bottom: horizontal, + start: vertical, + end: vertical, + ); + } + + BoxBorderDto _fromBorderSide(BorderSideDto side) { + return BoxBorderDto(top: side, bottom: side, start: side, end: side); + } T _only({ - ColorDto? color, - double? width, - BorderStyle? style, - double? strokeAlign, + BorderSideDto? top, + BorderSideDto? bottom, + BorderSideDto? start, + BorderSideDto? end, }) { - return builder(BorderSideDto( - color: color, - strokeAlign: strokeAlign, - style: style, - width: width, - )); + return builder( + BoxBorderDto(top: top, bottom: bottom, start: start, end: end), + ); } - /// Method to set the color of the [BorderSideDto] - /// - /// Returns a `ColorUtility` object for applying color attributes - /// to the [BorderSideDto]. - /// - /// Example usage: - /// - /// ```dart - /// final borderSide = BorderSideUtility(builder); - /// final attribute = borderSide.color(Colors.red); - /// ``` - /// - /// `attribute` will hold a [T] with a [BorderSideDto] that has color as red. - /// - /// See also: - /// * [ColorUtility], which is a utility class for manipulating [Color] attributes. - /// * [ColorDto], which is a data transfer object for [Color]. - ColorUtility get color => ColorUtility((color) => _only(color: color)); + /// Method to set the border on all sides. + BorderSideUtility get all { + return BorderSideUtility((side) => builder(_fromBorderSide(side))); + } - /// Method to set the style of the [BorderSideDto] - /// - /// Returns a [BorderStyleUtility] object for applying scalar attributes - /// - /// Example usage: - /// - /// ```dart - /// final borderSide = BorderSideUtility(builder); - /// final attribute = borderSide.style.solid(); - /// ``` - /// - /// `attribute` will hold a [T] with a [BorderSideDto] that has style as solid. - /// - /// See also: - /// * [BorderStyleUtility], which is a utility class for manipulating [BorderStyle] attributes. - BorderStyleUtility get style => - BorderStyleUtility((style) => _only(style: style)); + /// Method to set the border on the bottom side. + BorderSideUtility get bottom { + return BorderSideUtility((side) => _only(bottom: side)); + } - /// Method to set the width of the [BorderSideDto] - /// - /// Accepts a [double] value as a parameter. - /// - /// Example usage: - /// - /// ```dart - /// final borderSide = BorderSideUtility(builder); - /// final attribute = borderSide.width(2.0); - /// ``` - /// - /// `attribute` will hold a [T] with a [BorderSideDto] that has width as 2.0. - T width(double width) => call(width: width); + /// Method to set the border on the top side. + BorderSideUtility get top { + return BorderSideUtility((side) => _only(top: side)); + } - /// Method to set the stroke align of the [BorderSideDto] - /// - /// Accepts a [double] value as a parameter. - /// - /// Example usage: - /// - /// ```dart - /// final borderSide = BorderSideUtility(builder); - /// final attribute = borderSide.strokeAlign(0.5); - /// ``` - /// - /// `attribute` will hold a [T] with a [BorderSideDto] that has stroke align as 0.5. - T strokeAlign(double strokeAlign) => call(strokeAlign: strokeAlign); + /// Method to set the border on the start side in a directional context. + BorderSideUtility get start => + BorderSideUtility((side) => _only(start: side)); + + /// Method to set the border on the end side in a directional context. + BorderSideUtility get end => BorderSideUtility((side) => _only(end: side)); + + /// Method to set the borders on the vertical sides. + BorderSideUtility get vertical { + return BorderSideUtility((side) => builder(_symmetric(vertical: side))); + } + + /// Method to set the borders on the horizontal sides. + BorderSideUtility get horizontal { + return BorderSideUtility( + (side) => builder(_symmetric(horizontal: side)), + ); + } - /// Method that allows to set individual properties of the [BorderSideDto] to all sides. - /// - /// Example usage: - /// - /// ```dart - /// final borderSide = BorderSideUtility(builder); - /// final attribute = borderSide( - /// color: Colors.red, - /// width: 2.0, - /// style: BorderStyle.solid, - /// strokeAlign: 0.5, - /// ); - /// - /// attribute will hold a [T] with a [BorderSideDto] that has color as red, width as 2.0, style as solid, and stroke align as 0.5. - /// - /// See also: - /// * [BorderSideDto], which is a data transfer object for [BorderSide]. + /// Creates a [BoxBorderDto] with the provided parameters and calls the [builder] function. T call({ Color? color, double? width, BorderStyle? style, double? strokeAlign, }) { - final side = BorderSideDto( - color: color?.toDto(), + return all( + color: color, strokeAlign: strokeAlign, style: style, width: width, ); - - return builder(side); } } diff --git a/lib/src/attributes/constraints/constraints_util.dart b/lib/src/attributes/constraints/constraints_util.dart index a915cccd6..a6a8ad266 100644 --- a/lib/src/attributes/constraints/constraints_util.dart +++ b/lib/src/attributes/constraints/constraints_util.dart @@ -41,7 +41,7 @@ class BoxConstraintsUtility /// /// Attribute now holds a [T] with a [BoxConstraintsDto] that has a maxWidth value of `100`. DoubleUtility get maxWidth { - return DoubleUtility((value) => call(maxWidth: value)); + return DoubleUtility((value) => call(maxWidth: value)); } /// Sets the minimum width of the box constraints. @@ -56,7 +56,7 @@ class BoxConstraintsUtility /// /// Attribute now holds a [T] with a [BoxConstraintsDto] that has a minWidth value of `100`. DoubleUtility get minWidth { - return DoubleUtility((value) => call(minWidth: value)); + return DoubleUtility((value) => call(minWidth: value)); } /// Sets the minimum height of the box constraints. @@ -72,7 +72,7 @@ class BoxConstraintsUtility /// /// Attribute now holds a [T] with a [BoxConstraintsDto] that has a minHeight value of `100`. DoubleUtility get minHeight { - return DoubleUtility((value) => call(minHeight: value)); + return DoubleUtility((value) => call(minHeight: value)); } /// Sets the maximum height of the box constraints. @@ -88,7 +88,7 @@ class BoxConstraintsUtility /// /// Attribute now holds a [T] with a [BoxConstraintsDto] that has a maxHeight value of `100`. DoubleUtility get maxHeight { - return DoubleUtility((value) => call(maxHeight: value)); + return DoubleUtility((value) => call(maxHeight: value)); } T call({ diff --git a/lib/src/attributes/decoration/decoration_util.dart b/lib/src/attributes/decoration/decoration_util.dart index 38a51882a..a6c9ca303 100644 --- a/lib/src/attributes/decoration/decoration_util.dart +++ b/lib/src/attributes/decoration/decoration_util.dart @@ -62,8 +62,14 @@ class BoxDecorationUtility return ColorUtility((ColorDto color) => _only(color: color)); } - BoxBorderUtility get border { - return BoxBorderUtility((border) => _only(border: border)); + BorderUtility get border { + return BorderUtility((border) => _only(border: border)); + } + + BorderDirectionalUtility get borderDirectional { + return BorderDirectionalUtility((borderDirectional) { + return _only(border: borderDirectional); + }); } BorderRadiusGeometryUtility get borderRadius { @@ -72,6 +78,12 @@ class BoxDecorationUtility ); } + BorderRadiusDirectionalUtility get borderRadiusDirectional { + return BorderRadiusDirectionalUtility( + (borderRadiusDirectional) => _only(borderRadius: borderRadiusDirectional), + ); + } + BoxShapeUtility get shape { return BoxShapeUtility((BoxShape shape) => _only(shape: shape)); } diff --git a/lib/src/attributes/shadow/shadow_util.dart b/lib/src/attributes/shadow/shadow_util.dart index 5c36a652e..cb5c4dbc1 100644 --- a/lib/src/attributes/shadow/shadow_util.dart +++ b/lib/src/attributes/shadow/shadow_util.dart @@ -232,14 +232,7 @@ class ElevationUtility const ElevationUtility(super.builder); /// Method to set elevation based on material design standards. - /// - /// Example usage: - /// - /// ```dart - /// final attribute = elevation.two(); - /// ``` - /// - /// Attribute now holds a list of [BoxShadowDto] corresponding to a material elevation of `2`. + /// You can pass 0, 1, 2, 3, 4, 6, 8, 9, 12, 16, 24 to this method. T call(int value) { assert(kElevationToShadow.containsKey(value), 'Invalid elevation value'); diff --git a/lib/src/core/attributes_map.dart b/lib/src/core/attributes_map.dart index aaeb1b7da..0a58d76bc 100644 --- a/lib/src/core/attributes_map.dart +++ b/lib/src/core/attributes_map.dart @@ -14,7 +14,7 @@ class AttributeMap with Comparable { const AttributeMap.empty() : _map = null; factory AttributeMap(Iterable attributes) { - return AttributeMap._(_mergeMap(attributes)); + return AttributeMap._(_mergeMap(attributes)); } static LinkedHashMap _mergeMap( @@ -57,8 +57,7 @@ class AttributeMap with Comparable { Attr? attributeOfType() => _map?[Attr] as Attr?; - Iterable whereType() => - _map?.values.whereType() ?? []; + Iterable whereType() => _map?.values.whereType() ?? []; AttributeMap merge(AttributeMap? other) { return other == null ? this : AttributeMap([...values, ...other.values]); diff --git a/lib/src/core/extensions/iterable_ext.dart b/lib/src/core/extensions/iterable_ext.dart index 8166a3c70..b9e9ad0a8 100644 --- a/lib/src/core/extensions/iterable_ext.dart +++ b/lib/src/core/extensions/iterable_ext.dart @@ -34,7 +34,7 @@ extension ListExt on List { final otherLength = other.length; final maxLength = max(listLength, otherLength); - return List.generate(maxLength, (int index) { + return List.generate(maxLength, (int index) { if (index < listLength && index < otherLength) { final currentValue = this[index]; final otherValue = other[index]; diff --git a/lib/src/deprecations.dart b/lib/src/deprecations.dart index c0001f55a..caa9e5c5e 100644 --- a/lib/src/deprecations.dart +++ b/lib/src/deprecations.dart @@ -122,11 +122,11 @@ final bl = border.left; @Deprecated('Use border.right instead') final br = border.right; -@Deprecated('Use border.start instead') -final bs = border.start; +@Deprecated('Use borderDirectional.start instead') +final bs = borderDirectional.start; -@Deprecated('Use border.end instead') -final be = border.end; +@Deprecated('Use borderDirectional.end instead') +final be = borderDirectional.end; @Deprecated('Use alignment instead') final align = alignment; @@ -292,10 +292,10 @@ final borderBottom = border.bottom; final borderLeft = border.left; @Deprecated('Use border.right instead') final borderRight = border.right; -@Deprecated('Use border.start instead') -final borderStart = border.start; -@Deprecated('Use border.end instead') -final borderEnd = border.end; +@Deprecated('Use borderDirectional.start instead') +final borderStart = borderDirectional.start; +@Deprecated('Use borderDirectional.end instead') +final borderEnd = borderDirectional.end; @Deprecated('Use border.horizontal instead') final borderHorizontal = border.horizontal; @Deprecated('Use border.vertical instead') @@ -376,16 +376,16 @@ final roundedBL = borderRadius.bottomLeft; final roundedBR = borderRadius.bottomRight; @Deprecated(kShortAliasDeprecation) -final roundedTS = borderRadius.topStart; +final roundedTS = borderRadiusDirectional.topStart; @Deprecated(kShortAliasDeprecation) -final roundedTE = borderRadius.topEnd; +final roundedTE = borderRadiusDirectional.topEnd; @Deprecated(kShortAliasDeprecation) -final roundedBS = borderRadius.bottomStart; +final roundedBS = borderRadiusDirectional.bottomStart; @Deprecated(kShortAliasDeprecation) -final roundedBE = borderRadius.bottomEnd; +final roundedBE = borderRadiusDirectional.bottomEnd; @Deprecated('Use stack.alignment instead') final zAlignment = stack.alignment; diff --git a/lib/src/factory/mix_provider_data.dart b/lib/src/factory/mix_provider_data.dart index eac745d8c..ca42ba6ef 100644 --- a/lib/src/factory/mix_provider_data.dart +++ b/lib/src/factory/mix_provider_data.dart @@ -75,7 +75,7 @@ class MixData with Comparable { } Iterable whereType() { - return _attributes.whereType(); + return _attributes.whereType(); } bool contains() { diff --git a/lib/src/helpers/compare_mixin.dart b/lib/src/helpers/compare_mixin.dart index 2dfe6d72c..46d1f6e7e 100644 --- a/lib/src/helpers/compare_mixin.dart +++ b/lib/src/helpers/compare_mixin.dart @@ -1,5 +1,3 @@ -// ignore_for_file: avoid-mutating-parameters - import 'package:flutter/material.dart'; import '../core/extensions/iterable_ext.dart'; diff --git a/lib/src/specs/container/box_util.dart b/lib/src/specs/container/box_util.dart index efcda8e7a..1a804735f 100644 --- a/lib/src/specs/container/box_util.dart +++ b/lib/src/specs/container/box_util.dart @@ -66,8 +66,12 @@ const box = BoxSpecUtility(); /// - [BorderRadiusGeometryUtility] /// - [BoxSpecAttribute] final border = box.border; +final borderDirectional = box.borderDirectional; + final borderRadius = box.borderRadius; +final borderRadiusDirectional = box.borderRadiusDirectional; + /// `backgroundColor` - A Utility for defining [BoxDecoration] color value for a [Box] widget final backgroundColor = box.color; @@ -328,7 +332,13 @@ class BoxSpecUtility extends SpecUtility { BorderRadiusGeometryUtility get borderRadius => decoration.borderRadius; - BoxBorderUtility get border => decoration.border; + BorderRadiusDirectionalUtility + get borderRadiusDirectional => decoration.borderRadiusDirectional; + + BorderUtility get border => decoration.border; + + BorderDirectionalUtility get borderDirectional => + decoration.borderDirectional; BoxShadowListUtility get shadows => decoration.boxShadows; diff --git a/lib/src/specs/flex/flex_attribute.dart b/lib/src/specs/flex/flex_attribute.dart index 0523b2638..537ef3c35 100644 --- a/lib/src/specs/flex/flex_attribute.dart +++ b/lib/src/specs/flex/flex_attribute.dart @@ -28,7 +28,7 @@ class FlexSpecAttribute extends SpecAttribute { }); static FlexSpecAttribute of(MixData mix) { - return mix.attributeOf() ?? const FlexSpecAttribute(); + return mix.attributeOf() ?? const FlexSpecAttribute(); } @override diff --git a/lib/src/specs/flex/flex_widget.dart b/lib/src/specs/flex/flex_widget.dart index 80f805eac..f2a8b1cab 100644 --- a/lib/src/specs/flex/flex_widget.dart +++ b/lib/src/specs/flex/flex_widget.dart @@ -1,8 +1,9 @@ +// ignore_for_file: prefer_const_constructors + import 'package:flutter/widgets.dart'; import '../../core/styled_widget.dart'; import '../../deprecations.dart'; -import '../../factory/mix_provider.dart'; import '../../factory/mix_provider_data.dart'; import '../../factory/style_mix.dart'; import '../../utils/helper_util.dart'; @@ -50,7 +51,7 @@ class StyledFlex extends StyledWidget { class MixedFlex extends StatelessWidget { const MixedFlex({ super.key, - this.mix, + required this.mix, this.decoratorOrder = const [], required this.children, required this.direction, @@ -59,11 +60,10 @@ class MixedFlex extends StatelessWidget { final List children; final Axis direction; final List decoratorOrder; - final MixData? mix; + final MixData mix; @override Widget build(BuildContext context) { - final mix = this.mix ?? MixProvider.of(context); final spec = FlexSpec.of(mix); final gap = spec.gap; @@ -90,7 +90,7 @@ class MixedFlex extends StatelessWidget { List buildChildren(double? gap) { if (gap == null) return children; - return List.generate( + return List.generate( children.length, (index) => index == children.length - 1 ? children[index] @@ -188,7 +188,8 @@ class FlexBox extends StyledWidget { Widget build(BuildContext context) { return withMix(context, (mix) { return MixedBox( - child: MixedFlex(direction: direction, children: children), + mix: mix, + child: MixedFlex(mix: mix, direction: direction, children: children), ); }); } @@ -245,5 +246,4 @@ class VBox extends FlexBox { }) : super(style: style ?? mix, direction: Axis.vertical); } -final _defaultFlex = - Flex(direction: Axis.horizontal, children: const []); +final _defaultFlex = Flex(direction: Axis.horizontal, children: const []); diff --git a/lib/src/specs/stack/stack_attribute.dart b/lib/src/specs/stack/stack_attribute.dart index 480906109..fe4a48dec 100644 --- a/lib/src/specs/stack/stack_attribute.dart +++ b/lib/src/specs/stack/stack_attribute.dart @@ -20,7 +20,7 @@ class StackSpecAttribute extends SpecAttribute { _alignment = alignment; static StackSpecAttribute of(MixData mix) { - return mix.attributeOf() ?? const StackSpecAttribute(); + return mix.attributeOf() ?? const StackSpecAttribute(); } @override diff --git a/lib/src/specs/stack/stack_widget.dart b/lib/src/specs/stack/stack_widget.dart index 4f7dba1c9..805fa0fbd 100644 --- a/lib/src/specs/stack/stack_widget.dart +++ b/lib/src/specs/stack/stack_widget.dart @@ -66,7 +66,7 @@ class MixedStack extends StatelessWidget { textDirection: spec.textDirection, fit: spec.fit ?? _defaultStack.fit, clipBehavior: spec.clipBehavior ?? _defaultStack.clipBehavior, - children: children ?? const [], + children: children ?? const [], ); } } diff --git a/lib/src/theme/material/material_theme.dart b/lib/src/theme/material/material_theme.dart index 97334d88b..fa667e996 100644 --- a/lib/src/theme/material/material_theme.dart +++ b/lib/src/theme/material/material_theme.dart @@ -1,4 +1,3 @@ -// ignore_for_file: deprecated_member_use, avoid-non-null-assertion import 'package:flutter/material.dart'; import '../mix_theme.dart'; diff --git a/lib/src/theme/tokens/token_util.dart b/lib/src/theme/tokens/token_util.dart index 76ab67242..5ba4c695b 100644 --- a/lib/src/theme/tokens/token_util.dart +++ b/lib/src/theme/tokens/token_util.dart @@ -14,33 +14,30 @@ const $textStyles = TextStyleTokenUtil(); @immutable class RadiiTokenUtil { - const RadiiTokenUtil(); - final small = RadiusToken.small; final medium = RadiusToken.medium; final large = RadiusToken.large; + const RadiiTokenUtil(); } @immutable class SpaceTokenUtil { - const SpaceTokenUtil(); - final xsmall = SpaceToken.xsmall; final small = SpaceToken.small; final medium = SpaceToken.medium; final large = SpaceToken.large; final xlarge = SpaceToken.xlarge; final xxlarge = SpaceToken.xxlarge; + const SpaceTokenUtil(); } @immutable class BreakpointTokenUtil { - const BreakpointTokenUtil(); - final xsmall = BreakpointToken.xsmall; final small = BreakpointToken.small; final medium = BreakpointToken.medium; final large = BreakpointToken.large; + const BreakpointTokenUtil(); } @immutable diff --git a/test/src/attributes/border/border_radius_util_test.dart b/test/src/attributes/border/border_radius_util_test.dart index 1f973d127..36f7834a5 100644 --- a/test/src/attributes/border/border_radius_util_test.dart +++ b/test/src/attributes/border/border_radius_util_test.dart @@ -6,6 +6,8 @@ import '../../../helpers/testing_utils.dart'; void main() { const borderRadius = BorderRadiusGeometryUtility(UtilityTestAttribute.new); + const borderRadiusDirectional = + BorderRadiusDirectionalUtility(UtilityTestAttribute.new); group('BorderRadiusUtility', () { test('zero should return BorderRadiusAttribute with zero radius', () { final result = borderRadius.zero(); @@ -122,7 +124,7 @@ void main() { group('BorderRadiusDirectionalUtility', () { test('zero should return BorderRadiusDirectionalAttribute with zero radius', () { - final result = borderRadius.directional.zero(); + final result = borderRadiusDirectional.zero(); expect(result.value.topStart, Radius.zero); expect(result.value.topEnd, Radius.zero); expect(result.value.bottomStart, Radius.zero); @@ -132,7 +134,7 @@ void main() { test( 'only should return BorderRadiusDirectionalAttribute with specified radius', () { - final result = borderRadius.only( + final result = borderRadiusDirectional.only( topStart: const Radius.circular(10), topEnd: const Radius.circular(20), bottomStart: const Radius.circular(30), @@ -147,7 +149,7 @@ void main() { test( 'all should return BorderRadiusDirectionalAttribute with specified radius', () { - final result = borderRadius.directional.all.circular(10); + final result = borderRadiusDirectional.all.circular(10); expect(result.value.topStart, const Radius.circular(10)); expect(result.value.topEnd, const Radius.circular(10)); expect(result.value.bottomStart, const Radius.circular(10)); @@ -156,7 +158,7 @@ void main() { test('zero should return BorderRadiusDirectionalAttribute with zero radius', () { - final result = borderRadius.directional.zero(); + final result = borderRadiusDirectional.zero(); expect(result.value.topStart, Radius.zero); expect(result.value.topEnd, Radius.zero); expect(result.value.bottomStart, Radius.zero); @@ -167,7 +169,7 @@ void main() { test( 'topStart should return BorderRadiusDirectionalAttribute with specified radius', () { - final result = borderRadius.topStart.circular(10); + final result = borderRadiusDirectional.topStart.circular(10); expect(result.value.topStart, const Radius.circular(10)); expect(result.value.topEnd, isNull); expect(result.value.bottomStart, isNull); @@ -178,7 +180,7 @@ void main() { test( 'topEnd should return BorderRadiusDirectionalAttribute with specified radius', () { - final result = borderRadius.topEnd.circular(10); + final result = borderRadiusDirectional.topEnd.circular(10); expect(result.value.topStart, isNull); expect(result.value.topEnd, const Radius.circular(10)); expect(result.value.bottomStart, isNull); @@ -189,7 +191,7 @@ void main() { test( 'bottomStart should return BorderRadiusDirectionalAttribute with specified radius', () { - final result = borderRadius.bottomStart.circular(10); + final result = borderRadiusDirectional.bottomStart.circular(10); expect(result.value.topStart, isNull); expect(result.value.topEnd, isNull); expect(result.value.bottomStart, const Radius.circular(10)); @@ -200,7 +202,7 @@ void main() { test( 'bottomEnd should return BorderRadiusDirectionalAttribute with specified radius', () { - final result = borderRadius.bottomEnd.circular(10); + final result = borderRadiusDirectional.bottomEnd.circular(10); expect(result.value.topStart, isNull); expect(result.value.topEnd, isNull); expect(result.value.bottomStart, isNull); diff --git a/test/src/attributes/border/border_util_test.dart b/test/src/attributes/border/border_util_test.dart index 0553992ed..3e5508199 100644 --- a/test/src/attributes/border/border_util_test.dart +++ b/test/src/attributes/border/border_util_test.dart @@ -6,7 +6,7 @@ import '../../../helpers/testing_utils.dart'; void main() { group('BorderUtility', () { - const border = BoxBorderUtility(UtilityTestAttribute.new); + const border = BorderUtility(UtilityTestAttribute.new); test('border.top()', () { final result = border.top( @@ -232,4 +232,235 @@ void main() { expect(resultStrokeAlign.value.right?.strokeAlign, 0.2); }); }); + + // BorderDirectionalUtility + + group('BorderDirectionalUtility', () { + const borderDirectional = + BorderDirectionalUtility(UtilityTestAttribute.new); + + test('borderDirectional.top()', () { + final result = borderDirectional.top( + color: Colors.red, + width: 10.0, + style: BorderStyle.solid, + strokeAlign: 0.5, + ); + + expect(result.value.top?.color?.value, Colors.red); + expect(result.value.top?.width, 10.0); + expect(result.value.top?.style, BorderStyle.solid); + expect(result.value.top?.strokeAlign, 0.5); + expect(result.value.end, null); + expect(result.value.bottom, null); + expect(result.value.start, null); + + final resultColor = borderDirectional.top.color(Colors.yellow); + final resultWidth = borderDirectional.top.width(20.0); + final resultStyle = borderDirectional.top.style(BorderStyle.solid); + final resultStrokeAlign = borderDirectional.top.strokeAlign(0.2); + + expect(resultColor.value.top?.color?.value, Colors.yellow); + expect(resultWidth.value.top?.width, 20.0); + expect(resultStyle.value.top?.style, BorderStyle.solid); + expect(resultStrokeAlign.value.top?.strokeAlign, 0.2); + }); + + test('borderDirectional.bottom()', () { + final result = borderDirectional.bottom( + color: Colors.red, + width: 10.0, + style: BorderStyle.solid, + strokeAlign: 0.5, + ); + + expect(result.value.bottom?.color?.value, Colors.red); + expect(result.value.bottom?.width, 10.0); + expect(result.value.bottom?.style, BorderStyle.solid); + expect(result.value.bottom?.strokeAlign, 0.5); + expect(result.value.end, null); + expect(result.value.top, null); + expect(result.value.start, null); + + final resultColor = borderDirectional.bottom.color(Colors.yellow); + final resultWidth = borderDirectional.bottom.width(20.0); + final resultStyle = borderDirectional.bottom.style(BorderStyle.solid); + final resultStrokeAlign = borderDirectional.bottom.strokeAlign(0.2); + + expect(resultColor.value.bottom?.color?.value, Colors.yellow); + expect(resultWidth.value.bottom?.width, 20.0); + expect(resultStyle.value.bottom?.style, BorderStyle.solid); + expect(resultStrokeAlign.value.bottom?.strokeAlign, 0.2); + }); + + test('borderDirectional.start()', () { + final result = borderDirectional.start( + color: Colors.red, + width: 10.0, + style: BorderStyle.solid, + strokeAlign: 0.5, + ); + expect(result.value.start?.color?.value, Colors.red); + expect(result.value.start?.width, 10.0); + expect(result.value.start?.style, BorderStyle.solid); + expect(result.value.start?.strokeAlign, 0.5); + expect(result.value.end, null); + expect(result.value.top, null); + expect(result.value.bottom, null); + + final resultColor = borderDirectional.start.color(Colors.yellow); + final resultWidth = borderDirectional.start.width(20.0); + final resultStyle = borderDirectional.start.style(BorderStyle.solid); + final resultStrokeAlign = borderDirectional.start.strokeAlign(0.2); + + expect(resultColor.value.start?.color?.value, Colors.yellow); + expect(resultWidth.value.start?.width, 20.0); + expect(resultStyle.value.start?.style, BorderStyle.solid); + expect(resultStrokeAlign.value.start?.strokeAlign, 0.2); + }); + + test('borderDirectional.end()', () { + final result = borderDirectional.end( + color: Colors.red, + width: 10.0, + style: BorderStyle.solid, + strokeAlign: 0.5, + ); + expect(result.value.end?.color?.value, Colors.red); + expect(result.value.end?.width, 10.0); + expect(result.value.end?.style, BorderStyle.solid); + expect(result.value.end?.strokeAlign, 0.5); + expect(result.value.start, null); + expect(result.value.top, null); + expect(result.value.bottom, null); + + final resultColor = borderDirectional.end.color(Colors.yellow); + final resultWidth = borderDirectional.end.width(20.0); + final resultStyle = borderDirectional.end.style(BorderStyle.solid); + final resultStrokeAlign = borderDirectional.end.strokeAlign(0.2); + + expect(resultColor.value.end?.color?.value, Colors.yellow); + expect(resultWidth.value.end?.width, 20.0); + expect(resultStyle.value.end?.style, BorderStyle.solid); + expect(resultStrokeAlign.value.end?.strokeAlign, 0.2); + }); + + test('borderDirectional.horizontal()', () { + final result = borderDirectional.horizontal( + color: Colors.blue, + width: 5.0, + style: BorderStyle.solid, + strokeAlign: 0.3, + ); + expect(result.value.top?.color?.value, Colors.blue); + expect(result.value.top?.width, 5.0); + expect(result.value.top?.style, BorderStyle.solid); + expect(result.value.top?.strokeAlign, 0.3); + expect(result.value.bottom?.color?.value, Colors.blue); + expect(result.value.bottom?.width, 5.0); + expect(result.value.bottom?.style, BorderStyle.solid); + expect(result.value.bottom?.strokeAlign, 0.3); + expect(result.value.start, null); + expect(result.value.end, null); + + final resultColor = borderDirectional.horizontal.color(Colors.yellow); + final resultWidth = borderDirectional.horizontal.width(20.0); + final resultStyle = borderDirectional.horizontal.style(BorderStyle.solid); + final resultStrokeAlign = borderDirectional.horizontal.strokeAlign(0.2); + + expect(resultColor.value.top?.color?.value, Colors.yellow); + expect(resultWidth.value.top?.width, 20.0); + expect(resultStyle.value.top?.style, BorderStyle.solid); + expect(resultStrokeAlign.value.top?.strokeAlign, 0.2); + + expect(resultColor.value.bottom?.color?.value, Colors.yellow); + expect(resultWidth.value.bottom?.width, 20.0); + expect(resultStyle.value.bottom?.style, BorderStyle.solid); + expect(resultStrokeAlign.value.bottom?.strokeAlign, 0.2); + }); + + test('borderDirectional.vertical()', () { + final result = borderDirectional.vertical( + color: Colors.green, + width: 7.0, + style: BorderStyle.solid, + strokeAlign: 0.2, + ); + expect(result.value.start?.color?.value, Colors.green); + expect(result.value.start?.width, 7.0); + expect(result.value.start?.style, BorderStyle.solid); + expect(result.value.start?.strokeAlign, 0.2); + expect(result.value.end?.color?.value, Colors.green); + expect(result.value.end?.width, 7.0); + expect(result.value.end?.style, BorderStyle.solid); + expect(result.value.end?.strokeAlign, 0.2); + expect(result.value.top, null); + expect(result.value.bottom, null); + + final resultColor = borderDirectional.vertical.color(Colors.yellow); + final resultWidth = borderDirectional.vertical.width(20.0); + final resultStyle = borderDirectional.vertical.style(BorderStyle.solid); + final resultStrokeAlign = borderDirectional.vertical.strokeAlign(0.2); + + expect(resultColor.value.start?.color?.value, Colors.yellow); + expect(resultWidth.value.start?.width, 20.0); + expect(resultStyle.value.start?.style, BorderStyle.solid); + expect(resultStrokeAlign.value.start?.strokeAlign, 0.2); + + expect(resultColor.value.end?.color?.value, Colors.yellow); + expect(resultWidth.value.end?.width, 20.0); + expect(resultStyle.value.end?.style, BorderStyle.solid); + expect(resultStrokeAlign.value.end?.strokeAlign, 0.2); + }); + + test('borderDirectional.all()', () { + final result = borderDirectional.all( + color: Colors.purple, + width: 3.0, + style: BorderStyle.solid, + strokeAlign: 0.1, + ); + expect(result.value.top?.color?.value, Colors.purple); + expect(result.value.top?.width, 3.0); + expect(result.value.top?.style, BorderStyle.solid); + expect(result.value.top?.strokeAlign, 0.1); + expect(result.value.bottom?.color?.value, Colors.purple); + expect(result.value.bottom?.width, 3.0); + expect(result.value.bottom?.style, BorderStyle.solid); + expect(result.value.bottom?.strokeAlign, 0.1); + expect(result.value.start?.color?.value, Colors.purple); + expect(result.value.start?.width, 3.0); + expect(result.value.start?.style, BorderStyle.solid); + expect(result.value.start?.strokeAlign, 0.1); + expect(result.value.end?.color?.value, Colors.purple); + expect(result.value.end?.width, 3.0); + expect(result.value.end?.style, BorderStyle.solid); + expect(result.value.end?.strokeAlign, 0.1); + + final resultColor = borderDirectional.all.color(Colors.yellow); + final resultWidth = borderDirectional.all.width(20.0); + final resultStyle = borderDirectional.all.style(BorderStyle.solid); + final resultStrokeAlign = borderDirectional.all.strokeAlign(0.2); + + expect(resultColor.value.top?.color?.value, Colors.yellow); + expect(resultWidth.value.top?.width, 20.0); + expect(resultStyle.value.top?.style, BorderStyle.solid); + expect(resultStrokeAlign.value.top?.strokeAlign, 0.2); + + expect(resultColor.value.bottom?.color?.value, Colors.yellow); + expect(resultWidth.value.bottom?.width, 20.0); + expect(resultStyle.value.bottom?.style, BorderStyle.solid); + expect(resultStrokeAlign.value.bottom?.strokeAlign, 0.2); + + expect(resultColor.value.start?.color?.value, Colors.yellow); + expect(resultWidth.value.start?.width, 20.0); + expect(resultStyle.value.start?.style, BorderStyle.solid); + expect(resultStrokeAlign.value.start?.strokeAlign, 0.2); + + expect(resultColor.value.end?.color?.value, Colors.yellow); + expect(resultWidth.value.end?.width, 20.0); + expect(resultStyle.value.end?.style, BorderStyle.solid); + expect(resultStrokeAlign.value.end?.strokeAlign, 0.2); + }); + }); } diff --git a/test/src/specs/flex/flex_widget_test.dart b/test/src/specs/flex/flex_widget_test.dart index b416fa9a1..e09c3a47f 100644 --- a/test/src/specs/flex/flex_widget_test.dart +++ b/test/src/specs/flex/flex_widget_test.dart @@ -52,9 +52,10 @@ void main() { test('Verify if widgets are wrapped with Padding when there are 3 children', () { - var sut = const MixedFlex( + var sut = MixedFlex( + mix: EmptyMixData, direction: Axis.horizontal, - children: [ + children: const [ SizedBox(), SizedBox(), SizedBox(), @@ -69,9 +70,10 @@ void main() { }); test('Verify if widgets are wrapped with Padding when there is 1 child', () { - var sut = const MixedFlex( + var sut = MixedFlex( + mix: EmptyMixData, direction: Axis.horizontal, - children: [ + children: const [ SizedBox(), ], ).buildChildren(10); @@ -86,9 +88,10 @@ void main() { test( 'Verify if when MixedFlex has direction horizontal the padding is only in the right', () { - var sut = const MixedFlex( + var sut = MixedFlex( + mix: EmptyMixData, direction: Axis.horizontal, - children: [ + children: const [ SizedBox(), SizedBox(), ], @@ -110,9 +113,10 @@ void main() { test( 'Verify if when MixedFlex has direction horizontal the padding is only in the right', () { - var sut = const MixedFlex( + var sut = MixedFlex( + mix: EmptyMixData, direction: Axis.vertical, - children: [ + children: const [ SizedBox(), SizedBox(), ], diff --git a/website/pages/docs/_meta.json b/website/pages/docs/_meta.json index 592bdbd67..cf09c26e4 100644 --- a/website/pages/docs/_meta.json +++ b/website/pages/docs/_meta.json @@ -22,5 +22,13 @@ "widgets": { "title": "Widgets", "display": "children" + }, + "-- Utilities": { + "type": "separator", + "title": "Utilities" + }, + "utilities": { + "title": "Utilities", + "display": "children" } } diff --git a/website/pages/docs/utilities/_meta.json b/website/pages/docs/utilities/_meta.json new file mode 100644 index 000000000..c8f167f8f --- /dev/null +++ b/website/pages/docs/utilities/_meta.json @@ -0,0 +1,3 @@ +{ + "box-utilities": "Box Utilities" +} diff --git a/website/pages/docs/utilities/box-utilities.md b/website/pages/docs/utilities/box-utilities.md new file mode 100644 index 000000000..9b3bcd0b5 --- /dev/null +++ b/website/pages/docs/utilities/box-utilities.md @@ -0,0 +1,716 @@ +# Box Utilities + +## width + +Sets the width of the box. + +```dart +width(200) +``` + +## height + +Sets the height of the box. + +```dart +height(100) +``` + +## padding + +Sets the padding of the box. + +```dart +padding(10); + +padding(10, 20); + +padding(10, 20, 30); + +padding(10, 20, 30, 40); +``` + +### padding.all + +Sets the padding of the box on all sides. + +```dart +padding.all(10) +``` + +### padding.top + +Sets the padding of the box on the top side. + +```dart +padding.top(10) +``` + +### padding.bottom + +Sets the padding of the box on the bottom side. + +```dart +padding.bottom(10) +``` + +### padding.left + +Sets the padding of the box on the left side. + +```dart +padding.left(10) +``` + +### padding.right + +Sets the padding of the box on the right side. + +```dart +padding.right(10) +``` + +### padding.horizontal + +Sets the padding of the box on the horizontal (left and right) sides. + +```dart +padding.horizontal(10) +``` + +### padding.vertical + +Sets the padding of the box on the vertical (top and bottom) sides. + +```dart +padding.vertical(10) +``` + +### padding.only + +Sets the padding of the box on the specified sides. + +```dart +padding.only( + top: 10, + bottom: 20, + left: 30, + right: 40 +); +``` + +## Constraints + +### maxWidth + +Sets the maximum width the box can have. + +```dart +maxWidth(200) +``` + +### minWidth + +Sets the minimum width the box must have. + +```dart +minWidth(100) +``` + +### maxHeight + +Sets the maximum height the box can have. + +```dart +maxHeight(200) +``` + +### minHeight + +Sets the minimum height the box must have. + +```dart +minHeight(100) +``` + +## backgroundColor + +Sets the background color of the box. + +```dart +backgroundColor(Colors.blue) +backgroundColor.blue() +``` + +## elevation + +Sets the elevation of the box. + +```dart +// Elevation can be 0, 1, 2, 3, 4, 6, 8, 9, 12, 16, 24 +elevation(2) +``` + +## alignment + +Sets the alignment of the box. + +```dart +// You can pass the alignment into the utility +alignment(Alignment.center); + +// Or you can use the alignment utility +alignment.center(); +alignment.centerLeft(); +alignment.centerRight(); +alignment.topLeft(); +alignment.topCenter(); +alignment.topRight(); +alignment.bottomLeft(); +alignment.bottomCenter(); +alignment.bottomRight(); +``` + +## clipBehavior + +Sets the clip behavior of the box. + +```dart +// You can pass the clip into the utility +clipBehavior(Clip.hardEdge) +clipBehavior.none(); +clipBehavior.hardEdge(); +clipBehavior.antiAlias(); +clipBehavior.antiAliasWithSaveLayer(); +``` + +## Decoration + +### border + +Defines the border of a Box. Equivalent to `BoxDecoration.border`, in a `Container` + +#### call() + +Styles all sides of `Border`. + +```dart +border( + color: Colors.red, + width: 2, + style: BorderStyle.solid, + strokeAlign: 0.5 +); +``` + +#### border.all + +Styles all sides of `Border`. + +```dart +border.all.color.red(); +border.all.width(2); +border.all.style.solid(); +border.all.strokeAlign(0.5); +``` + +#### border.top + +Styles the top side of `Border`. + +```dart +border.top.color.red(); +border.top.width(2); +border.top.style.solid(); +border.top.strokeAlign(0.5); +``` + +#### border.bottom + +Styles the bottom side of `Border`. + +```dart +border.bottom.color.red(); +border.bottom.width(2); +border.bottom.style.solid(); +border.bottom.strokeAlign(0.5); +``` + +#### border.left + +Styles the left side of `Border`. + +```dart +border.left.color.red(); +border.left.width(2); +border.left.style.solid(); +border.left.strokeAlign(0.5); +``` + +#### border.right + +Styles the right side`Border`. + +```dart +border.right.color.red(); +border.right.width(2); +border.right.style.solid(); +border.right.strokeAlign(0.5); +``` + +#### border.start + +Styles the start side of `BorderDirectional`. + +```dart +border.start.color.red(); +border.start.width(2); +border.start.style.solid(); +border.start.strokeAlign(0.5); +``` + +#### border.end + +Styles the end side of `BorderDirectional`. + +```dart +border.end.color.red(); +border.end.width(2); +border.end.style.solid(); +border.end.strokeAlign(0.5); +``` + +#### border.horizontal + +Styles the horizontal (top and bottom) sides of `Border`. + +```dart +border.horizontal.color.red(); +border.horizontal.width(2); +border.horizontal.style.solid(); +border.horizontal.strokeAlign(0.5); +``` + +#### border.vertical + +Styles the vertical (left and right) sides of `Border`. + +```dart +border.vertical.color.red(); +border.vertical.width(2); +border.vertical.style.solid(); +border.vertical.strokeAlign(0.5); +``` + +### borderDirectional + +Defines the `BorderDirectional` of a Box. Equivalent to `BoxDecoration.border`, in a `Container` + +#### call() + +Styles all sides of `BorderDirectional`. + +```dart +borderDirectional( + color: Colors.red, + width: 2, + style: BorderStyle.solid, + strokeAlign: 0.5 +); +``` + +#### borderDirectional.all + +Styles all sides of `BorderDirectional`. + +```dart +borderDirectional.all.color.red(); +borderDirectional.all.width(2); +borderDirectional.all.style.solid(); +borderDirectional.all.strokeAlign(0.5); +``` + +#### borderDirectional.top + +Styles the top side `BorderDirectional`. + +```dart +borderDirectional.top.color.red(); +borderDirectional.top.width(2); +borderDirectional.top.style.solid(); +borderDirectional.top.strokeAlign(0.5); +``` + +#### borderDirectional.bottom + +Styles the bottom side of `BorderDirectional`. + +```dart +borderDirectional.bottom.color.red(); +borderDirectional.bottom.width(2); +borderDirectional.bottom.style.solid(); +borderDirectional.bottom.strokeAlign(0.5); +``` + +#### borderDirectional.start + +Styles the start side of `BorderDirectional`. + +```dart +borderDirectional.start.color.red(); +borderDirectional.start.width(2); +borderDirectional.start.style.solid(); +borderDirectional.start.strokeAlign(0.5); +``` + +#### borderDirectional.end + +Styles the end side of `BorderDirectional`. + +```dart +borderDirectional.end.color.red(); +borderDirectional.end.width(2); +borderDirectional.end.style.solid(); +borderDirectional.end.strokeAlign(0.5); +``` + +#### borderDirectional.horizontal + +Styles the horizontal (start and end) sides of `BorderDirectional`. + +```dart +borderDirectional.horizontal.color.red(); +borderDirectional.horizontal.width(2); +borderDirectional.horizontal.style.solid(); +borderDirectional.horizontal.strokeAlign(0.5); +``` + +#### borderDirectional.vertical + +Styles the vertical (top and bottom) sides of `BorderDirectional`. + +```dart +borderDirectional.vertical.color.red(); +borderDirectional.vertical.width(2); +borderDirectional.vertical.style.solid(); +borderDirectional.vertical.strokeAlign(0.5); +``` + +### borderRadius + +Styles `Radius` the corners of a `BorderRadiusGeometry` of a `BoxDecoration.borderRadius`. + +```dart +// BorderRadius all: Radius.circular(10) +borderRadius(10); + +// BorderRadius topLeft and topRight: Radius.circular(10), bottomLeft and bottomRight: Radius.circular(20) +borderRadius(10, 20); + +// BorderRadius topLeft: Radius.circular(10), topRight and bottomLeft: Radius.circular(20), bottomRight: Radius.circular(30) +borderRadius(10, 20, 30); + +// BorderRadius topLeft: Radius.circular(10), topRight: Radius.circular(20), bottomLeft: Radius.circular(30), bottomRight: Radius.circular(40) +borderRadius(10, 20, 30, 40); + +/// BorderRadius all: Radius.circular(10) +borderRadius.circular(10); + +/// BorderRadius all: Radius.elliptical(10, 20) +borderRadius.elliptical(10, 20); + +/// BorderRadius all: Radius.zero +borderRadius.zero(); +``` + +#### borderRadius.all + +Styles a uniform `BorderRadius` of a `BoxDecoration.borderRadius`. + +```dart +borderRadius.all(10); +borderRadius.all.circular(10); +borderRadius.all.elliptical(10, 20); +borderRadius.all.zero(); +``` + +#### borderRadius.topLeft + +Styles the topLeft `BorderRadius` of a `BoxDecoration.borderRadius`. + +```dart +borderRadius.topLeft(10); +borderRadius.topLeft.circular(10); +borderRadius.topLeft.elliptical(10, 20); +borderRadius.topLeft.zero(); +``` + +#### borderRadius.topRight + +Styles the topRight `BorderRadius` of a `BoxDecoration.borderRadius`. + +```dart +borderRadius.topRight(10); +borderRadius.topRight.circular(10); +borderRadius.topRight.elliptical(10, 20); +borderRadius.topRight.zero(); +``` + +#### borderRadius.bottomLeft + +Styles the bottomLeft `BorderRadius` of a `BoxDecoration.borderRadius`. + +```dart +borderRadius.bottomLeft(10); +borderRadius.bottomLeft.circular(10); +borderRadius.bottomLeft.elliptical(10, 20); +borderRadius.bottomLeft.zero(); +``` + +#### borderRadius.bottomRight + +Styles the bottomRight `BorderRadius` of a `BoxDecoration.borderRadius`. + +```dart +borderRadius.bottomRight(10); +borderRadius.bottomRight.circular(10); +borderRadius.bottomRight.elliptical(10, 20); +borderRadius.bottomRight.zero(); +``` + +#### borderRadius.topStart + +Styles the topStart `BorderRadiusDirectional` of a `BoxDecoration.borderRadius`. + +```dart +borderRadius.topStart(10); +borderRadius.topStart.circular(10); +borderRadius.topStart.elliptical(10, 20); +borderRadius.topStart.zero(); +``` + +#### borderRadius.topEnd + +Styles the topEnd `BorderRadiusDirectional` of a `BoxDecoration.borderRadius`. + +```dart +borderRadius.topEnd(10); +borderRadius.topEnd.circular(10); +borderRadius.topEnd.elliptical(10, 20); +borderRadius.topEnd.zero(); +``` + +#### borderRadius.bottomStart + +Styles the bottomStart `BorderRadiusDirectional` of a `BoxDecoration.borderRadius`. + +```dart +borderRadius.bottomStart(10); +borderRadius.bottomStart.circular(10); +borderRadius.bottomStart.elliptical(10, 20); +borderRadius.bottomStart.zero(); +``` + +#### borderRadius.bottomEnd + +Styles the bottomEnd `BorderRadiusDirectional` of a `BoxDecoration.borderRadius`. + +```dart +borderRadius.bottomEnd(10); +borderRadius.bottomEnd.circular(10); +borderRadius.bottomEnd.elliptical(10, 20); +borderRadius.bottomEnd.zero(); +``` + +#### borderRadius.top + +Styles the top (topLeft and topRight) `BorderRadius` of a `BoxDecoration.borderRadius`. + +```dart +borderRadius.top(10); +borderRadius.top.circular(10); +borderRadius.top.elliptical(10, 20); +borderRadius.top.zero(); +``` + +#### borderRadius.bottom + +Styles the bottom (bottomLeft and bottomRight) `BorderRadius` of a `BoxDecoration.borderRadius`. + +```dart +borderRadius.bottom(10); +borderRadius.bottom.circular(10); +borderRadius.bottom.elliptical(10, 20); +borderRadius.bottom.zero(); +``` + +#### borderRadius.left + +Styles the left (topLeft and bottomLeft) `BorderRadius` of a `BoxDecoration.borderRadius`. + +```dart +border.left(10); +borderRadius.left.circular(10); +borderRadius.left.elliptical(10, 20); +borderRadius.left.zero(); +``` + +#### borderRadius.right + +Styles the right (topRight and bottomRight) `BorderRadius` of a `BoxDecoration.borderRadius`. + +```dart +border.right(10); +borderRadius.right.circular(10); +borderRadius.right.elliptical(10, 20); +borderRadius.right.zero(); +``` + +#### borderRadius.only + +The same as calling `BorderRadius.only` of a `BoxDecoration.borderRadius`. + +```dart +borderRadius.only( + topLeft: Radius.circular(10), + topRight: Radius.circular(20), + bottomLeft: Radius.circular(30), + bottomRight: Radius.circular(40) +); +``` + +### borderRadiusDirectional + +Styles the `BorderRadiusDirectional` of a `BoxDecoration.borderRadius`. + +```dart +// BorderRadiusDirectional.all(Radius.circular(10)); +borderRadiusDirectional(10); + +// BorderRadiusDirectional.only(topStart: Radius.circular(10), topEnd: Radius.circular(20), bottomStart: Radius.circular(10), bottomEnd: Radius.circular(20)); +borderRadiusDirectional(10, 20); + +// Applies 10 to topStart, 20 to topEnd and bottomStart, 30 to bottomEnd +// BorderRadiusDirectional.only(topStart: Radius.circular(10), topEnd: Radius.circular(20), bottomStart: Radius.circular(30), bottomEnd: Radius.circular(20)); +borderRadiusDirectional(10, 20, 30); + +// BorderRadiusDirectional.only(topStart: Radius.circular(10), topEnd: Radius.circular(20), bottomStart: Radius.circular(30), bottomEnd: Radius.circular(40)); +borderRadiusDirectional(10, 20, 30, 40); + +borderRadiusDirectional.circular(10); +borderRadiusDirectional.elliptical(10, 20); +borderRadiusDirectional.zero(); +``` + +#### borderRadiusDirectional.all + +Styles the `BorderRadiusDirectional.all` of a `BoxDecoration.borderRadius`. + +```dart +borderRadiusDirectional.all(10); +borderRadiusDirectional.all.circular(10); +borderRadiusDirectional.all.elliptical(10, 20); +borderRadiusDirectional.all.zero(); +``` + +#### borderRadiusDirectional.topStart + +Styles the `BorderRadiusDirectional.topStart` of a `BoxDecoration.borderRadius`. + +```dart +borderRadiusDirectional.topStart(10); +borderRadiusDirectional.topStart.circular(10); +borderRadiusDirectional.topStart.elliptical(10, 20); +borderRadiusDirectional.topStart.zero(); +``` + +#### borderRadiusDirectional.topEnd + +Styles the `BorderRadiusDirectional.topEnd` of a `BoxDecoration.borderRadius`. + +```dart +borderRadiusDirectional.topEnd(10); +borderRadiusDirectional.topEnd.circular(10); +borderRadiusDirectional.topEnd.elliptical(10, 20); +borderRadiusDirectional.topEnd.zero(); +``` + +#### borderRadiusDirectional.bottomStart + +Styles the `BorderRadiusDirectional.bottomStart` of a `BoxDecoration.borderRadius`. + +```dart +borderRadiusDirectional.bottomStart(10); +borderRadiusDirectional.bottomStart.circular(10); +borderRadiusDirectional.bottomStart.elliptical(10, 20); +borderRadiusDirectional.bottomStart.zero(); +``` + +#### borderRadiusDirectional.bottomEnd + +Styles the `BorderRadiusDirectional.bottomEnd` of a `BoxDecoration.borderRadius`. + +```dart +borderRadiusDirectional.bottomEnd(10); +borderRadiusDirectional.bottomEnd.circular(10); +borderRadiusDirectional.bottomEnd.elliptical(10, 20); +borderRadiusDirectional.bottomEnd.zero(); +``` + +#### borderRadiusDirectional.top + +Styles the (topStart and topEnd) of a `BoxDecoration.borderRadius`. + +```dart +borderRadiusDirectional.top(10); +borderRadiusDirectional.top.circular(10); +borderRadiusDirectional.top.elliptical(10, 20); +borderRadiusDirectional.top.zero(); +``` + +#### borderRadiusDirectional.bottom + +Styles the (bottomStart and bottomEnd) of a `BoxDecoration.borderRadius`. + +```dart +borderRadiusDirectional.bottom(10); +borderRadiusDirectional.bottom.circular(10); +borderRadiusDirectional.bottom.elliptical(10, 20); +borderRadiusDirectional.bottom.zero(); +``` + +#### borderRadiusDirectional.start + +Styles (topStart and bottomStart) `BorderRadiusDirectional` of a `BoxDecoration.borderRadius`. + +```dart +borderRadiusDirectional.start(10); +borderRadiusDirectional.start.circular(10); +borderRadiusDirectional.start.elliptical(10, 20); +borderRadiusDirectional.start.zero(); +``` + +#### borderRadiusDirectional.end + +Styles (topEnd and bottomEnd) `BorderRadiusDirectional` of a `BoxDecoration.borderRadius`. + +```dart +borderRadiusDirectional.end(10); +borderRadiusDirectional.end.circular(10); +borderRadiusDirectional.end.elliptical(10, 20); +borderRadiusDirectional.end.zero(); +``` + +#### borderRadiusDirectional.only + +Similar to using `BorderRadiusDirectional.only` of a `BoxDecoration.borderRadius`. + +```dart + +borderRadiusDirectional.only( + topStart: Radius.circular(10), + topEnd: Radius.circular(20), + bottomStart: Radius.circular(10), + bottomEnd: Radius.circular(20) +); +```