Commit c5ab57a
authored
[flutter_svg] feat: Expose the renderStrategy property in SvgPicture (flutter#9373)
This PR exposes the `renderStrategy` property from the `vector_graphics` package to address the performance issue discussed in [#166184](flutter/flutter#166184).
By default, SVG widgets are rendered using the picture strategy, which records a list of drawing commands and replays them each frame. While this offers greater flexibility (e.g., for scaling), it can result in significant raster time when many SVGs are present in the widget tree.
As demonstrated in [#166184](flutter/flutter#166184), using the default strategy can lead to frame drops due to high raster time:
<img width="820" alt="image" src="https://github.com/user-attachments/assets/dfc58d50-c8b2-477e-9a75-fe0eb742f9c7" />
Switching to the raster strategy renders the SVGs into images ahead of time, reducing the raster workload:
<img width="894" alt="image" src="https://github.com/user-attachments/assets/2fd8ddbf-3693-4797-be99-8b0919ef1703" />
Exposing this property allows developers to choose between flexibility and performance based on their app’s needs.
Fixes flutter/flutter#166184
## Pre-Review Checklist1 parent 97fe921 commit c5ab57a
File tree
5 files changed
+135
-6
lines changed- third_party/packages/flutter_svg
- lib
- test
5 files changed
+135
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
137 | 142 | | |
138 | 143 | | |
139 | 144 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
| |||
201 | 202 | | |
202 | 203 | | |
203 | 204 | | |
| 205 | + | |
204 | 206 | | |
205 | 207 | | |
206 | 208 | | |
| |||
265 | 267 | | |
266 | 268 | | |
267 | 269 | | |
| 270 | + | |
268 | 271 | | |
269 | 272 | | |
270 | 273 | | |
| |||
325 | 328 | | |
326 | 329 | | |
327 | 330 | | |
| 331 | + | |
328 | 332 | | |
329 | 333 | | |
330 | 334 | | |
| |||
380 | 384 | | |
381 | 385 | | |
382 | 386 | | |
| 387 | + | |
383 | 388 | | |
384 | 389 | | |
385 | 390 | | |
| |||
435 | 440 | | |
436 | 441 | | |
437 | 442 | | |
| 443 | + | |
438 | 444 | | |
439 | 445 | | |
440 | 446 | | |
| |||
526 | 532 | | |
527 | 533 | | |
528 | 534 | | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
529 | 543 | | |
530 | 544 | | |
531 | 545 | | |
| |||
540 | 554 | | |
541 | 555 | | |
542 | 556 | | |
| 557 | + | |
543 | 558 | | |
544 | 559 | | |
545 | 560 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
Lines changed: 108 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
139 | 140 | | |
140 | 141 | | |
141 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
142 | 165 | | |
143 | 166 | | |
144 | 167 | | |
| |||
295 | 318 | | |
296 | 319 | | |
297 | 320 | | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
298 | 340 | | |
299 | 341 | | |
300 | 342 | | |
| |||
334 | 376 | | |
335 | 377 | | |
336 | 378 | | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
337 | 399 | | |
338 | 400 | | |
339 | 401 | | |
| |||
380 | 442 | | |
381 | 443 | | |
382 | 444 | | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
383 | 472 | | |
384 | 473 | | |
385 | 474 | | |
| |||
425 | 514 | | |
426 | 515 | | |
427 | 516 | | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
428 | 536 | | |
429 | 537 | | |
430 | 538 | | |
| |||
0 commit comments