パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v7.5.0

figma

純粋なDartで書かれた、Figmaドキュメントと対話するためのFigma APIラッパーライブラリです。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
2040
いいね数
25
Pub ポイント
130

パッケージをインストール

flutter pub add figma

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

figma パッケージは、Figma API に対してクリーンで純粋な Dart インターフェースを提供する Dart ライブラリです。開発者が Figma ドキュメントとプログラム的にやり取りできるようにします。デザインファイルの取得、アセットの取得、複数のプラットフォームでのコンポーネントの管理をサポートしています。Flutter アプリやツールに Figma データを統合するのに最適で、認証およびリクエスト処理を簡素化します。このライブラリは積極的にメンテナンスされており、Android、iOS、Web、macOS、Windows、Linux と互換性があります。

用途

  • Figma からデザインファイルを取得しています
  • アプリでデザイントークンを同期する
  • アセット抽出の自動化
  • FigmaデータをCI/CDパイプラインに統合する
  • 建築デザイン協業ツール

主な機能

  • 純粋なDart実装
  • クロスプラットフォーム対応
  • 認証の処理
  • 型安全な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 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。