figma_string_extension 0.5.0 copy "figma_string_extension: ^0.5.0" to clipboard
figma_string_extension: ^0.5.0 copied to clipboard

Convert Figma String to Flutter Widget

example/main.dart

import 'package:figma_string_extension/figma_string_extension.dart';
import 'package:flutter/material.dart';

main() {
  FigmaStringConfig.insertResolver(
      // if you have custom color
      colorResolvers: [
        ColorResolverPart((p) {
          switch (p) {
            case 'Card Color':
              return const Color(0xffFFF0FE);
            default:
              throw 'unknown color [$p]';
          }
        })
      ],
      // if you have custom textStyle
      textStyleResolvers: [
        TextStyleResolverPart(
          (p) {
            switch (p) {
              case 'Card Text':
                return const TextStyle(
                  fontSize: 16,
                  fontWeight: FontWeight.w500,
                );
              default:
                throw 'unknown textStyle [$p]';
            }
          },
        )
      ]);

  runApp(MaterialApp(
    home: Scaffold(
      body: Center(
        child: Column(
          children: [
            Container(
              width: 100,
              height: 50,

              /// custom color
              color: 'Card Color'.asColor,
            ),
            Container(
              width: 50,
              height: 50,
              decoration: BoxDecoration(
                /// figma hex color
                color: '#D8F0FEF1'.asColor,
                /// figma box-shadow
                boxShadow:
                    'box-shadow: 0px 3px 3px 0px #0000001F;'.asBoxShadows,
              ),
              child: Text(
                "hello",

                /// custom text style
                style: 'Card Text'.asTextStyle,
              ),
            ),
          ],
        ),
      ),
    ),
  ));
}
0
likes
110
points
172
downloads

Publisher

verified publisherwyattcoder.top

Weekly Downloads

Convert Figma String to Flutter Widget

Repository (GitHub)

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

collection, flutter, get_it

More

Packages that depend on figma_string_extension