Repository navigation
Commit 8bdce07
authored
Make shape border lerp symmetric (flutter#187282)
<img width="1536" height="1024" alt="ChatGPT Image May 29, 2026,
01_48_49 AM"
src="https://github.com/user-attachments/assets/1a48077b-6687-47de-820a-3171b8bde84b"
/>
<img width="1568" height="656" alt="image"
src="https://github.com/user-attachments/assets/83c0b20f-25c8-49af-b1e7-c57ac5ab4ec4"
/>
Fix flutter#110634 (took 4 years to
think on this solution!)
Make ShapeBorder.lerp use reverse interpolation before fallback
Some border pairs can already lerp with each other, but only one side
knows how to do it. For example, `StarBorder` knows how to lerp to
`RoundedRectangleBorder`, but `RoundedRectangleBorder` does not need to
know about `StarBorder`.
Instead of adding more pair-specific checks like `if (b is
RoundedRectangleBorder)` across shapes (at a certain point I even
considered sealed classes), we can make the central lerp smarter. After
trying the existing direction:
`b.lerpFrom(a, t) ?? a.lerpTo(b, t)`
also try the same animation from the opposite direction:
`b.lerpTo(a, 1.0 - t) ?? a.lerpFrom(b, 1.0 - t)`
So if `ShapeBorder.lerp(star, roundedRectangle, t)` works,
`ShapeBorder.lerp(roundedRectangle, star, t)` can reuse that same logic
on the reversed timeline instead of falling back to the hard switch at
`t = 0.5`.
This keeps the cross-shape behavior centralized in `ShapeBorder.lerp`
and `OutlinedBorder.lerp`, without changing direct `lerpFrom` or
`lerpTo` calls.1 parent 6414603 commit 8bdce07
2 files changed
Lines changed: 130 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
440 | 440 | | |
441 | 441 | | |
442 | 442 | | |
443 | | - | |
444 | | - | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
445 | 446 | | |
446 | 447 | | |
447 | 448 | | |
| |||
471 | 472 | | |
472 | 473 | | |
473 | 474 | | |
474 | | - | |
475 | | - | |
476 | 475 | | |
477 | | - | |
478 | | - | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
479 | 479 | | |
480 | 480 | | |
481 | 481 | | |
| |||
503 | 503 | | |
504 | 504 | | |
505 | 505 | | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
510 | 512 | | |
511 | 513 | | |
512 | 514 | | |
513 | 515 | | |
514 | 516 | | |
515 | 517 | | |
516 | | - | |
| 518 | + | |
| 519 | + | |
517 | 520 | | |
518 | 521 | | |
519 | 522 | | |
| |||
693 | 696 | | |
694 | 697 | | |
695 | 698 | | |
696 | | - | |
697 | | - | |
698 | | - | |
699 | | - | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
700 | 705 | | |
701 | 706 | | |
702 | 707 | | |
703 | 708 | | |
704 | 709 | | |
705 | 710 | | |
706 | | - | |
| 711 | + | |
| 712 | + | |
707 | 713 | | |
708 | 714 | | |
709 | 715 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
39 | 86 | | |
40 | 87 | | |
41 | 88 | | |
| |||
172 | 219 | | |
173 | 220 | | |
174 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
0 commit comments