Android, iOS, Web, macOS, Windows, Linux에서 SVG 편집 및 조작을 가능하게 하는 플러터 패키지입니다. 벡터 그래픽을 직접 Flutter 애플리케이션 내에서 수정할 수 있는 도구를 제공하며, 형태 조정, 색상 변경, 레이어 관리 등의 기능을 지원합니다. 크로스플랫폼 일관성을 위해 설계되었으며, 기존의 플러터 워크플로우와 원활하게 통합됩니다. 외부 도구에 의존하지 않고 상호작용 가능한 SVG 커스터마이징이 필요한 앱에 이상적입니다.
사용 사례
모바일 앱에서의 인터랙티브 SVG 디자인
웹 기반 벡터 그래픽 편집기
크로스플랫폼 이미지 커스터마이징 도구
실시간 SVG 렌더링 및 수정
시각 콘텐츠 편집 기능을 갖춘 교육용 앱
주요 기능
크로스 플랫폼 SVG 지원
실시간 편집 기능
벡터 기반 조작
Flutter 위젯 시스템과의 통합
경량 및 모듈식 아키텍처
적합한 대상
다중미디어 앱을 개발하는 개발자
디자인 중심의 플러터 애플리케이션
SVG 상호작용을 필요로 하는 도구
다중 플랫폼 앱 제작자
사용자 생성 콘텐츠를 포함하는 앱
고려 사항
SVG 형식으로만 제한
벡터 그래픽에 대한 이해가 필요합니다
복잡한 SVG에 따라 성능이 달라질 수 있습니다
래스터 형식으로 내장된 내보내기 없음
상류 SVG 파싱 라이브러리에 의존
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
SvgPicEditor
SvgPicEditor is a Flutter widget that allows you to load and modify SVG files from various sources, such as local assets, SVG strings, or URLs. This widget also lets you modify specific SVG elements using the ElementEdit class, making it easy to change properties like color, opacity, transformations, and more. The new listenEdit and getColors features further expand the possibilities for manipulating and customizing SVGs.
This example loads an SVG file from a local asset, modifies it, and adds the onTap callback to handle tap actions, printing either the modified SVG string or no value at all.
The listenEdit feature allows you to listen for edits made to the SVG content and get updates about the modified SVG.
SvgPicEditor.asset(
'assets/example.svg',
modifications: [
ElementEdit(
querySelector: '#element1',
fillColor: Colors.red,
),
],
width: 200.0,
height: 200.0,
fit: BoxFit.contain,
listenEdit: (svgContent) {
// Whenever the SVG is edited, the updated content will be printedprint('Edited SVG content: $svgContent');
},
);
Using getColors to Retrieve Colors from the SVG
The getColors feature allows you to extract color information from an SVG. It returns an SvgColorElement containing the color and the elements associated with it in the SVG.
SvgPicEditor.asset(
'assets/example.svg',
modifications: [
ElementEdit(
querySelector: '#element1',
fillColor: Colors.red,
),
],
width: 200.0,
height: 200.0,
fit: BoxFit.contain,
getColor: (List<SvgColorElement> colors) {
// Retrieve the colors and associated elements from the SVG
colors.forEach((colorElement) {
print('Color: ${colorElement.color}');
colorElement.parts.forEach((part) { // List of associated elementsprint('Element: ${part.querySelector}');
});
});
},
);
Conclusion
With the new listenEdit, getColors, and onTap features, SvgPicEditor becomes an even more powerful and flexible tool for manipulating and customizing SVGs in Flutter. Now, in addition to modifying SVG elements, you can track real-time edits, extract valuable information about the colors and elements within the SVG, and trigger actions when the SVG is tapped.
Support the Project
If you would like to support the development of this project, you can make a contribution through PayPal. Your support helps keep the development active and adds new features.
Contribute via Inter Pix
You can make your donation by scanning the QR code below:
We truly appreciate your support!
Version 3.2.0
Improvements
Refined the onTap functionality, now supporting both void and modified SVG string returns for better flexibility.
Enhanced error handling in the SvgPicEditor widget, ensuring smoother user experience when errors occur.
Updated the modifiedSvgString update logic to improve the reactivity and ensure faster rendering.
New Features
Introduced the onTap callback function, allowing users to trigger actions when the SVG is tapped, either with the modified SVG string or without any return value.
Added shimmer effect loading for a smoother experience when the SVG is being processed.
Fixes
Corrected a potential issue with the SVG string processing, improving the integrity of the final modified output.
Minor optimizations in the way SVG parts are loaded for performance improvements.