Repository: flutter
Issue: [vector_graphics] Cannot set RenderingStrategy to picture
Labels: c: new feature,package,c: proposal,workaround available,team-engine,p: vector_graphics

### Use case

I use vector_graphics_compiler to compile a list of SVGs into vector format for vector_graphics. Specifically, I'm using them for country flags. The problem is that with `RenderingStrategy.raster` rendering is way less performant for them.

### Proposal

Currently, raster mode is hardcoded in VectorGraphic widget, so a better idea would be to allow specifying it.

Moreover, raster mode results in some canvas kit issues when this list is scrolled quite fast.

<details>
Restarted application in 89ms.
Aborted()
══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
The following NativeError object was thrown during paint():
  RuntimeError: Aborted(). Build with -sASSERTIONS for more info.

The relevant error-causing widget was:
  FlagWidget
  FlagWidget:file:///Users/mykhailo.lazebnyi/projects/ignite-sdk/packages/core/nexus/widgetbook/lib/src/preview/components/core/flag/country_flag_preview.dart:11:20

When the exception was thrown, this was the stack:
https://www.gstatic.com/flutter-canvaskit/a18df97ca57a249df5d8d68cd0820600223ce262/chromium/canvaskit.js 93:151   Ea
https://www.gstatic.com/flutter-canvaskit/a18df97ca57a249df5d8d68cd0820600223ce262/chromium/canvaskit.js 169:377  k
https://www.gstatic.com/flutter-canvaskit/a18df97ca57a249df5d8d68cd0820600223ce262/chromium/canvaskit.js 116:52   <fn>
https://www.gstatic.com/flutter-canvaskit/a18df97ca57a249df5d8d68cd0820600223ce262/chromium/canvaskit.js 106:260  <computed>
https://www.gstatic.com/flutter-canvaskit/a18df97ca57a249df5d8d68cd0820600223ce262/chromium/canvaskit.js 33:9     g
https://www.gstatic.com/flutter-canvaskit/a18df97ca57a249df5d8d68cd0820600223ce262/chromium/canvaskit.js 43:340   readPixels
lib/_engine/engine/canvaskit/canvaskit_api.dart 1179:7                                                            SkImageExtension.readPixels
lib/_engine/engine/canvaskit/picture.dart 108:38                                                                  toImageSync
packages/vector_graphics/src/render_vector_graphic.dart 215:22                                                    _createRaster
packages/vector_graphics/src/render_vector_graphic.dart 252:9                                                     [_maybeUpdateRaster]
packages/vector_graphics/src/render_vector_graphic.dart 299:5                                                     paint
packages/flutter/src/rendering/object.dart 3268:7                                                                 [_paintWithContext]
packages/flutter/src/rendering/object.dart 251:12                                                                 paintChild
packages/flutter/src/rendering/proxy_box.dart 136:12                                                              paint
packages/flutter/src/rendering/object.dart 3268:7                                                                 [_paintWithContext]
packages/flutter/src/rendering/object.dart 251:12                                                                 paintChild
packages/flutter/src/rendering/proxy_box.dart 136:12                                                              paint
packages/flutter/src/rendering/object.dart 688:7                                                                  pushTransform
packages/flutter/src/rendering/proxy_box.dart 2800:21                                                             [_paintChildWithTransform]
packages/flutter/src/rendering/proxy_box.dart 2830:15                                                             paint
packages/flutter/src/rendering/object.dart 3268:7                                                                 [_paintWithContext]
packages/flutter/src/rendering/object.dart 251:12                                                                 paintChild
packages/flutter/src/rendering/proxy_box.dart 136:12                                                              paint
packages/flutter/src/rendering/object.dart 3268:7                                                                 [_paintWithContext]
packages/flutter/src/rendering/object.dart 251:12                                                                 paintChild
packages/flutter/src/rendering/proxy_box.dart 136:12                                                              paint
packages/flutter/src/rendering/object.dart 3268:7                                                                 [_paintWithContext]
packages/flutter/src/rendering/object.dart 251:12                                                                 paintChild
packages/flutter/src/rendering/proxy_box.dart 136:12                                                              paint
packages/flutter/src/rendering/object.dart 3268:7                                                                 [_paintWithContext]
packages/flutter/src/rendering/object.dart 251:12                                                                 paintChild
packages/flutter/src/rendering/proxy_box.dart 136:12                                                              paint
packages/flutter/src/rendering/object.dart 3268:7                                                                 [_paintWithContext]
packages/flutter/src/rendering/object.dart 167:10                                                                 _repaintCompositedChild
packages/flutter/src/rendering/object.dart 110:5                                                                  repaintCompositedChild
packages/flutter/src/rendering/object.dart 1183:31                                                                flushPaint
packages/flutter/src/rendering/object.dart 1193:14                                                                flushPaint
packages/flutter/src/rendering/binding.dart 604:5                                                                 drawFrame
packages/flutter/src/widgets/binding.dart 1164:13                                                                 drawFrame
packages/flutter/src/rendering/binding.dart 468:5                                                                 [_handlePersistentFrameCallback]
packages/flutter/src/scheduler/binding.dart 1397:7                                                                [_invokeFrameCallback]
packages/flutter/src/scheduler/binding.dart 1318:9                                                                handleDrawFrame
packages/flutter/src/scheduler/binding.dart 1176:5                                                                [_handleDrawFrame]
lib/_engine/engine/platform_dispatcher.dart 1408:5                                                                invoke
lib/_engine/engine/platform_dispatcher.dart 310:5                                                                 invokeOnDrawFrame
lib/_engine/engine/initialization.dart 187:36                                                                     <fn>
dart-sdk/lib/_internal/js_dev_runtime/patch/js_allow_interop_patch.dart 188:27                                    _callDartFunctionFast1

The following RenderObject was being processed when the exception was fired: RenderVectorGraphic#ce3c8:
  creator: _RawVectorGraphicWidget ← SizedBox ← FittedBox ← SizedBox ← Semantics ← VectorGraphic ←
    FlagWidget ← SizedBox ← RepaintBoundary ← IndexedSemantics ← _SelectionKeepAlive ←
    NotificationListener<KeepAliveNotification> ← ⋯
  parentData: <none> (can use size)
  constraints: BoxConstraints(w=640.0, h=480.0)
  size: Size(640.0, 480.0)
This RenderObject has no descendants.
════════════════════════════════════════════════════════════════════════════════════════════════════
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'
Another exception was thrown: TypeError: null: type 'Null' is not a subtype of type 'NativeUint8List'


</details>