Milad akarie
Committed by David PHAM-VAN

Add test annotations

@@ -51,10 +51,14 @@ void main() { @@ -51,10 +51,14 @@ void main() {
51 Page( 51 Page(
52 textDirection: TextDirection.rtl, 52 textDirection: TextDirection.rtl,
53 pageFormat: const PdfPageFormat(150, 50), 53 pageFormat: const PdfPageFormat(150, 50),
54 - build: (Context context) => Row( 54 + build: (Context context) =>
  55 + TestAnnotation(
  56 + anno: 'RTL Row',
  57 + child: Row(
55 children: [_blueBox, _redBox], 58 children: [_blueBox, _redBox],
56 ), 59 ),
57 ), 60 ),
  61 + ),
58 ); 62 );
59 }); 63 });
60 64
@@ -63,11 +67,15 @@ void main() { @@ -63,11 +67,15 @@ void main() {
63 Page( 67 Page(
64 textDirection: TextDirection.rtl, 68 textDirection: TextDirection.rtl,
65 pageFormat: const PdfPageFormat(150, 50), 69 pageFormat: const PdfPageFormat(150, 50),
66 - build: (Context context) => Row( 70 + build: (Context context) =>
  71 + TestAnnotation(
  72 + anno: 'RTL Row MainAlignment.center',
  73 + child: Row(
67 mainAxisAlignment: MainAxisAlignment.center, 74 mainAxisAlignment: MainAxisAlignment.center,
68 children: [_blueBox, _redBox], 75 children: [_blueBox, _redBox],
69 ), 76 ),
70 ), 77 ),
  78 + ),
71 ); 79 );
72 }); 80 });
73 81
@@ -76,7 +84,10 @@ void main() { @@ -76,7 +84,10 @@ void main() {
76 Page( 84 Page(
77 pageFormat: const PdfPageFormat(150, 100), 85 pageFormat: const PdfPageFormat(150, 100),
78 textDirection: TextDirection.rtl, 86 textDirection: TextDirection.rtl,
79 - build: (Context context) => SizedBox( 87 + build: (Context context) =>
  88 + TestAnnotation(
  89 + anno: 'RTL Row CrossAlignment.end',
  90 + child: SizedBox(
80 width: 150, 91 width: 150,
81 height: 100, 92 height: 100,
82 child: Row( 93 child: Row(
@@ -85,16 +96,21 @@ void main() { @@ -85,16 +96,21 @@ void main() {
85 ), 96 ),
86 ), 97 ),
87 ), 98 ),
  99 + ),
88 ); 100 );
89 }); 101 });
90 test('Should render a blue box followed by a red box ordered LTR aligned left', () { 102 test('Should render a blue box followed by a red box ordered LTR aligned left', () {
91 pdf.addPage( 103 pdf.addPage(
92 Page( 104 Page(
93 pageFormat: const PdfPageFormat(150, 50), 105 pageFormat: const PdfPageFormat(150, 50),
94 - build: (Context context) => Row( 106 + build: (Context context) =>
  107 + TestAnnotation(
  108 + anno: 'LTR Row',
  109 + child: Row(
95 children: [_blueBox, _redBox], 110 children: [_blueBox, _redBox],
96 ), 111 ),
97 ), 112 ),
  113 + ),
98 ); 114 );
99 }); 115 });
100 test('Should render a blue box followed by a red box ordered TTB aligned right', () { 116 test('Should render a blue box followed by a red box ordered TTB aligned right', () {
@@ -102,7 +118,10 @@ void main() { @@ -102,7 +118,10 @@ void main() {
102 Page( 118 Page(
103 textDirection: TextDirection.rtl, 119 textDirection: TextDirection.rtl,
104 pageFormat: const PdfPageFormat(150, 150), 120 pageFormat: const PdfPageFormat(150, 150),
105 - build: (Context context) => SizedBox( 121 + build: (Context context) =>
  122 + TestAnnotation(
  123 + anno: 'RTL Column crossAlignment.start',
  124 + child: SizedBox(
106 width: 150, 125 width: 150,
107 height: 150, 126 height: 150,
108 child: Column( 127 child: Column(
@@ -111,6 +130,7 @@ void main() { @@ -111,6 +130,7 @@ void main() {
111 ), 130 ),
112 ), 131 ),
113 ), 132 ),
  133 + ),
114 ); 134 );
115 }); 135 });
116 test('Should render a blue box followed by a red box ordered TTB aligned left', () { 136 test('Should render a blue box followed by a red box ordered TTB aligned left', () {
@@ -118,7 +138,10 @@ void main() { @@ -118,7 +138,10 @@ void main() {
118 Page( 138 Page(
119 textDirection: TextDirection.ltr, 139 textDirection: TextDirection.ltr,
120 pageFormat: const PdfPageFormat(150, 150), 140 pageFormat: const PdfPageFormat(150, 150),
121 - build: (Context context) => SizedBox( 141 + build: (Context context) =>
  142 + TestAnnotation(
  143 + anno: 'LTR Column crossAlignment.start',
  144 + child: SizedBox(
122 width: 150, 145 width: 150,
123 height: 150, 146 height: 150,
124 child: Column( 147 child: Column(
@@ -127,6 +150,7 @@ void main() { @@ -127,6 +150,7 @@ void main() {
127 ), 150 ),
128 ), 151 ),
129 ), 152 ),
  153 + ),
130 ); 154 );
131 }); 155 });
132 156
@@ -135,12 +159,17 @@ void main() { @@ -135,12 +159,17 @@ void main() {
135 Page( 159 Page(
136 textDirection: TextDirection.rtl, 160 textDirection: TextDirection.rtl,
137 pageFormat: const PdfPageFormat(150, 150), 161 pageFormat: const PdfPageFormat(150, 150),
138 - build: (Context context) => SizedBox( 162 + build: (Context context) =>
  163 + TestAnnotation(
  164 + anno: 'RTL Wrap',
  165 + child: SizedBox(
139 width: 150, 166 width: 150,
140 height: 150, 167 height: 150,
141 child: Wrap( 168 child: Wrap(
142 children: [_blueBox, _redBox, _yellowBox], 169 children: [_blueBox, _redBox, _yellowBox],
143 - )), 170 + ),
  171 + ),
  172 + ),
144 ), 173 ),
145 ); 174 );
146 }); 175 });
@@ -150,12 +179,17 @@ void main() { @@ -150,12 +179,17 @@ void main() {
150 Page( 179 Page(
151 textDirection: TextDirection.ltr, 180 textDirection: TextDirection.ltr,
152 pageFormat: const PdfPageFormat(150, 150), 181 pageFormat: const PdfPageFormat(150, 150),
153 - build: (Context context) => SizedBox( 182 + build: (Context context) =>
  183 + TestAnnotation(
  184 + anno: 'LTR Wrap',
  185 + child: SizedBox(
154 width: 150, 186 width: 150,
155 height: 150, 187 height: 150,
156 child: Wrap( 188 child: Wrap(
157 children: [_blueBox, _redBox, _yellowBox], 189 children: [_blueBox, _redBox, _yellowBox],
158 - )), 190 + ),
  191 + ),
  192 + ),
159 ), 193 ),
160 ); 194 );
161 }); 195 });
@@ -164,7 +198,10 @@ void main() { @@ -164,7 +198,10 @@ void main() {
164 Page( 198 Page(
165 textDirection: TextDirection.rtl, 199 textDirection: TextDirection.rtl,
166 pageFormat: const PdfPageFormat(150, 150), 200 pageFormat: const PdfPageFormat(150, 150),
167 - build: (Context context) => SizedBox( 201 + build: (Context context) =>
  202 + TestAnnotation(
  203 + anno: 'RTL Wrap WrapAlignment.center',
  204 + child: SizedBox(
168 width: 150, 205 width: 150,
169 height: 150, 206 height: 150,
170 child: Wrap( 207 child: Wrap(
@@ -172,7 +209,9 @@ void main() { @@ -172,7 +209,9 @@ void main() {
172 runSpacing: 10, 209 runSpacing: 10,
173 runAlignment: WrapAlignment.center, 210 runAlignment: WrapAlignment.center,
174 children: [_blueBox, _redBox, _yellowBox], 211 children: [_blueBox, _redBox, _yellowBox],
175 - )), 212 + ),
  213 + ),
  214 + ),
176 ), 215 ),
177 ); 216 );
178 }); 217 });
@@ -182,7 +221,10 @@ void main() { @@ -182,7 +221,10 @@ void main() {
182 Page( 221 Page(
183 textDirection: TextDirection.rtl, 222 textDirection: TextDirection.rtl,
184 pageFormat: const PdfPageFormat(150, 150), 223 pageFormat: const PdfPageFormat(150, 150),
185 - build: (Context context) => SizedBox( 224 + build: (Context context) =>
  225 + TestAnnotation(
  226 + anno: 'RTL Wrap WrapAlignment.end',
  227 + child: SizedBox(
186 width: 150, 228 width: 150,
187 height: 150, 229 height: 150,
188 child: Wrap( 230 child: Wrap(
@@ -192,6 +234,7 @@ void main() { @@ -192,6 +234,7 @@ void main() {
192 children: [_blueBox, _redBox, _yellowBox], 234 children: [_blueBox, _redBox, _yellowBox],
193 )), 235 )),
194 ), 236 ),
  237 + ),
195 ); 238 );
196 }); 239 });
197 240
@@ -201,7 +244,10 @@ void main() { @@ -201,7 +244,10 @@ void main() {
201 textDirection: TextDirection.rtl, 244 textDirection: TextDirection.rtl,
202 pageFormat: const PdfPageFormat(150, 150), 245 pageFormat: const PdfPageFormat(150, 150),
203 build: (Context context) { 246 build: (Context context) {
204 - return _blueBox; 247 + return TestAnnotation(
  248 + anno: 'RTL Page',
  249 + child: _blueBox,
  250 + );
205 }, 251 },
206 ), 252 ),
207 ); 253 );
@@ -213,7 +259,10 @@ void main() { @@ -213,7 +259,10 @@ void main() {
213 textDirection: TextDirection.ltr, 259 textDirection: TextDirection.ltr,
214 pageFormat: const PdfPageFormat(150, 150), 260 pageFormat: const PdfPageFormat(150, 150),
215 build: (Context context) { 261 build: (Context context) {
216 - return _blueBox; 262 + return TestAnnotation(
  263 + anno: 'LTR Page',
  264 + child: _blueBox,
  265 + );
217 }, 266 },
218 ), 267 ),
219 ); 268 );
@@ -226,7 +275,10 @@ void main() { @@ -226,7 +275,10 @@ void main() {
226 pageFormat: const PdfPageFormat(150, 150), 275 pageFormat: const PdfPageFormat(150, 150),
227 build: (Context context) { 276 build: (Context context) {
228 return [ 277 return [
229 - ListView(children: [for (int i = 0; i < 30; i++) Text('Hello World')]), 278 + ListView(children: [
  279 + Text('RTL MultiPage'),
  280 + for (int i = 0; i < 15; i++) Text('List item'),
  281 + ]),
230 ]; 282 ];
231 }, 283 },
232 ), 284 ),
@@ -240,7 +292,10 @@ void main() { @@ -240,7 +292,10 @@ void main() {
240 pageFormat: const PdfPageFormat(150, 150), 292 pageFormat: const PdfPageFormat(150, 150),
241 build: (Context context) { 293 build: (Context context) {
242 return [ 294 return [
243 - ListView(children: [for (int i = 0; i < 30; i++) Text('Hello World')]), 295 + Text('LTR MultiPage'),
  296 + ListView(children: [
  297 + for (int i = 0; i < 15; i++) Text('List item'),
  298 + ]),
244 ]; 299 ];
245 }, 300 },
246 ), 301 ),
@@ -253,9 +308,12 @@ void main() { @@ -253,9 +308,12 @@ void main() {
253 textDirection: TextDirection.rtl, 308 textDirection: TextDirection.rtl,
254 pageFormat: const PdfPageFormat(150, 150), 309 pageFormat: const PdfPageFormat(150, 150),
255 build: (Context context) { 310 build: (Context context) {
256 - return Padding( 311 + return TestAnnotation(
  312 + anno: 'RTL Padded start',
  313 + child: Padding(
257 padding: const EdgeInsetsDirectional.only(start: 20), 314 padding: const EdgeInsetsDirectional.only(start: 20),
258 child: _blueBox, 315 child: _blueBox,
  316 + ),
259 ); 317 );
260 }, 318 },
261 ), 319 ),
@@ -268,9 +326,12 @@ void main() { @@ -268,9 +326,12 @@ void main() {
268 textDirection: TextDirection.ltr, 326 textDirection: TextDirection.ltr,
269 pageFormat: const PdfPageFormat(150, 150), 327 pageFormat: const PdfPageFormat(150, 150),
270 build: (Context context) { 328 build: (Context context) {
271 - return Padding( 329 + return TestAnnotation(
  330 + anno: 'LTR Padded start',
  331 + child: Padding(
272 padding: const EdgeInsetsDirectional.only(start: 20), 332 padding: const EdgeInsetsDirectional.only(start: 20),
273 child: _blueBox, 333 child: _blueBox,
  334 + ),
274 ); 335 );
275 }, 336 },
276 ), 337 ),
@@ -283,9 +344,12 @@ void main() { @@ -283,9 +344,12 @@ void main() {
283 textDirection: TextDirection.rtl, 344 textDirection: TextDirection.rtl,
284 pageFormat: const PdfPageFormat(150, 150), 345 pageFormat: const PdfPageFormat(150, 150),
285 build: (Context context) { 346 build: (Context context) {
286 - return Align( 347 + return TestAnnotation(
  348 + anno: 'RTL Align directional.centerStart',
  349 + child: Align(
287 alignment: AlignmentDirectional.centerStart, 350 alignment: AlignmentDirectional.centerStart,
288 child: _blueBox, 351 child: _blueBox,
  352 + ),
289 ); 353 );
290 }, 354 },
291 ), 355 ),
@@ -298,9 +362,12 @@ void main() { @@ -298,9 +362,12 @@ void main() {
298 textDirection: TextDirection.ltr, 362 textDirection: TextDirection.ltr,
299 pageFormat: const PdfPageFormat(150, 150), 363 pageFormat: const PdfPageFormat(150, 150),
300 build: (Context context) { 364 build: (Context context) {
301 - return Align( 365 + return TestAnnotation(
  366 + anno: 'LTR Align directional.centerStart',
  367 + child: Align(
302 alignment: AlignmentDirectional.centerStart, 368 alignment: AlignmentDirectional.centerStart,
303 child: _blueBox, 369 child: _blueBox,
  370 + ),
304 ); 371 );
305 }, 372 },
306 ), 373 ),
@@ -313,7 +380,10 @@ void main() { @@ -313,7 +380,10 @@ void main() {
313 textDirection: TextDirection.rtl, 380 textDirection: TextDirection.rtl,
314 pageFormat: const PdfPageFormat(150, 150), 381 pageFormat: const PdfPageFormat(150, 150),
315 build: (Context context) { 382 build: (Context context) {
316 - return Container( 383 + return TestAnnotation(
  384 + anno: 'RTL RadiusDirectional.only topStart',
  385 + child: Container(
  386 + margin: const EdgeInsets.only(top: 11),
317 decoration: const BoxDecoration( 387 decoration: const BoxDecoration(
318 color: PdfColors.blue, 388 color: PdfColors.blue,
319 borderRadius: BorderRadiusDirectional.only( 389 borderRadius: BorderRadiusDirectional.only(
@@ -322,6 +392,7 @@ void main() { @@ -322,6 +392,7 @@ void main() {
322 ), 392 ),
323 width: 150, 393 width: 150,
324 height: 150, 394 height: 150,
  395 + ),
325 ); 396 );
326 }, 397 },
327 ), 398 ),
@@ -334,7 +405,10 @@ void main() { @@ -334,7 +405,10 @@ void main() {
334 textDirection: TextDirection.rtl, 405 textDirection: TextDirection.rtl,
335 pageFormat: const PdfPageFormat(150, 150), 406 pageFormat: const PdfPageFormat(150, 150),
336 build: (Context context) { 407 build: (Context context) {
337 - return Container( 408 + return TestAnnotation(
  409 + anno: 'RTL RadiusDirectional.horizontal start',
  410 + child: Container(
  411 + margin: const EdgeInsets.only(top: 11),
338 decoration: const BoxDecoration( 412 decoration: const BoxDecoration(
339 color: PdfColors.blue, 413 color: PdfColors.blue,
340 borderRadius: BorderRadiusDirectional.horizontal( 414 borderRadius: BorderRadiusDirectional.horizontal(
@@ -343,6 +417,7 @@ void main() { @@ -343,6 +417,7 @@ void main() {
343 ), 417 ),
344 width: 150, 418 width: 150,
345 height: 150, 419 height: 150,
  420 + ),
346 ); 421 );
347 }, 422 },
348 ), 423 ),
@@ -355,15 +430,19 @@ void main() { @@ -355,15 +430,19 @@ void main() {
355 textDirection: TextDirection.ltr, 430 textDirection: TextDirection.ltr,
356 pageFormat: const PdfPageFormat(150, 150), 431 pageFormat: const PdfPageFormat(150, 150),
357 build: (Context context) { 432 build: (Context context) {
358 - return Container( 433 + return TestAnnotation(
  434 + anno: 'LTR RadiusDirectional.horizontal end',
  435 + child: Container(
  436 + margin: const EdgeInsets.only(top: 22),
359 decoration: const BoxDecoration( 437 decoration: const BoxDecoration(
360 color: PdfColors.blue, 438 color: PdfColors.blue,
361 borderRadius: BorderRadiusDirectional.horizontal( 439 borderRadius: BorderRadiusDirectional.horizontal(
362 - start: Radius.circular(20), 440 + end: Radius.circular(20),
363 ), 441 ),
364 ), 442 ),
365 width: 150, 443 width: 150,
366 height: 150, 444 height: 150,
  445 + ),
367 ); 446 );
368 }, 447 },
369 ), 448 ),
@@ -376,15 +455,19 @@ void main() { @@ -376,15 +455,19 @@ void main() {
376 textDirection: TextDirection.ltr, 455 textDirection: TextDirection.ltr,
377 pageFormat: const PdfPageFormat(150, 150), 456 pageFormat: const PdfPageFormat(150, 150),
378 build: (Context context) { 457 build: (Context context) {
379 - return Container( 458 + return TestAnnotation(
  459 + anno: 'LTR RadiusDirectional.only topEnd',
  460 + child: Container(
  461 + margin: const EdgeInsets.only(top: 11),
380 decoration: const BoxDecoration( 462 decoration: const BoxDecoration(
381 color: PdfColors.blue, 463 color: PdfColors.blue,
382 borderRadius: BorderRadiusDirectional.only( 464 borderRadius: BorderRadiusDirectional.only(
383 - topStart: Radius.circular(20), 465 + topEnd: Radius.circular(20),
384 ), 466 ),
385 ), 467 ),
386 width: 150, 468 width: 150,
387 height: 150, 469 height: 150,
  470 + ),
388 ); 471 );
389 }, 472 },
390 ), 473 ),
@@ -397,16 +480,19 @@ void main() { @@ -397,16 +480,19 @@ void main() {
397 textDirection: TextDirection.rtl, 480 textDirection: TextDirection.rtl,
398 pageFormat: const PdfPageFormat(150, 150), 481 pageFormat: const PdfPageFormat(150, 150),
399 build: (Context context) { 482 build: (Context context) {
400 - return GridView( 483 + return TestAnnotation(
  484 + anno: 'RTL GridView Axis.vertical',
  485 + child: GridView(
401 crossAxisCount: 3, 486 crossAxisCount: 3,
402 childAspectRatio: 1, 487 childAspectRatio: 1,
403 direction: Axis.vertical, 488 direction: Axis.vertical,
404 children: [ 489 children: [
405 - for (int i = 0; i < 8; i++) 490 + for (int i = 0; i < 7; i++)
406 Container( 491 Container(
407 color: [PdfColors.blue, PdfColors.red, PdfColors.yellow][i % 3], 492 color: [PdfColors.blue, PdfColors.red, PdfColors.yellow][i % 3],
408 ), 493 ),
409 ], 494 ],
  495 + ),
410 ); 496 );
411 }, 497 },
412 ), 498 ),
@@ -419,7 +505,9 @@ void main() { @@ -419,7 +505,9 @@ void main() {
419 textDirection: TextDirection.ltr, 505 textDirection: TextDirection.ltr,
420 pageFormat: const PdfPageFormat(150, 150), 506 pageFormat: const PdfPageFormat(150, 150),
421 build: (Context context) { 507 build: (Context context) {
422 - return GridView( 508 + return TestAnnotation(
  509 + anno: 'LTR GridView Axis.vertical',
  510 + child: GridView(
423 crossAxisCount: 3, 511 crossAxisCount: 3,
424 childAspectRatio: 1, 512 childAspectRatio: 1,
425 direction: Axis.vertical, 513 direction: Axis.vertical,
@@ -429,6 +517,7 @@ void main() { @@ -429,6 +517,7 @@ void main() {
429 color: [PdfColors.blue, PdfColors.red, PdfColors.yellow][i % 3], 517 color: [PdfColors.blue, PdfColors.red, PdfColors.yellow][i % 3],
430 ), 518 ),
431 ], 519 ],
  520 + ),
432 ); 521 );
433 }, 522 },
434 ), 523 ),
@@ -440,7 +529,7 @@ void main() { @@ -440,7 +529,7 @@ void main() {
440 textDirection: TextDirection.rtl, 529 textDirection: TextDirection.rtl,
441 pageFormat: const PdfPageFormat(150, 150), 530 pageFormat: const PdfPageFormat(150, 150),
442 build: (Context context) { 531 build: (Context context) {
443 - return GridView( 532 + return TestAnnotation(anno: 'RTL GridView Axis.horizontal', child: GridView(
444 crossAxisCount: 3, 533 crossAxisCount: 3,
445 childAspectRatio: 1, 534 childAspectRatio: 1,
446 direction: Axis.horizontal, 535 direction: Axis.horizontal,
@@ -450,7 +539,7 @@ void main() { @@ -450,7 +539,7 @@ void main() {
450 color: [PdfColors.blue, PdfColors.red, PdfColors.yellow][i % 3], 539 color: [PdfColors.blue, PdfColors.red, PdfColors.yellow][i % 3],
451 ), 540 ),
452 ], 541 ],
453 - ); 542 + ),);
454 }, 543 },
455 ), 544 ),
456 ); 545 );
@@ -462,7 +551,7 @@ void main() { @@ -462,7 +551,7 @@ void main() {
462 textDirection: TextDirection.ltr, 551 textDirection: TextDirection.ltr,
463 pageFormat: const PdfPageFormat(150, 150), 552 pageFormat: const PdfPageFormat(150, 150),
464 build: (Context context) { 553 build: (Context context) {
465 - return GridView( 554 + return TestAnnotation(anno: 'LTR GridView Axis.horizontal', child: GridView(
466 crossAxisCount: 3, 555 crossAxisCount: 3,
467 childAspectRatio: 1, 556 childAspectRatio: 1,
468 direction: Axis.horizontal, 557 direction: Axis.horizontal,
@@ -472,7 +561,7 @@ void main() { @@ -472,7 +561,7 @@ void main() {
472 color: [PdfColors.blue, PdfColors.red, PdfColors.yellow][i % 3], 561 color: [PdfColors.blue, PdfColors.red, PdfColors.yellow][i % 3],
473 ), 562 ),
474 ], 563 ],
475 - ); 564 + ),);
476 }, 565 },
477 ), 566 ),
478 ); 567 );
@@ -483,3 +572,30 @@ void main() { @@ -483,3 +572,30 @@ void main() {
483 await file.writeAsBytes(await pdf.save()); 572 await file.writeAsBytes(await pdf.save());
484 }); 573 });
485 } 574 }
  575 +
  576 +class TestAnnotation extends StatelessWidget {
  577 + TestAnnotation({required this.anno, required this.child});
  578 +
  579 + final String anno;
  580 + final Widget child;
  581 +
  582 + @override
  583 + Widget build(Context context) {
  584 + return Stack(children: [
  585 + child,
  586 + Positioned(
  587 + top: 0,
  588 + right: 0,
  589 + left: 0,
  590 + child: Container(
  591 + color: PdfColors.white,
  592 + child: Text(
  593 + anno,
  594 + style: const TextStyle(color: PdfColors.black, fontSize: 9),
  595 + textAlign: TextAlign.center,
  596 + ),
  597 + ),
  598 + ),
  599 + ]);
  600 + }
  601 +}