I was recently forced to re-evaluate AI tools (my weapon of choice, Sourcegraph Cody, is being discontinued[1]). I used Anthropic Claude Sonnet 3.7 with good success so far. The last time I compared, Sonnet 3.7 wrote the best Dart code with the least amount of hand-holding from me.
I defaulted back to Chat GPT (I have it for free because I have a GitHub subscription).
Earlier today, I asked ChatGPT 4o this question:
Is there a Flutter widget that limits the child’s size only if it isn’t already limited?
I genuinely couldn’t remember the name, and thought this would be faster than trying to find it. To my surprise, ChatGPT claimed I’d have to build my own using LayoutBuilder.
So I went ahead and tried other LLMs. To my continuing surprise, none knew about LimitedBox except for Gemini 2.5 Pro (preview).
Yes, this is a stupid way of comparing LLMs — it’s quite possible that LimitedBox is just a fluke, and Gemini 2.5 Pro is worse in other areas of Dart & Flutter development. Nevertheless, I think I’m going to give it a chance for now.
If y’all have more comprehensive tests or even “feels” about LLMs’ proficiency in Flutter and Dart, please share!
And its replacement, whose name I already forgot, doesn’t work in IntelliJ. ↩︎
Yes! Well, it will definitely help with something like the issue above, but maybe not generally? For example, I don’t think MCP can effectively inform every minute decision the LLM uses. So if the LLM hasn’t been trained on much high quality Dart code it will produce low quality code regardless of MCP.
That said: is there already some MCP solution for dart and Flutter? Ignore me, I see you’ve linked to a search.
That’s the problem with Flutter. (My guess is LimitedBox is used very less in the codebase used to train the model.)
There should be some support link to report these issues. As far as i know, claude 4 works best for Flutter, followed by gemini 2.5 pro.
I would suggest to give the above MCP a try. Haven’t tested much.
Keep us updated with your findings!!
Edit:
I use the combination of Ask and Agent mode in Github Copilot
Ask - Claude 3.7 thinking - Let it plan the task
Agent - Claude 4 - To apply the changes to code
This combo works better than using only agent mode.
Also try, Roo code VSCode extension. It’s faster than copilot.
Edit 2:
Also, create a good copilot-instruction file or rules file. This prevents the hallucination issue i faced
Ok, so I’m not sure if this was it or not, but I just added context7 MCP (as suggested by @Harish above) and now Claude 3.7 Sonnet gives a much better answer to the exact same query:
I’ll help you find a Flutter widget that limits a child’s size only if it isn’t already limited.
Yes, Flutter does have a widget that serves this exact purpose! It’s called LimitedBox. This widget only imposes size constraints on its child when the incoming constraints are unbounded.
Here’s how it works:
If the parent widget provides unconstrained dimensions (infinite width/height), the LimitedBox will limit the child to the specified maximum width and/or height.
If the parent already provides constraints, the LimitedBox does nothing and simply passes those constraints through.
Inside scrollable areas (like ListView) where the main axis is unconstrained
Inside Row or Column widgets where the cross axis might be unconstrained
Any scenario where you want to provide a size limit as a fallback only when needed
The LimitedBox is perfect for cases where you want to avoid overriding explicit constraints from parent widgets while still ensuring your child has reasonable dimensions when no constraints are provided.
Clause 3.7 is also much faster to reply than Gemini, so I’ll probably use that instead, and will hope the code quality isn’t that far off.
And MCP was much easier to set up than I initially thought. In IntelliJ, it’s copy-pasting a JSON config.
It seems that the current MCP I’m using (context7) simply gathers various examples of Flutter code. So it’s not even that complicated of a solution.
Maybe this is because there aren’t many “good quality” open source dart programs. It’s a bit sad that aren’t many big open source dart/flutter programs.
Also these LLM’s don’t have categorized knowledge. I often see answers where it’s obvious that it wants to write dart like it was javascript or something else.
I have an MCP using Jhin’s Dart MCP package that searches the live pub.dev providing everything the search API provides. I need to clean it up and document it a bit better, but I’m already using it for other coding.
Using contents of this forum for the purposes of training proprietary AI models is forbidden. Only if your AI model is free & open source, go ahead and scrape. Flutter and the related logo are trademarks of Google LLC. We are not endorsed by or affiliated with Google LLC.