figma
Figma डॉक्यूमेंट्स के साथ इंटरैक्ट करने के लिए एक Figma API व्रैपर लाइब्रेरी, शुद्ध Dart में लिखा गया।
शुद्ध डार्ट में लिखा गया फिग्मा API क्लाइंट
यह अंग्रेज़ी मूल स्नैपशॉट है। नवीनतम सामग्री GitHub पर देखें।
A library for interacting with Figma APIs with typed responses and data structures for working with Figma programatically.
Add the package to your pubspec.yaml:
dependencies:
figma: ^7.3.4
Or install it using the Dart package manager:
dart pub add figma
To use the Figma API, you'll need an access token. You can obtain one in two ways:
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);
}
// 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');
// 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']);
// Get local variables
final localVars = await figma.getLocalVariables('file_key');
// Get published variables
final publishedVars = await figma.getPublishedVariables('file_key');
// Get team components
final teamComponents = await figma.getTeamComponents('team_id');
// Get component info
final componentInfo = await figma.getComponent('component_id');
// 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');
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}');
}
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']
);
Rate Limiting: Implement appropriate rate limiting in your application to avoid hitting Figma's API limits.
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'
);
}
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);
Contributions are welcome! Please read our contributing guidelines and submit pull requests to our GitHub repository.
This project is licensed under the MIT License - see the LICENSE file for details.
निर्भरता सूची 22 आइटम
^1.19.0>=10.0.0 <18.0.0^2.0.0^1.0.0^2.0.0^4.9.0^1.9.1^2.7.0^2.8.0^2.2.0>=0.4.2 <0.6.0^4.11.1>=10.0.0 <18.0.0^3.1.3^6.11.1^6.0.0^1.3.0^7.3.0^1.9.1^2.2.0^1.26.3^3.1.3उपयोग के अनुसार छाँटें, गतिविधि की तुलना करें और अपनाने से पहले मूल प्रोजेक्ट की आवश्यकताएँ जाँचें।
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗