Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A modifier works like 'rich' in pure dart #215

Open
andyzhshg opened this issue Apr 12, 2024 · 0 comments
Open

A modifier works like 'rich' in pure dart #215

andyzhshg opened this issue Apr 12, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@andyzhshg
Copy link

Motivation

I'm working on a CLI tool that will generate some text files with style, much like generating HTML. When translating some fields using slang, I also hope to specify some sort of style on this field. It's very similar to how the rich modifier works in slang.

However, as the rich modifier relies on TextSpan, which is not available in pure Dart, I'm stuck here.

What I hope for is something like this, a class similar to TextSpan:

class CustomStyledSpan {
  CustomStyledSpan({this.text, this.style, this.children});
  final String? text;
  final Object? style;
  final List<CustomStyledSpan>? children;
}

and the builder can generate something like this:

mixin GeneratedClass {
  CustomStyledSpan? text({required CustomStyledSpan field});
}

Developer Experience

I think this feature would add more flexibility when using slang with pure Dart.

I'm looking into how to implement this feature myself and would really appreciate any guidance or advice anyone can provide.

@andyzhshg andyzhshg added the enhancement New feature or request label Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant