David PHAM-VAN

Use covariant on SpanningWidget

@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 - Improve Text rendering 6 - Improve Text rendering
7 - Add individual cell decoration 7 - Add individual cell decoration
8 - Improve Bullet Widget 8 - Improve Bullet Widget
  9 +- Use covariant on SpanningWidget
9 10
10 ## 3.2.0 11 ## 3.2.0
11 12
@@ -67,11 +67,9 @@ class _FlexContext extends WidgetContext { @@ -67,11 +67,9 @@ class _FlexContext extends WidgetContext {
67 int lastChild = 0; 67 int lastChild = 0;
68 68
69 @override 69 @override
70 - void apply(WidgetContext other) {  
71 - if (other is _FlexContext) {  
72 - firstChild = other.firstChild;  
73 - lastChild = other.lastChild;  
74 - } 70 + void apply(_FlexContext other) {
  71 + firstChild = other.firstChild;
  72 + lastChild = other.lastChild;
75 } 73 }
76 74
77 @override 75 @override
@@ -504,10 +502,8 @@ class Flex extends MultiChildWidget implements SpanningWidget { @@ -504,10 +502,8 @@ class Flex extends MultiChildWidget implements SpanningWidget {
504 bool get hasMoreWidgets => true; 502 bool get hasMoreWidgets => true;
505 503
506 @override 504 @override
507 - void restoreContext(WidgetContext context) {  
508 - if (context is _FlexContext) {  
509 - _context.firstChild = context.lastChild;  
510 - } 505 + void restoreContext(_FlexContext context) {
  506 + _context.firstChild = context.lastChild;
511 } 507 }
512 508
513 @override 509 @override
@@ -32,13 +32,11 @@ class _GridViewContext extends WidgetContext { @@ -32,13 +32,11 @@ class _GridViewContext extends WidgetContext {
32 double? childMainAxis; 32 double? childMainAxis;
33 33
34 @override 34 @override
35 - void apply(WidgetContext other) {  
36 - if (other is _GridViewContext) {  
37 - firstChild = other.firstChild;  
38 - lastChild = other.lastChild;  
39 - childCrossAxis = other.childCrossAxis;  
40 - childMainAxis = other.childMainAxis;  
41 - } 35 + void apply(_GridViewContext other) {
  36 + firstChild = other.firstChild;
  37 + lastChild = other.lastChild;
  38 + childCrossAxis = other.childCrossAxis;
  39 + childMainAxis = other.childMainAxis;
42 } 40 }
43 41
44 @override 42 @override
@@ -337,10 +335,8 @@ class GridView extends MultiChildWidget implements SpanningWidget { @@ -337,10 +335,8 @@ class GridView extends MultiChildWidget implements SpanningWidget {
337 bool get hasMoreWidgets => true; 335 bool get hasMoreWidgets => true;
338 336
339 @override 337 @override
340 - void restoreContext(WidgetContext context) {  
341 - if (context is _GridViewContext) {  
342 - _context.firstChild = context.lastChild;  
343 - } 338 + void restoreContext(_GridViewContext context) {
  339 + _context.firstChild = context.lastChild;
344 } 340 }
345 341
346 @override 342 @override
@@ -34,7 +34,7 @@ import 'widget.dart'; @@ -34,7 +34,7 @@ import 'widget.dart';
34 abstract class WidgetContext { 34 abstract class WidgetContext {
35 WidgetContext clone(); 35 WidgetContext clone();
36 36
37 - void apply(WidgetContext other); 37 + void apply(covariant WidgetContext other);
38 } 38 }
39 39
40 abstract class SpanningWidget extends Widget { 40 abstract class SpanningWidget extends Widget {
@@ -48,7 +48,7 @@ abstract class SpanningWidget extends Widget { @@ -48,7 +48,7 @@ abstract class SpanningWidget extends Widget {
48 48
49 /// Aplpy the context for next layout 49 /// Aplpy the context for next layout
50 @protected 50 @protected
51 - void restoreContext(WidgetContext context); 51 + void restoreContext(covariant WidgetContext context);
52 } 52 }
53 53
54 class NewPage extends Widget { 54 class NewPage extends Widget {
@@ -141,11 +141,9 @@ class _TableContext extends WidgetContext { @@ -141,11 +141,9 @@ class _TableContext extends WidgetContext {
141 int lastLine = 0; 141 int lastLine = 0;
142 142
143 @override 143 @override
144 - void apply(WidgetContext other) {  
145 - if (other is _TableContext) {  
146 - firstLine = other.firstLine;  
147 - lastLine = other.lastLine;  
148 - } 144 + void apply(_TableContext other) {
  145 + firstLine = other.firstLine;
  146 + lastLine = other.lastLine;
149 } 147 }
150 148
151 @override 149 @override
@@ -425,7 +423,7 @@ class Table extends Widget implements SpanningWidget { @@ -425,7 +423,7 @@ class Table extends Widget implements SpanningWidget {
425 } 423 }
426 424
427 @override 425 @override
428 - void restoreContext(WidgetContext context) { 426 + void restoreContext(_TableContext context) {
429 _context.apply(context); 427 _context.apply(context);
430 _context.firstLine = _context.lastLine; 428 _context.firstLine = _context.lastLine;
431 } 429 }
@@ -50,11 +50,9 @@ class _WrapContext extends WidgetContext { @@ -50,11 +50,9 @@ class _WrapContext extends WidgetContext {
50 int lastChild = 0; 50 int lastChild = 0;
51 51
52 @override 52 @override
53 - void apply(WidgetContext other) {  
54 - if (other is _WrapContext) {  
55 - firstChild = other.firstChild;  
56 - lastChild = other.lastChild;  
57 - } 53 + void apply(_WrapContext other) {
  54 + firstChild = other.firstChild;
  55 + lastChild = other.lastChild;
58 } 56 }
59 57
60 @override 58 @override
@@ -394,10 +392,8 @@ class Wrap extends MultiChildWidget implements SpanningWidget { @@ -394,10 +392,8 @@ class Wrap extends MultiChildWidget implements SpanningWidget {
394 } 392 }
395 393
396 @override 394 @override
397 - void restoreContext(WidgetContext context) {  
398 - if (context is _WrapContext) {  
399 - _context.firstChild = context.lastChild;  
400 - } 395 + void restoreContext(_WrapContext context) {
  396 + _context.firstChild = context.lastChild;
401 } 397 }
402 398
403 @override 399 @override