SvgPicture.file constructor
- File file, {
- Key? key,
- double? width,
- double? height,
- BoxFit fit = BoxFit.contain,
- AlignmentGeometry alignment = Alignment.center,
- bool matchTextDirection = false,
- bool allowDrawingOutsideViewBox = false,
- WidgetBuilder? placeholderBuilder,
- Color? color,
- BlendMode colorBlendMode = BlendMode.srcIn,
- String? semanticsLabel,
- bool excludeFromSemantics = false,
- Clip clipBehavior = Clip.hardEdge,
- bool cacheColorFilter = false,
- SvgTheme? theme,
Creates a widget that displays a PictureStream obtained from a File.
The file
argument must not be null.
Either the width
and height
arguments should be specified, or the
widget should be placed in a context that sets tight layout constraints.
Otherwise, the image dimensions will change as the image is loaded, which
will result in ugly layout changes.
If matchTextDirection
is set to true, the picture will be flipped
horizontally in TextDirection.rtl contexts.
The allowDrawingOutsideOfViewBox
parameter should be used with caution -
if set to true, it will not clip the canvas used internally to the view box,
meaning the picture may draw beyond the intended area and lead to undefined
behavior or additional memory overhead.
A custom placeholderBuilder
can be specified for cases where decoding or
acquiring data may take a noticeably long time.
The color
and colorBlendMode
arguments, if specified, will be used to set a
ColorFilter on any Paints created for this drawing.
The theme
argument, if provided, will override the default theme
used when parsing SVG elements.
On Android, this may require the
android.permission.READ_EXTERNAL_STORAGE
permission.
If excludeFromSemantics
is true, then semanticLabel
will be ignored.
Implementation
SvgPicture.file(
File file, {
Key? key,
this.width,
this.height,
this.fit = BoxFit.contain,
this.alignment = Alignment.center,
this.matchTextDirection = false,
this.allowDrawingOutsideViewBox = false,
this.placeholderBuilder,
Color? color,
BlendMode colorBlendMode = BlendMode.srcIn,
this.semanticsLabel,
this.excludeFromSemantics = false,
this.clipBehavior = Clip.hardEdge,
this.cacheColorFilter = false,
this.theme,
}) : pictureProvider = FilePicture(
allowDrawingOutsideViewBox == true
? svgByteDecoderOutsideViewBoxBuilder
: svgByteDecoderBuilder,
file,
colorFilter: svg.cacheColorFilterOverride ?? cacheColorFilter
? _getColorFilter(color, colorBlendMode)
: null,
),
colorFilter = _getColorFilter(color, colorBlendMode),
super(key: key);