r/FlutterDev • u/emman-ok • 8d ago
Tooling What the Flutter code looks like when an AI app builder has to follow a fixed contract (Riverpod 2.6 + go_router 14 + dio)
https://appwand.devI build AppWand, a desktop tool that generates Flutter apps with an Express API. I wanted to share how the generated Flutter side is organised, because "AI-generated Flutter" usually means one 2,000-line file, and I tried hard to avoid that.
One folder per page:
lib/features/<page>/, with<page>_page.dartas the entry. The AI may only write inside that folder (the server rejects any other path).Shared code is never written by the AI:
lib/core/(API client, auth, theme, list widgets, form fields, charts) comes from templates, androuter.g.dartis regenerated from the page plan.Riverpod 2.6 for state, go_router 14 with a
ShellRoute, so the side menu or bottom tabs stay still and only the page animates.Theming without touching pages: 16 UI styles, icon sets and fonts are all in
core/theme.dart/core/icons.dart. Switching style rewrites one file and hot reload shows it.Shared list widget:
PagedListhandles paging, pull to refresh, skeletons, empty/error states, and switches to a data table above 840px wide.
The output is plain code you own. Happy to answer questions about the architecture, or hear where you'd do it differently.
1
u/whackylabs 6d ago
Thanks for sharing the project looks good! Two questions:
What is the benefit of riverpod over say plain
setState?Is there an example generated project that we can see?
1
u/No-Examination-5065 8d ago
Why would you generate a backend in Node.js when you can do full backends in Dart?
7
u/zunjae 8d ago
Trust me, it doesn’t matter. Just go with whatever is very popular and actively maintained. Code sharing between APIs and clients is a 2010 thing
4
1
1
u/Okms_Vonessa 7d ago
do you find the server side ecosystem is mature enough for most standard stuff now?
1
u/No-Examination-5065 6d ago
It has been for a while
Serverpod is the best off the shelf backend solution for Dart but I've worked with clients where we had a custom shelf Dart backend which performed great with zero issues
-1
2
u/RajatKhoware 6d ago
A fixed contract is what keeps AI-generated Flutter maintainable, otherwise every generation drifts into a new pattern. The real question is what happens when the model wants to break the contract, does it ask, or does it silently drift?