패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.0.10

svg_to_paint

svg_to_paint 는 SVG 파일에서 Dart 코드를 생성합니다. XML 파일이 주어지면 명령을 입력하기만 하면 간단히 그릴 수 있습니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
37
좋아요
38
Pub 점수
160

패키지 설치

flutter pub add svg_to_paint

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

svg_to_paint는 SVG 파일을 Dart 코드로 변환하여 Flutter 애플리케이션에서 벡터 그래픽을 직접 렌더링할 수 있도록 해주는 Flutter/Dart 패키지입니다. 간단한 명령어를 실행함으로써 개발자들은 XML 기반의 SVG를 재사용 가능한 Paint 객체로 변환할 수 있으며, 아이콘과 일러스트레이션을 효율적이고 확장 가능하게 그릴 수 있습니다. 이 도구는 수동 경로 생성이나 복잡한 파싱 로직 없이도 SVG 자산을 통합하는 과정을 단순화합니다. Android, iOS, Web, macOS, Windows, Linux 등 모든 주요 플랫폼을 지원합니다.

사용 사례

  • SVG 아이콘을 Flutter 호환 코드로 변환하기
  • 앱에서 벡터 그래픽 생성 자동화
  • UI 디자인에서 아이콘 관리 간소화
  • 외부 종속성 없이 확장 가능한 그래픽 통합
  • SVG 소스에서 동적 일러스트 만들기

주요 기능

  • 명령줄을 통한 SVG에서 Dart 코드로의 변환
  • 모든 플러터 플랫폼을 지원합니다
  • 깨끗하고 읽기 쉬운 Dart 코드를 생성합니다
  • 최소한의 설정 필요
  • SVG의 확장성과 품질을 유지합니다

적합한 대상

  • SVG 자산을 사용하는 Flutter 개발자
  • 벡터 그래픽을 통합하는 UI 디자이너
  • 경량 아이콘 렌더링이 필요한 프로젝트
  • 확장 가능하고 해상도에 관계없이 사용 가능한 시각적 요소가 필요한 앱
  • 자산 처리 워크플로를 자동화하는 팀

고려 사항

  • 변환을 위해 명령줄 액세스가 필요합니다
  • 생성된 코드는 수동 최적화가 필요할 수 있습니다
  • 런타임 SVG 파싱에 적합하지 않습니다
  • 정적 SVG에 한정
  • 초기 설정을 위해 외부 도구에 의존합니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Flutter Svg to Paint Package

Pub Flutter Website NodeJs Website Star on Github License: MIT


svg_to_paint generates dart code from a svg file. This package is an abstraction of NodeJs package svg_to_paint.


Requirements

Node.JS v10+

Install

$ flutter pub global activate svg_to_paint

Usage

  1. Convert your xml svg in vector drawable (for example in https://svg2vector.com)

  2. Type in terminal:

svg_to_paint source_file_path destination_path name_file command

Params

* - required

  • source_file_path * - is the path of your file, for example (/Users/user/Desktop/file.xml)

  • destination_path * - is the destination path of your dart generated files, for example (/Users/user/Desktop)

  • name_file * - is the name of your file, for example (icon)

  • command * - represents the coordinates type of svg. You can choose absolute or relative.

Example

Given the svg file icon.xml in the folder named test, we will generate dart files in the same folder.

svg_to_paint /User/dev/test/icon.xml /User/dev/test icon absolute

Generates:

dev
└───test
│   │   auto_painter.dart
│   │   icon_generated.dart

Generated icon_generated.dart:

// GENERATED CODE

import 'auto_painter.dart'; 

class IconGenerated extends CustomPainter { 

  final viewPortWidth = 24; 
  final viewPortHeight = 24; 

  String path0 = 'M,23.4,12.3,C,23.4,11.5,23.299999999999997,10.700000000000001,23.2,9.9,H,12,V,14.5,H,18.4,C,18.099999999999998,16,17.299999999999997,17.3,15.999999999999998,18.1,V,21.1,H,19.799999999999997,C,22.1,19,23.4,15.9,23.4,12.3,Z';
  String path1 = 'M,12,24,C,15.2,24,17.9,22.9,19.9,21.1,L,16.099999999999998,18.1,C,14.999999999999998,18.8,13.599999999999998,19.200000000000003,11.999999999999998,19.200000000000003,C,8.899999999999999,19.200000000000003,6.199999999999998,17.1,5.299999999999998,14.300000000000002,H,1.299999999999998,V,17.400000000000002,C,3.3,21.4,7.5,24,12,24,Z';
  String path2 = 'M,5.3,14.3,C,4.8,12.8,4.8,11.200000000000001,5.3,9.700000000000001,V,6.6,H,1.2999999999999998,C,-0.40000000000000013,10,-0.40000000000000013,14,1.2999999999999998,17.299999999999997,L,5.3,14.3,Z';
  String path3 = 'M,12,4.8,C,13.7,4.8,15.3,5.3999999999999995,16.6,6.6,L,16.6,6.6,L,20,3.2,C,17.8,1.2000000000000002,15,0.10000000000000009,12,0.10000000000000009,C,7.5,0,3.3,2.6,1.3,6.6,L,5.3,9.7,C,6.2,6.9,8.9,4.8,12,4.8,Z';

  @override
   void paint(Canvas canvas, Size size) {
    canvas.drawRect(Rect.fromLTRB(0, 0, size.width, size.height),
        Paint()..color = Color(0xFFffffff)); 

  canvas.drawPath(drawPath(path0, viewPortWidth, viewPortHeight, size), Paint()..color = Color(0xFF4285F4)); 
  canvas.drawPath(drawPath(path1, viewPortWidth, viewPortHeight, size), Paint()..color = Color(0xFF34A853)); 
  canvas.drawPath(drawPath(path2, viewPortWidth, viewPortHeight, size), Paint()..color = Color(0xFFFBBC04)); 
  canvas.drawPath(drawPath(path3, viewPortWidth, viewPortHeight, size), Paint()..color = Color(0xFFEA4335)); 
 }

  @override
  bool shouldRepaint(CustomPainter oldDelegate) => false; 

} 

and auto_painter.dart which will contains the methods to draw

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

카테고리

의존성

의존성 목록 2 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.