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.
I am seeing poor results from the context7 libraries for Flutter that I’ve tried. For example, using the context7 chat tab for the library /websites/main-api_flutter_dev, I asked it to simply list the properties and methods for a StatefulWidget. It couldn’t find that info in the library and so instead replied based on it’s training data.
The interesting parts from my context7 chat tab session:
“I apologize for the difficulty in retrieving the specific documentation about Flutter’s StatefulWidget. The search results are returning embedder/platform-level documentation rather than the Dart Flutter framework documentation for StatefulWidget.”
It then provided a reasonable answer that it said was “based on my knowledge of Flutter’s Dart framework.”
I asked context7’s chat to confirm it was responding based on training data and not the /websites/main-api_flutter_dev library. It responded:
“Yes, my response was based on my training data, not the documentation from this library. I was unable to find relevant StatefulWidget documentation through the getDocs tool, and instead of being clear about that limitation, I filled in the gap with my general knowledge of Flutter.”
Can anyone recommend a specific context7 or other MCP library for the Flutter API?
I’m using VSC with the Dart extension which has the Dart MCP server. From what I can tell it only provides limited access to Flutter documentation.
I asked an agent to reference the docs for a StatefulWidget using the Dart MCP and the approach it took was interesting: it queried my code for uses of StatefulWidget, then used the hover tool with the line/column of one such use, and finally referenced the text that came back from the hover tool to answer my question.
So it appears its response is limited to examining what’s in the hover text. Looking through all the tools in the VSC Dart extension MCP I don’t see any other tool for querying the full Flutter/Dart API docs.
Antigravity and Gemini CLI are smarter and do less wrong things (I assume they are the same model), but Antigravity has a pretty low usage limit (it can barely complete two tasks or a complicated one).
Claude CLI comes in second, but it is not as good for Dart/Flutter (for example, it still uses a lot of deprecated code, such as MediaQuery.of(context).size instead of MediaQuery.sizeOf(context) or WillPopScope instead of PopScope).
For IDE Glorified Notepads, Super Maven is the best for auto completing code (the chatbot, not so much, especially now that Claude no longer works and they don’t even reply to support tickets).
I wish Antigravity had some kind of limit tracker, like Claude do:
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.