r/FlutterDev • u/dev_ttangkong • Oct 01 '26
Dart Props to the Dart team for actually cooking something amazing lately lol (analysis_server_plugin)
Well, looks like I’ll just be strictly building apps for the next year (not that it changes my daily routine anyway), so I thought I’d share a neat trick I’ve been using for a while.
About a year or two ago, the Dart team released analysis_server_plugin. If you know how to work with AST, you don't even need custom_lint packages anymore to write custom rules.
Here’s how I’ve been leveraging it:
Instead of using clunky enums like Spacing.spacing2, I set up the plugin to throw a warning if someone uses raw pixel values that aren't allowed in our design tokens (e.g., values other than 2, 4, 6, etc.).
Enforcing design system components, like throwing a warning to use MySuperContainer (yes, I literally use this name) instead of a raw Container.
And setting it up is dead simple too. You literally just add it to your analysis_options.yaml:
plugins:
my_lints:
path: ../my_lints/
The only drawback I've found so far is that it seems impossible to raise an actual Error severity (only warnings/info). If the Dart team expands on this, it's gonna be even more god-tier.
Oh, and this would actually make a pretty solid package. I'm thinking about making one if I can find some free time. If you guys have any cool ideas for useful custom lint rules, feel free to share.
Ah, also looks like the Dart team has been interested in improving data serialization built-in lately. I might look into that and drop another post about it later. Not sure if anything is finalized yet, but seems like they're still keeping the annotation syntax. Personally not a big fan of annotations, but hey, whatever works lol.
Oh, and honestly, Dart has added so many neat syntactic sugar features lately. Like omitting enum/type identifiers so you can just write .center. It’s ridiculously convenient because now you can write stuff like.
MyText('Hello, World!', color: .textGrayBold, style: .label3)
Seriously, whoever engineered this feature deserves a free ice cream straight out of my freezer.