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

패키지 상세v7.5.0

figma

순수한 Dart로 작성된 Figma 문서와 상호 작용하기 위한 Figma API 래퍼 라이브러리입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
2천
좋아요
25
Pub 점수
130

패키지 설치

flutter pub add figma

패키지 개요

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

figma 패키지는 Figma API에 대한 깔끔하고 순수한 Dart 인터페이스를 제공하는 Dart 라이브러리입니다. 개발자가 Figma 문서와 프로그래밍 방식으로 상호 작용할 수 있게 해줍니다. 디자인 파일을 가져오고, 자산을 검색하며, 여러 플랫폼에서 컴포넌트를 관리하는 것을 지원합니다. Flutter 앱이나 도구에 Figma 데이터를 통합하기에 적합하며, 인증 및 요청 처리를 간소화합니다. 이 라이브러리는 활발히 유지 보수되고 있으며 Android, iOS, Web, macOS, Windows, Linux와 호환됩니다.

사용 사례

  • Figma에서 디자인 파일을 가져오는 중
  • 앱에서 디자인 토큰 동기화
  • 자산 추출 자동화
  • CI/CD 파이프라인에 Figma 데이터 통합하기
  • 건축 설계 협업 도구

주요 기능

  • 순수한 다트 구현
  • 크로스 플랫폼 지원
  • 인증 처리
  • 타입 안전한 API 응답
  • Flutter와의 간편한 통합

적합한 대상

  • Figma를 사용하는 Flutter 개발자
  • 디자인 시스템 도구
  • 디자인 자산을 포함하는 CI/CD 워크플로우
  • Teams automating design-to-code processes

고려 사항

  • Figma API 개인 액세스 토큰이 필요합니다
  • Figma API에 속도 제한이 적용됩니다
  • 적절한 승인 없이 공개 또는 공유된 Figma 파일에 한정됨
  • 완전한 Figma 클라이언트는 아니며, API 상호작용만 가능

원본 README

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

figma

Dart CI pub license

A library for interacting with Figma APIs with typed responses and data structures for working with Figma programatically.

Features

  • 🚀 Full Figma API coverage with typed responses
  • 🔒 Support for both API token and OAuth authentication
  • 🔄 Support for variables (both local and published)
  • 🛠️ Comprehensive component and style handling
  • 📱 Export capabilities including PDF format
  • 🧩 Support for component sets and variants

Installation

Add the package to your pubspec.yaml:

dependencies:
  figma: ^7.3.4

Or install it using the Dart package manager:

dart pub add figma

Getting Started

Authentication

To use the Figma API, you'll need an access token. You can obtain one in two ways:

  1. Personal Access Token: Generate from your Figma account settings
  2. OAuth Token: Implement OAuth flow in your application
Basic Usage
import 'package:figma/figma.dart';

void main() async {
  // Initialize the client with your access token
  final figma = FigmaClient('your_access_token');
  
  // Get a Figma file
  final file = await figma.getFile('file_key');
  
  // Access file data
  print(file.name);
  print(file.lastModified);
}

Working with Files

Retrieving File Information
// Get file with components
final fileWithComponents = await figma.getFileWithNodes(
  'file_key',
  ['node_id_1', 'node_id_2']
);

// Get file styles
final styles = await figma.getFileStyles('file_key');

// Get component sets
final components = await figma.getFileComponentSets('file_key');
Working with Images
// Export images
final images = await figma.getImage(
  'file_key',
  ['node_id'],
  format: 'png',
  scale: 2
);

// Get image fills
final imageFills = await figma.getImageFills(['image_ref_1', 'image_ref_2']);

Advanced Features

Variables Support
// Get local variables
final localVars = await figma.getLocalVariables('file_key');

// Get published variables
final publishedVars = await figma.getPublishedVariables('file_key');
Component Management
// Get team components
final teamComponents = await figma.getTeamComponents('team_id');

// Get component info
final componentInfo = await figma.getComponent('component_id');
Comments and Collaboration
// Post a comment
await figma.postComment(
  'file_key',
  'This is a comment',
  clientMetadata: {'key': 'value'}
);

// Get file comments
final comments = await figma.getComments('file_key');

Best Practices

  1. Error Handling: The library throws FigmaException for API errors. Always implement proper error handling:

    try {
      final file = await figma.getFile('file_key');
    } on FigmaException catch (e) {
      print('Figma API error: ${e.message}');
    }
    
  2. Resource Management: When working with large files, request only the nodes you need:

    // Instead of getting the entire file
    final specificNodes = await figma.getFileNodes(
      'file_key',
      ['specific_node_id']
    );
    
  3. Rate Limiting: Implement appropriate rate limiting in your application to avoid hitting Figma's API limits.

Automation Examples

Export All Frame Images
Future<void> exportAllFrames(String fileKey) async {
  final figma = FigmaClient('your_token');
  final file = await figma.getFile(fileKey);
  
  final frameIds = file.document.children
      .whereType<Frame>()
      .map((frame) => frame.id)
      .toList();
      
  final images = await figma.getImage(
    fileKey,
    frameIds,
    format: 'png'
  );
}

TypeScript/JavaScript Integration

When using this library in Flutter web projects that interact with JavaScript/TypeScript codebases:

// Dart
final jsonData = await figma.getFile('file_key');
// Convert to JSON string for JS interop
final jsonString = jsonEncode(jsonData);
// TypeScript
interface FigmaFile {
  // Your TypeScript type definitions
}

const figmaData: FigmaFile = JSON.parse(jsonString);

Resources

Contributing

Contributions are welcome! Please read our contributing guidelines and submit pull requests to our GitHub repository.

License

This project is licensed under the MIT License - see the LICENSE file for details.

카테고리

의존성

의존성 목록 6 개

소스 저장소

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

아직 데이터가 없습니다.