Site icon Flutter Packages | Pub dev Packages – Flutter Mobile App World

From design to responsive pages and apps on Tailwind and Flutter

Figma to Code

Figma to Code

Most design to code plugins are bad, some are even paid. This project aims to raise the bar by generating responsivelayouts in Tailwind and Flutter. The plan is to eventually add support for Jetpack Compose and possibly standard HTML or other frameworks like React NativeSwiftUIBootstrap or Fluent. Feedback, ideas and partnerships are appreciated!

How it works

This plugin takes an unconventional approach to improve code quality: it optimizes the layout before the conversion to code even begins. The standard Figma Nodes (what represents each layer) is a joy to work with, but it can’t modify a layer without modifying the user project. For this reason, I decided to virtualize it, remaking the official implementation and naming them AltNodes. During the process of converting a Node into an AltNode, the plugin does the following:

That process can also be seen as an Intermediate Representation and might allow this plugin to, one day, live outside Figma.

Hard cases

When finding the unknown (a Group or Frame with more than one child and no vertical or horizontal alignment), Tailwind mode uses insets for best cases and lefttop from standard CSS for the worst cases. Flutter mode uses Stack and Positioned.fill. Both are usually not recommended and can easily defeat the responsiveness. In many scenarios, just wrapping some elements in a Group or Frame can solve:

Tip: Instead of selecting the whole page, you can also select individual items. This can be useful for both debugging and componentization. For example: you can use the plugin to generate the code of a single element and then replicate it using a for-loop.

Todo

Tailwind limitations

Flutter limits and ideas

How to build the project

The project is configured to be built with Webpack or Rollup. The author couldn’t find a way to correctly configure Svelte in Webpack, so Rollup was added. But Rollup is a lot less stable than Webpack and crashes regularly in watch mode when editing Typescript files. So, if you are going to work with Typescript only, I reccommend sticking with Webpack. If you are going to make changes in the UI, you need to use Rollup for now.

Issues

The Figma file for this README and icon is also open and welcome to changes! Check it here.

I took decisions thinking about how it would benefit the majority of people, but I can (and probably will!) be wrong many times. Found a bug? Have an idea for an improvement? Feel free to add an issue or email me. Pull requests are also more than welcome.

Download Figma to Code plugin source code on GitHub

https://github.com/bernaferrari/FigmaToCode

Exit mobile version