createLocalPictureConfiguration function
PictureConfiguration
createLocalPictureConfiguration(
- BuildContext? context, {
- Rect? viewBox,
- ColorFilter? colorFilterOverride,
- Color? color,
- BlendMode? colorBlendMode,
Creates an PictureConfiguration based on the given BuildContext (and optionally size).
This is the object that must be passed to PictureProvider.resolve.
If this is not called from a build method, then it should be reinvoked whenever the dependencies change, e.g. by calling it from State.didChangeDependencies, so that any changes in the environment are picked up (e.g. if the device pixel ratio changes).
See also:
- PictureProvider, which has an example showing how this might be used.
Implementation
PictureConfiguration createLocalPictureConfiguration(
BuildContext? context, {
Rect? viewBox,
ColorFilter? colorFilterOverride,
Color? color,
BlendMode? colorBlendMode,
}) {
ColorFilter? filter = colorFilterOverride;
if (filter == null && color != null) {
filter = ColorFilter.mode(color, colorBlendMode ?? BlendMode.srcIn);
}
return PictureConfiguration(
bundle: context != null ? DefaultAssetBundle.of(context) : rootBundle,
locale: context != null ? Localizations.maybeLocaleOf(context) : null,
textDirection: context != null ? Directionality.maybeOf(context) : null,
viewBox: viewBox,
platform: defaultTargetPlatform,
colorFilter: filter,
);
}