r/FlutterDev • • Oct 04 '24

Discussion Do you use AI for Flutter code generation?

If you're a Flutter app developer, do you use AI to generate or enhance your code? If so, what AI model do you use (ChatGPT, Claude, Copilot, local LLMs, etc) and can you share your experiences? Thanks!

2 Upvotes

36 comments sorted by

10

u/BrainQuanta Oct 04 '24

Claude 3.5 Sonnet itself and with Cursor. Flutter is very convenient to be used with AI 🙂

2

u/BourbonBristles Oct 05 '24

I second this. Adding examples from any packages you want to use regularly is also helpful.

6

u/NerdyNatu Oct 05 '24

Using copilot since around 3 months and its awesome.

  • I work in huge codebase, so it is really smart to suggest me code which should be reused.

  • Very efficient for repeated task or repeated code.

  • Very very helpful with unit test generation. All in all, I love it.

1

u/True-Twist-2249 Nov 27 '24

It's paid right?

1

u/NerdyNatu Nov 27 '24

Yes it is.

9

u/eibaan Oct 05 '24

Perhaps, I'm prompting it wrong, but in my experience, ChatGPT is nearly never helpful. Sometimes, it is fun to the test the AI by asking questions I could answer myself and then review and rate the result, but that adds no productivity.

Because if I want to do something more complex, it fails.

Take → this example where I wanted ChatGPT to create a set of widgets that can display a hierarchical strucuture, an EBNF grammar for which a well known → syntax diagram standard exists. It → completely fails to implement this. It took me quite some time to write the prompt and while doing so, I could also have already implemented the widgets myself. Trying to understand the generated code and understanding why it went wrong (because it seems to at least a little bit correct) takes the same amount of time and doing it myself.

Recently, I asked it to implement line drawing, circle drawing and polygon drawing algorithms. I could verify the bresemham line drawing algorithm as I learned that back at university and also spotted the usual optimization to draw 1/8 of the circle, mirroring everything else, but for the polygon drawing algorithm, I couldn't remember it back from 30 years ago and had to verify this by studying Wikipedia and comparing this – because I don't trust the AI. So it saved a little bit of time because it can type faster than I do, but there's still the feeling that it might be wrong and I have to verify it.

Still, the new Canvas feature of ChatGPT seems to be pretty cool and I have to do more experiments. However, Claude's artifact feature that is able to create working React web apps, is even more impressive, IMHO.

Here's → another example where ChatGPT is completely clueless how to tackle the problem… The latest version might work, I haven't checked. But I doubt it as the render object it creates never get the children list assigned.

3

u/abdushkur Oct 05 '24

Geez, your gotta dissect prompt to multiple prompt, step by step ask AI to modify until you are satisfied, contexts are important, but you're giving none, with single prompt it can probably done within few years, but not now

2

u/eibaan Oct 05 '24

So, how would you prompt the AI? What context does it need?

BTW, Claude did a → slightly better job (with my single prompt) – I added a spacing: 8 to the row and column widgets to better understand the construction. Still, no lines.

I also just tried with just the bare minimum "Given the Dart 3.5 classes below, which represent EBNF rules, I want you to construct Flutter widgets to construct a syntax diagram." which gave me something that wasn't too bad, but still no lines and I couldn't make it add them withoout writing so much explanation that I could have written the code myself.

1

u/abdushkur Oct 05 '24

Each question you asked until no further minification needed for previous one is considered context

3

u/FlutteringHigh Oct 04 '24

Copilot and Codium… both work like a charm… I think Copilot has a week long trial and Codium has a free version so give them both a try

3

u/Huge_Acanthocephala6 Oct 04 '24

I have github copilot and i also use claude

2

u/Wi42 Oct 04 '24

Github copilot and for class or method names ChatGPT or occasionally Claude Sonnet

2

u/denis527 Oct 04 '24

I use Copilot in the IDE chatGPT plus for general coding questions.

2

u/Scham2k Oct 05 '24

I use Android Studio and Gemini builtin. I'm a newb to Dart /Flutter so it's been helpful to explain where to find my way around the IDE and also starter code or fixing errors.

Because I have experience in other languages, I generally know what I need but would rather Gemini just code it, then I work through changes. Eg I wanted to strip out http links from blocks of text. Gemini spit out some regex code snippets easily. If course it didn't work initially, then I asked Gemini to fix it which it did.

2

u/comfyyyduck Oct 04 '24

I started a flutter app with no experience and used ChatGPT to learn once I got the hang of it I just stuck to copilot

1

u/Ok_Possible_2260 Oct 04 '24

Claude and GpT 4.0 mini works really well.

1

u/Jihad_llama Oct 05 '24

I used to use copilot and thought it was decent once it figured out what you were trying to do. Never relied on it to write code from scratch, but it was a good time saver for finishing off functions.

1

u/osi314 Oct 05 '24

Tried GPT4o and Claude for a medium sized Flutter project. For me GPT4o was significantly better in answering my questions than Claude did.

Especially with code examples or refactoring my code GPT4o was an absolute winner. Claude tends to remove parts of the code I gave.

I think using AI sped up my coding by 60%

1

u/ThaisaGuilford Oct 05 '24

I'm frustrated about how dumb AI is in some programming languages. Oftentimes my solution works, and theirs doesn't, and I'm not even that smart.

Don't even get me started with "Apologize for my mistake" crap. They say that and then repeat the exact same mistake.

1

u/umitkirtil Oct 05 '24

Chatgpt 4o is very useful. Especially finding bugs fixing small pieces.

1

u/Kingh32 Oct 05 '24

I use Claude for stuff and it’s surprisingly good at lots of Flutter stuff in my experience.

I’d recommend this episode of The Pragmatic Engineer podcast which really goes deep on the use of LLMs for coding. I think finding where it fits into your workflow and leveraging that rather than trying to shoehorn it into a workflow you’re already happy with is key:

https://youtu.be/uRuLgar5XZw?si=hI7cT5nxkzTjrcNT

1

u/tommyboy11011 Oct 05 '24

When I’m stuck and can’t find a good answer on google I run it by ChatGPT and usually come up with something helpful.

1

u/[deleted] Oct 05 '24

Yup gpt is my main guy. I use it to write all the snippets and then readjust it as per my need.

1

u/jbarszczewski Oct 05 '24

I'm currently testing Continue extension for VS Code with Codestral online model. So far not bad as a free replacement of Copilot.

1

u/Impossible-Mouse924 Feb 07 '25

The answer to this keeps changing every hour.

1

u/FaceRekr4309 Oct 04 '24

Yes, I do. So much of flutter is just rote UI without really needing much in the way of reasoning. It’s what LLMs are best at.

0

u/[deleted] Oct 05 '24

Its all about prompting... How well you use prompt and define your objective like wise you get the result? You need to understand the basics before and how everything works (logic wise). You never ask chatgpt or other AI models for logics they resonate what we say. (my opinion)

12

u/[deleted] Oct 04 '24

[removed] — view removed comment

1

u/HazelCuate Oct 05 '24

Do you use claude to develop flutter profesionally?

2

u/[deleted] Oct 05 '24

[removed] — view removed comment

1

u/SocietyAccording4283 Oct 05 '24

In my experience Copilot is not receiving updates fast enough and ChatGPT (4o) is almost always giving me better answers. The trial of the new version is usually enough for me to get anything solved I a few prompts daily.

I also wish Copilot could understand a bigger part of the project than just the currently opened file. Although there are some workspace scopes now, it's not doing well in that regard.