|
| 1 | +# Getting Started with Figma Flutter MCP |
| 2 | + |
| 3 | +Welcome to Figma Flutter MCP! This guide will walk you through setting up and using the MCP server to convert Figma designs into Flutter code using AI-powered tools like Cursor. |
| 4 | + |
| 5 | +## 🚀 Quick Setup in Cursor |
| 6 | + |
| 7 | +### 1. Get Your Figma API Key |
| 8 | + |
| 9 | +First, you'll need a Figma access token: |
| 10 | + |
| 11 | +1. Go to [Figma Account Settings](https://www.figma.com/settings) |
| 12 | +2. Scroll down to "Personal access tokens" |
| 13 | +3. Click "Create new token" |
| 14 | +4. Give it a name (e.g., "Flutter MCP") |
| 15 | +5. Copy the token (keep it secure!) |
| 16 | + |
| 17 | +> 📋 **Note**: You only need a free Figma account - no Dev Mode subscription required! |
| 18 | +
|
| 19 | +### 2. Configure MCP in Cursor |
| 20 | + |
| 21 | +1. Open Cursor |
| 22 | +2. Press `Cmd + Shift + P` (or `Ctrl + Shift + P` on Windows) |
| 23 | +3. Type "Open MCP Settings" and select it |
| 24 | +4. Click "Add new MCP" |
| 25 | +5. Paste the configuration below: |
| 26 | + |
| 27 | +#### For macOS/Linux: |
| 28 | +```json |
| 29 | +{ |
| 30 | + "mcpServers": { |
| 31 | + "Figma Flutter MCP": { |
| 32 | + "command": "npx", |
| 33 | + "args": ["-y", "figma-flutter-mcp", "--figma-api-key=YOUR-API-KEY-HERE", "--stdio"] |
| 34 | + } |
| 35 | + } |
| 36 | +} |
| 37 | +``` |
| 38 | + |
| 39 | +#### For Windows: |
| 40 | +```json |
| 41 | +{ |
| 42 | + "mcpServers": { |
| 43 | + "Figma Flutter MCP": { |
| 44 | + "command": "cmd", |
| 45 | + "args": ["/c", "npx", "-y", "figma-flutter-mcp", "--figma-api-key=YOUR-API-KEY-HERE", "--stdio"] |
| 46 | + } |
| 47 | + } |
| 48 | +} |
| 49 | +``` |
| 50 | + |
| 51 | +**Important**: Replace `YOUR-API-KEY-HERE` with your actual Figma API key. |
| 52 | + |
| 53 | +### 3. Verify Setup |
| 54 | + |
| 55 | +1. Restart Cursor |
| 56 | +2. Open a new chat |
| 57 | +3. You should see "Figma Flutter MCP" in the available tools |
| 58 | +4. Test with: "Can you help me convert Figma designs to Flutter?" |
| 59 | + |
| 60 | +--- |
| 61 | + |
| 62 | +## 🎨 Setting Up Theme Colors |
| 63 | + |
| 64 | +The most efficient way to generate Flutter themes is to create a dedicated theme frame in Figma. |
| 65 | + |
| 66 | +### Create Your Theme Frame |
| 67 | + |
| 68 | +1. **In Figma**: Create a frame with your color palette |
| 69 | +2. **Organize colors** by purpose (primary, secondary, background, etc.) |
| 70 | +3. **Add labels** to identify each color's purpose |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | +### Get the Figma Link |
| 75 | + |
| 76 | +**Figma Desktop**: |
| 77 | +- Select your theme frame |
| 78 | +- Press `Cmd + L` (or `Ctrl + L`) |
| 79 | + |
| 80 | +**Figma Web**: |
| 81 | +- Select your theme frame |
| 82 | +- Copy the URL from your browser |
| 83 | + |
| 84 | +### Generate Flutter Theme |
| 85 | + |
| 86 | +Use this prompt in Cursor: |
| 87 | + |
| 88 | +``` |
| 89 | +Setup Flutter theme from <figma_link> including all colors. |
| 90 | +Create a comprehensive ColorScheme and ThemeData that follows Material Design 3 principles. |
| 91 | +Organize the colors by their semantic meaning (primary, secondary, surface, etc.). |
| 92 | +``` |
| 93 | + |
| 94 | +**Example Result**: You'll get a complete Flutter theme with: |
| 95 | +- `ColorScheme` with proper semantic color assignments |
| 96 | +- `ThemeData` configuration |
| 97 | +- Custom color extensions if needed |
| 98 | +- Usage examples for each color |
| 99 | + |
| 100 | +--- |
| 101 | + |
| 102 | +## ✍️ Setting Up Typography |
| 103 | + |
| 104 | +Create a typography system that matches your design language. |
| 105 | + |
| 106 | +### Create Your Typography Frame |
| 107 | + |
| 108 | +1. **In Figma**: Create a frame with text samples |
| 109 | +2. **Include different styles**: Headlines, body text, captions, etc. |
| 110 | +3. **Show hierarchy**: H1, H2, H3, body, small text |
| 111 | +4. **Add style names** for clarity |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | +### Get the Figma Link |
| 116 | + |
| 117 | +Same process as theme colors - select the frame and copy the link. |
| 118 | + |
| 119 | +### Generate Flutter Typography |
| 120 | + |
| 121 | +Use this prompt in Cursor: |
| 122 | + |
| 123 | +``` |
| 124 | +Setup Flutter typography theme from <figma_link>. |
| 125 | +Create a complete TextTheme with all the text styles shown. |
| 126 | +Include font weights, sizes, and letter spacing that match the design. |
| 127 | +Provide usage examples for each text style. |
| 128 | +``` |
| 129 | + |
| 130 | +**Example Result**: You'll get: |
| 131 | +- Complete `TextTheme` configuration |
| 132 | +- Proper Material Design text style assignments |
| 133 | +- Custom text styles if your design uses unique typography |
| 134 | +- Code examples showing how to use each style |
| 135 | + |
| 136 | +--- |
| 137 | + |
| 138 | +## 🧩 Single Widget Creation |
| 139 | + |
| 140 | +Convert individual Figma components into reusable Flutter widgets. |
| 141 | + |
| 142 | +### Best Practices for Widget Design |
| 143 | + |
| 144 | +1. **Use Figma Components** when possible (creates variants automatically) |
| 145 | +2. **Name your components** descriptively |
| 146 | +3. **Create variants** for different states (enabled/disabled, light/dark) |
| 147 | +4. **Include all interactive states** |
| 148 | + |
| 149 | + |
| 150 | + |
| 151 | +### Get the Component Link |
| 152 | + |
| 153 | +**For Components**: |
| 154 | +- Select the component or component set |
| 155 | +- Copy the link (`Cmd + L` or `Ctrl + L`) |
| 156 | + |
| 157 | +**For Frames** (if you don't have components): |
| 158 | +- Select any frame you want to convert to a widget |
| 159 | +- Copy the link |
| 160 | + |
| 161 | +### Generate Flutter Widget |
| 162 | + |
| 163 | +Use this prompt in Cursor: |
| 164 | + |
| 165 | +``` |
| 166 | +Create this widget in Flutter from <figma_link>. |
| 167 | +Include 2-3 main variants and break the code into smaller, readable files. |
| 168 | +Make it a reusable component with proper state management. |
| 169 | +Include documentation and usage examples. |
| 170 | +``` |
| 171 | + |
| 172 | +**Example Result**: You'll get: |
| 173 | +- Main widget file with clean, readable code |
| 174 | +- Separate files for complex sub-components |
| 175 | +- Proper state management (StatefulWidget if needed) |
| 176 | +- Variant handling (different styles/states) |
| 177 | +- Documentation and usage examples |
| 178 | +- Proper Flutter best practices |
| 179 | + |
| 180 | +### Advanced Widget Prompts |
| 181 | + |
| 182 | +**For Complex Components**: |
| 183 | +``` |
| 184 | +Analyze this complex component from <figma_link>. |
| 185 | +Break it down into smaller sub-widgets for better maintainability. |
| 186 | +Include proper state management and animation support where appropriate. |
| 187 | +``` |
| 188 | + |
| 189 | +**For Component Sets with Many Variants**: |
| 190 | +``` |
| 191 | +Create this component set from <figma_link> with all variants. |
| 192 | +Use enums for variant selection and ensure type safety. |
| 193 | +Optimize for performance and reusability. |
| 194 | +``` |
| 195 | + |
| 196 | +--- |
| 197 | + |
| 198 | +## 📱 Full Screen Generation |
| 199 | + |
| 200 | +Convert entire Figma screens into complete Flutter screens with proper structure. |
| 201 | + |
| 202 | +### Prepare Your Screen Design |
| 203 | + |
| 204 | +1. **Use Frames** for full screens |
| 205 | +2. **Include navigation elements** (app bars, bottom navigation) |
| 206 | +3. **Add realistic content** (not just placeholder text) |
| 207 | +4. **Consider responsive design** for different screen sizes |
| 208 | + |
| 209 | +### Get the Screen Link |
| 210 | + |
| 211 | +- Select the main screen frame |
| 212 | +- Copy the Figma link |
| 213 | + |
| 214 | +### Generate Flutter Screen |
| 215 | + |
| 216 | +Use this prompt in Cursor: |
| 217 | + |
| 218 | +``` |
| 219 | +Create a complete Flutter screen from this Figma design: <figma_link> |
| 220 | +Ensure the code is well-organized with smaller, readable files. |
| 221 | +Include proper navigation structure and responsive design. |
| 222 | +Export any image assets automatically. |
| 223 | +``` |
| 224 | + |
| 225 | +**Example Result**: You'll get: |
| 226 | +- Main screen file with `Scaffold` structure |
| 227 | +- Separate widget files for complex sections |
| 228 | +- Proper navigation setup (AppBar, BottomNavigationBar, etc.) |
| 229 | +- Responsive design considerations |
| 230 | +- Automatic image asset export to `assets/` folder |
| 231 | +- Updated `pubspec.yaml` with asset references |
| 232 | +- Clean, maintainable code structure |
| 233 | + |
| 234 | +### Advanced Screen Prompts |
| 235 | + |
| 236 | +**For Complex Layouts**: |
| 237 | +``` |
| 238 | +Analyze this complex screen layout from <figma_link>. |
| 239 | +Create a responsive design that works on both mobile and tablet. |
| 240 | +Use proper Flutter layout widgets and ensure good performance. |
| 241 | +``` |
| 242 | + |
| 243 | +**For Screens with Navigation**: |
| 244 | +``` |
| 245 | +Create this screen from <figma_link> with proper navigation integration. |
| 246 | +Include route definitions and navigation logic. |
| 247 | +Ensure it fits well within a larger app structure. |
| 248 | +``` |
| 249 | + |
| 250 | +**For Data-Driven Screens**: |
| 251 | +``` |
| 252 | +Convert this screen from <figma_link> into a Flutter screen. |
| 253 | +Make it data-driven with proper model classes and state management. |
| 254 | +Include loading states and error handling. |
| 255 | +``` |
| 256 | + |
| 257 | +--- |
| 258 | + |
| 259 | +## 💡 Pro Tips for Better Results |
| 260 | + |
| 261 | +### 1. **Be Specific in Your Prompts** |
| 262 | + |
| 263 | +❌ **Vague**: "Convert this Figma design" |
| 264 | +✅ **Specific**: "Create a reusable login form widget from this Figma component with validation states" |
| 265 | + |
| 266 | +### 2. **Mention Your Requirements** |
| 267 | + |
| 268 | +- Target platform (mobile, web, desktop) |
| 269 | +- State management preference (Provider, Riverpod, Bloc) |
| 270 | +- Design system (Material 3, Cupertino, custom) |
| 271 | +- Performance considerations |
| 272 | + |
| 273 | +### 3. **Iterative Refinement** |
| 274 | + |
| 275 | +Start with basic conversion, then refine: |
| 276 | +``` |
| 277 | +1. "Convert this basic button from <figma_link>" |
| 278 | +2. "Add animation and haptic feedback to the button" |
| 279 | +3. "Make it accessible with proper semantics" |
| 280 | +``` |
| 281 | + |
| 282 | +### 4. **Asset Management** |
| 283 | + |
| 284 | +- **Images**: Automatically exported with screen generation |
| 285 | +- **SVGs**: Export separately using: `"Export this as SVG asset from <figma_link>"` |
| 286 | +- **Icons**: Consider using Flutter's built-in icons or icon fonts |
| 287 | + |
| 288 | +### 5. **Code Organization** |
| 289 | + |
| 290 | +Always request: |
| 291 | +- Separate files for complex components |
| 292 | +- Proper folder structure |
| 293 | +- Clear naming conventions |
| 294 | +- Documentation and comments |
| 295 | + |
| 296 | +--- |
| 297 | + |
| 298 | +## 🔧 Troubleshooting |
| 299 | + |
| 300 | +### Common Issues |
| 301 | + |
| 302 | +**"MCP Server Not Found"** |
| 303 | +- Restart Cursor after adding MCP configuration |
| 304 | +- Check that your API key is correct |
| 305 | +- Ensure you have internet connection for `npx` to download the package |
| 306 | + |
| 307 | +**"Figma API Error"** |
| 308 | +- Verify your API key is valid |
| 309 | +- Check that the Figma file is accessible with your account |
| 310 | +- Ensure the Figma link contains both file ID and node ID |
| 311 | + |
| 312 | +**"Rate Limiting"** |
| 313 | +- Wait a few minutes between large requests |
| 314 | +- Analyze one component/screen at a time |
| 315 | +- Avoid rapid-fire requests |
| 316 | + |
| 317 | +### Getting Help |
| 318 | + |
| 319 | +1. **Check the [Issues](https://github.com/mhmzdev/figma-flutter-mcp/issues)** on GitHub |
| 320 | +2. **Read the detailed [documentation](figma-flutter-mcp.md)** |
| 321 | +3. **Join the community** discussions |
| 322 | +4. **Report bugs** with specific examples |
| 323 | + |
| 324 | +--- |
| 325 | + |
| 326 | +## 🎯 Next Steps |
| 327 | + |
| 328 | +Now that you're set up, try these workflows: |
| 329 | + |
| 330 | +1. **Start with Theme**: Set up your app's color scheme and typography |
| 331 | +2. **Create Components**: Build a library of reusable widgets |
| 332 | +3. **Build Screens**: Convert full designs into complete Flutter screens |
| 333 | +4. **Iterate and Refine**: Use AI to improve and optimize your code |
| 334 | + |
| 335 | +Remember: The better your Figma designs are organized and the more specific your prompts are, the better results you'll get! |
| 336 | + |
| 337 | +--- |
| 338 | + |
| 339 | +**Happy coding! 🚀** |
| 340 | + |
| 341 | +*Built with ❤️ for designers and developers who want to bridge the gap between design and code.* |
0 commit comments