David PHAM-VAN

Add Positioned.fill()

@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 ## 3.1.1 3 ## 3.1.1
4 4
5 - Fix documentation 5 - Fix documentation
  6 +- Add Positioned.fill()
6 7
7 ## 3.1.0 8 ## 3.1.0
8 9
@@ -20,6 +20,7 @@ import 'package:pdf/pdf.dart'; @@ -20,6 +20,7 @@ import 'package:pdf/pdf.dart';
20 import 'package:vector_math/vector_math_64.dart'; 20 import 'package:vector_math/vector_math_64.dart';
21 21
22 import 'geometry.dart'; 22 import 'geometry.dart';
  23 +import 'text.dart';
23 import 'widget.dart'; 24 import 'widget.dart';
24 25
25 /// How to size the non-positioned children of a [Stack]. 26 /// How to size the non-positioned children of a [Stack].
@@ -39,6 +40,46 @@ class Positioned extends SingleChildWidget { @@ -39,6 +40,46 @@ class Positioned extends SingleChildWidget {
39 required Widget child, 40 required Widget child,
40 }) : super(child: child); 41 }) : super(child: child);
41 42
  43 + /// Creates a Positioned object with left, top, right, and bottom set to 0.0
  44 + /// unless a value for them is passed.
  45 + Positioned.fill({
  46 + this.left = 0.0,
  47 + this.top = 0.0,
  48 + this.right = 0.0,
  49 + this.bottom = 0.0,
  50 + required Widget child,
  51 + }) : super(child: child);
  52 +
  53 + /// Creates a widget that controls where a child of a [Stack] is positioned.
  54 + factory Positioned.directional({
  55 + required TextDirection textDirection,
  56 + double? start,
  57 + double? top,
  58 + double? end,
  59 + double? bottom,
  60 + required Widget child,
  61 + }) {
  62 + double? left;
  63 + double? right;
  64 + switch (textDirection) {
  65 + case TextDirection.rtl:
  66 + left = end;
  67 + right = start;
  68 + break;
  69 + case TextDirection.ltr:
  70 + left = start;
  71 + right = end;
  72 + break;
  73 + }
  74 + return Positioned(
  75 + left: left,
  76 + top: top,
  77 + right: right,
  78 + bottom: bottom,
  79 + child: child,
  80 + );
  81 + }
  82 +
42 final double? left; 83 final double? left;
43 84
44 final double? top; 85 final double? top;