flutter2figma 0.4.2
flutter2figma: ^0.4.2 copied to clipboard
(Beta) Convert an existing Flutter UI into an editable Figma design: auto-layout frames or an exact runtime capture, text styles, color variables with light/dark modes, and components.
0.4.2 #
Fixes #
- Color variables and text styles take the theme Flutter rendered with,
when the screens ran: an app whose theme the code alone can't find (a
MaterialAppbuilt inside aBlocBuilder) got Material's default purple variables, so bound text and icons showed purple in Figma. Without a theme in the code, only the mode Flutter rendered is exported. - Vectors without a stroke no longer keep the 1 px black outline Figma gives new vectors (painter shapes, glass borders).
- Fonts bundled under a compact name (
EncodeSansCondensed) use Figma's spelling of the same font ("Encode Sans Condensed") instead of a substitute.
0.4.1 #
Figma plugin #
- The plugin's window shows its version, and so does the import notification, so several installed copies can be told apart.
- "Update the plugin" messages point to Figma Community first, with the GitHub release as the fallback.
Export #
- The end-of-export summary says which plugin version the file needs.
0.4.0 #
flutter2figma export now runs the app by default (runtime mode) and
writes preview.html. It used to only read the code, which leaves
placeholders wherever the app decides things at runtime. For the old
behavior, use --static (for example on CI machines without Flutter).
Export #
- In a Flutter app, plain
flutter2figmaruns the export (export options work too:flutter2figma --static). - The export ends with a summary: how many screens Flutter rendered, which ones came from the code alone and why, how to fix them, and the next steps (check the preview, import in Figma, where to get the plugin).
- Runtime mode falls back to static instead of failing when Flutter isn't installed or the project isn't a resolved Flutter app.
--[no-]previewis on by default.
Figma plugin #
- After an import, the plugin names the screens exported from the code alone, which may show placeholders, and how to export them exactly.
- Importing a
design.jsonfrom a newer flutter2figma says so and links to the latest plugin; the import still goes ahead. The plugin stays offline: it compares its version with the one that wrote the file. - Each release opens a "Publish X.Y.Z to Figma Community" issue with the steps and the version note, since Figma has no publishing API.
0.3.0 #
design.json is now version 4 (rotation, vector strokes and image fills,
background blurs): update the Figma plugin to import it.
Preview #
export --previewwritespreview.html: every screen drawn fromdesign.jsonin the browser beside Flutter's own render (with--runtime), a wipe slider between them, and layer outlines by kind (vector, text, image). The app's fonts are embedded.
Export #
- Radial and sweep gradients on frames that fill or hug kept the shape of a 1 px box in Figma (the angle of a sweep was wrong); they now use the size they were painted at.
--no-auto-layoutkeeps runtime screens absolutely positioned.
Runtime mode #
- Custom painters export as vectors: rects, rounded rects, circles, ovals, arcs, lines and paths, with their fills and strokes, in paint order. A gradient fills its shape as an image; blurs, shadows, blend modes and text are drawn alone as images where they paint, and text keeps its rotation.
Transform.rotateis kept: rotated widgets keep their own size and turn in Figma, instead of an unrotated bounding box.SweepGradientbecomes a Figma angular gradient, andBackdropFilterblurs become background blurs.- Apps with plugins start in more cases: every Pigeon plugin call gets an
empty answer, and Firebase (core and Remote Config),
package_info_plusandpath_providerget fakes. Assets the pubspec lists but that are missing (a gitignored.env) are stood in for during the run, with the keys the app reads fromdotenv. - Shadows render as shadows (tests draw them as black outlines), and text with no font family uses Roboto instead of the test font's boxes.
0.2.0 #
flutter2figma is now labeled beta.
Runtime mode #
flutter2figma export --runtime(andexportProject(runtime: true)) renders each screen with Flutter in aflutter testand exports exactly what it draws: Flutter's positions, text with its real styles, icons as vectors, images, and anything custom-painted as images. Colors and text styles are bound to the theme's variables and styles.- The app starts through its own
main(). Route-level providers are carried to every screen, wrapper classes are used, simple required constructor arguments get placeholders, andshared_preferences/flutter_secure_storageget in-memory fakes.test/flutter2figma_setup.dartcan addsetUp,wrapScreenandbuildScreen. - Screens that can't run fall back to static export, with the reason.
- Children are recorded in the order they are painted, and what a widget paints itself is split into what goes under and over its children, so backgrounds, outlines and borders stack as in the app.
- Layout overflows in the app are reported with their
file:line(the screen is still exported). --screenshots <dir>saves Flutter's own render of every screen, to compare with the Figma import.
Export #
- Tap targets: buttons, icon buttons, switches, checkboxes and radios take the
48 px space Flutter lays them out in (
MaterialTapTargetSize.padded), so the layout around them matches the app. Buttons sit in aTap targetframe;materialTapTargetSizein the theme andtapTargetSizein a button's style are honored. - Icons are exact vectors:
Icons.*glyphs are read from the Material icons font of the project's Flutter SDK, andCupertinoIconsfrom thecupertino_iconspackage, placed where Flutter draws them and colored by the theme's icon color variable. Icons from other fonts stay placeholders. - Asset images are embedded:
Image.asset,Image(image: AssetImage(...)),DecorationImageandSvgPicture.asset(flutter_svg). The highest resolution variant (2.0x/,3.0x/) is used at its logical size,fitmaps to Figma's scale modes, and images over Figma's 4096 px limit are scaled down (other formats such as WebP become PNG). Network, file and memory images stay placeholders. ListTile,SwitchListTile,CheckboxListTileandRadioListTile: Material 3 padding, heights (one, two and three lines, dense), leading slot, text styles and selected/disabled colors.- Chips (
Chip,InputChip,FilterChip,ChoiceChip,ActionChip, elevated variants): outline or tonal fill, avatar, checkmark when selected, delete icon, tap target. NavigationBarandBottomNavigationBarinScaffold.bottomNavigationBar: the body fills the space above the bar and a floating action button sits above it.Wrapwraps (Figma auto layout wrap) instead of exporting as a row.- Gradients:
LinearGradientandRadialGradientbecome Figma gradient fills (colors, stops, direction, center and radius) in both modes, instead of their first color. CircleAvatar(color, child, background image).- A frame downgraded from fill to hug no longer leaves filling children
inside it, which Figma rejected; a decorated
Containerwith a margin grows with a filling child, as in Flutter. a ?? bis evaluated: a knownadecides, and anaonly known at runtime is assumed null as on the first frame, so the fallback shows (Text(icon ?? '')on an empty board) instead of{icon ?? ''}.- Fields of project enum constants and other project values passed
positionally are readable:
DrawnElement.cross.icongives❌. - New dependency:
image, to scale and convert images. design.jsonversion 3 (addsVECTORnodes,imagesand image paints) and IR version 3. Update the Figma plugin to import them.
Tests #
showcase/, a dense multi-screen app, andtool/stress.sh, which exports it both ways and imports both through the Figma mock. CI exports it too.- The example app measures real Flutter layout sizes
(
test/goldens/basic_layout.json), and the plugin test checks Figma produces the same ones.
0.1.0 #
First release.
Export #
flutter2figma exportturns a Flutter project intodesign.json(for the Figma plugin) andir.json(the intermediate representation).- Static analysis only: the app is never run. Screens are found through
wrappers such as providers,
BlocBuilder,PopScopeand auth gates. - Auto layout that follows Flutter's constraints (fixed / hug / fill).
Wrappers like
Paddingfold into frame padding, andSizedBoxspacers into gaps, but only when the result renders the same. - Layout, content, Material controls and surfaces,
TextField, and progress indicators. Widgets from packages andbuilder:widgets render their content. Anything unsupported becomes a flagged placeholder. - Runtime-dependent UI exports the initial state where it can be known, and
reports what it assumed:
- bloc/cubit builders see the bloc's initial state;
- constructor defaults are filled in, including freezed
@Default; - conditions on known values are folded;
- other conditionals keep the richer branch;
- loops over literal lists are unrolled, and loops over runtime data show sample items.
GridView,Switch,CheckboxandRadio, drawn with Material 3 defaults.
Theme #
- Reads the app's
MaterialApptheme,darkThemeandthemeMode, and resolves them the way Flutter does:- color schemes, including
ColorScheme.fromSeed; fontFamily,textThemeand GoogleFonts;- app bar, card and button themes;
- nested
Themewidgets.
- color schemes, including
- Checked against Flutter's own resolved theme on real apps (exact match).
flutter2figma themeprints the resolved theme as JSON.
Design system #
ColorSchemeroles become color variables with Light and Dark modes. Painted project color constants become variables too.- Text theme entries become text styles, and elevation levels become effect styles. Values bind to these only when they came from them.
- Material buttons become a
Buttoncomponent set. Project widgets used twice or more become components with instances.
Figma plugin #
- Imports
design.json(format version 2, documented indoc/design-json.md). It creates or updates the variable collection, variables and styles by name, builds components from first occurrences, binds paints to variables, and sets each screen's mode. - Has no network access.
- Released as
flutter2figma-figma-plugin-<version>.zipon GitHub Releases.
API #
package:flutter2figma/flutter2figma.dartprovidesexportProject(). The stages are separate libraries:analyzer.dart,compiler.dart,ir.dartandfigma.dart.