-
Notifications
You must be signed in to change notification settings - Fork 26
Description
I'm exploring the use of supernova exporters in my company's project to generate design tokens in our flutter app. I'm currently running into an issue i was hoping i could get help with. When i'm using the flutter tokens exporter, it generates some code for me, but if those tokens don't exist, I get code that fails the lint check step of our build pipelines.
import 'package:flutter/material.dart';
class AppGradients {
AppGradients._();
}
`Unused import: 'package:flutter/material.dart'.
I've cloned the repository and i've made some changes to the exporter code but i'm still having one problem.
{[ let brand = ds.currentBrand() /]}
{[ const borderTokensTree = ds.tokenGroupTreeByType("Border", brand.id) /]}
{[ let bordersExist = false /]}
{[ traverse borderTokensTree property subgroups into borderTokenGroup ]}
{[ const borderTokenInGroups = ds.tokensByGroupId(borderTokenGroup.id) /]}
{[ if (borderTokenInGroups.length > 0) ]}
{[ bordersExist = true /]}
{[/]}
{[/]}
{[ if bordersExist ]}
import 'package:flutter/material.dart';
<! ----I want a new line here--->
{[/]}
This results in this code when a token exists:
import 'package:flutter/material.dart';
class AppGradients {
static const blue500Gradient = LinearGradient(
begin: Alignment(0, -1),
...
The problem now is that i'm failing dart format because i need the new line after the import code.
I'm struggling to find any documentation on how to use the templating code.
Is there an easy way to insert a new line after the import statement conditionally based on whether or not the token exists?