[flutter_svg] feat: Expose the colorMapper property in SvgPicture (#9043)
## Description
This pull request exposes the existing colorMapper functionality in the flutter_svg package, allowing developers to customize SVG colors during parsing.
## Related Issue
- https://github.com/flutter/flutter/issues/158634
## Motivation
The colorMapper functionality was already present within the flutter_svg package but was not directly accessible through the SvgPicture constructors. By exposing this property, developers gain a powerful and flexible way to dynamically modify the colors of SVG assets based on custom logic. This can be useful for various scenarios, such as theming or branding.
## Example Usage
```dart
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
const String svgString = '''
<svg viewBox="0 0 100 100">
<rect width="50" height="50" fill="#FF0000" />
<circle cx="75" cy="75" r="25" fill="#00FF00" />
</svg>
''';
class MyColorMapper extends ColorMapper {
const MyColorMapper();
@override
Color substitute(
String? id, String elementName, String attributeName, Color color) {
if (color == const Color(0xFFFF0000)) {
return Colors.blue;
}
if (color == const Color(0xFF00FF00)) {
return Colors.yellow;
}
return color;
}
}
void main() {
runApp(MaterialApp(
home: Scaffold(
body: Center(
child: SvgPicture.string(
svgString,
width: 200,
height: 200,
colorMapper: const MyColorMapper(),
),
),
),
));
}
```
[flutter_svg] Initial import
Imports https://github.com/dnfield/flutter_svg into this repository,
with history, and updates it to follow repository conventions:
- Updates min SDKs.
- Removes analysis options and fixes resulting warnings.
- Autoformats.
- Updates pubspecs to follow repo standard.
- Updates repo tooling to allow the flutter_svg_test non-dev
dependency on flutter_test.
- Adds repo metadata.
- Adds METADATA files.
- Adds commemoration to README.
- Updates example app Android build files to current standards.
- Bumps versions and slightly relax version constraints for
vector_graphics* to allow the new versions.
- Moves gitignore of golden test diffs into the package.
[flutter_svg] Initial import
Imports https://github.com/dnfield/flutter_svg into this repository,
with history, and updates it to follow repository conventions:
- Updates min SDKs.
- Removes analysis options and fixes resulting warnings.
- Autoformats.
- Updates pubspecs to follow repo standard.
- Updates repo tooling to allow the flutter_svg_test non-dev
dependency on flutter_test.
- Adds repo metadata.
- Adds METADATA files.
- Adds commemoration to README.
- Updates example app Android build files to current standards.
- Bumps versions and slightly relax version constraints for
vector_graphics* to allow the new versions.
- Moves gitignore of golden test diffs into the package.
[flutter_svg] Initial import
Imports https://github.com/dnfield/flutter_svg into this repository,
with history, and updates it to follow repository conventions:
- Updates min SDKs.
- Removes analysis options and fixes resulting warnings.
- Autoformats.
- Updates pubspecs to follow repo standard.
- Updates repo tooling to allow the flutter_svg_test non-dev
dependency on flutter_test.
- Adds repo metadata.
- Adds METADATA files.
- Adds commemoration to README.
- Updates example app Android build files to current standards.
- Bumps versions and slightly relax version constraints for
vector_graphics* to allow the new versions.
- Moves gitignore of golden test diffs into the package.
[flutter_svg] Initial import
Imports https://github.com/dnfield/flutter_svg into this repository,
with history, and updates it to follow repository conventions:
- Updates min SDKs.
- Removes analysis options and fixes resulting warnings.
- Autoformats.
- Updates pubspecs to follow repo standard.
- Updates repo tooling to allow the flutter_svg_test non-dev
dependency on flutter_test.
- Adds repo metadata.
- Adds METADATA files.
- Adds commemoration to README.
- Updates example app Android build files to current standards.
- Bumps versions and slightly relax version constraints for
vector_graphics* to allow the new versions.
- Moves gitignore of golden test diffs into the package.