Joseph Grabinger
Committed by GitHub

Apply BoxShape and BorderRadius to selected Checkbox (#1285)

@@ -14,6 +14,7 @@ @@ -14,6 +14,7 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
  17 +import 'dart:math' as math;
17 import 'dart:typed_data'; 18 import 'dart:typed_data';
18 19
19 import 'package:vector_math/vector_math_64.dart'; 20 import 'package:vector_math/vector_math_64.dart';
@@ -81,7 +82,10 @@ class Checkbox extends SingleChildWidget { @@ -81,7 +82,10 @@ class Checkbox extends SingleChildWidget {
81 double width = 13, 82 double width = 13,
82 double height = 13, 83 double height = 13,
83 BoxDecoration? decoration, 84 BoxDecoration? decoration,
84 - }) : super( 85 + }) : radius = decoration?.shape == BoxShape.circle
  86 + ? Radius.circular(math.max(height, width)/2)
  87 + : decoration?.borderRadius?.topLeft ?? Radius.zero,
  88 + super(
85 child: Container( 89 child: Container(
86 width: width, 90 width: width,
87 height: height, 91 height: height,
@@ -103,6 +107,8 @@ class Checkbox extends SingleChildWidget { @@ -103,6 +107,8 @@ class Checkbox extends SingleChildWidget {
103 107
104 final String name; 108 final String name;
105 109
  110 + final Radius radius;
  111 +
106 @override 112 @override
107 void paint(Context context) { 113 void paint(Context context) {
108 super.paint(context); 114 super.paint(context);
@@ -118,7 +124,7 @@ class Checkbox extends SingleChildWidget { @@ -118,7 +124,7 @@ class Checkbox extends SingleChildWidget {
118 124
119 final g = bf.appearance(context.document, PdfAnnotAppearance.normal, 125 final g = bf.appearance(context.document, PdfAnnotAppearance.normal,
120 name: '/Yes', selected: value); 126 name: '/Yes', selected: value);
121 - g.drawRect(0, 0, bf.rect.width, bf.rect.height); 127 + g.drawRRect(0, 0, bf.rect.width, bf.rect.height, radius.y, radius.x);
122 g.setFillColor(activeColor); 128 g.setFillColor(activeColor);
123 g.fillPath(); 129 g.fillPath();
124 g.moveTo(2, bf.rect.height / 2); 130 g.moveTo(2, bf.rect.height / 2);