How to Build a Flutter App with Cursor AI (Complete Guide)
I remember the exact moment I realized app development had fundamentally changed. I was staring at a massive, tangled widget tree in Flutter, trying to figure out why my padding was overflowing on an iPhone SE but looked fine on a Pro Max. Normally, this meant diving into Stack Overflow, tweaking constraints, hot reloading, failing, and repeating.
Instead, I highlighted the code block in Cursor, pressed Cmd + K, and typed: "Fix the overflow issue on smaller screens and make this layout responsive."
Two seconds later, the code refactored itself. The overflow was gone. It felt like magic, but really, it was just the new baseline for writing code.
If you're reading this, you probably already know that Flutter is an incredible framework for building cross-platform apps. And you likely know that Cursor is the AI-first code editor everyone is talking about. But putting them together? That's where you get a massive multiplier on your productivity.
In this guide, we aren't just going to look at superficial features. We're going to walk through exactly how to build a Flutter app using Cursor AI from scratch. By the end, you'll know how to prompt effectively, debug instantly, and cut your development time in half.
Let's get into it.
Why Cursor for Flutter?#
You might be wondering, "Can't I just use VS Code with GitHub Copilot?"
You can. And for a long time, that's exactly what I did. But Cursor is fundamentally different because it isn't an extension bolted onto an editor; it's an editor built entirely around AI.
When you're building with Flutter, your codebase spans multiple files—state management in one folder, models in another, UI widgets in a third. If you ask a standard AI assistant to add a feature, it loses the thread because it doesn't understand your whole project.
Cursor's superpower is codebase-wide context. You can press Cmd + Enter and ask it to "Implement a dark mode toggle based on the theme file we already have," and it will know exactly which files to edit, without you having to manually copy-paste context back and forth.
Phase 1: The Setup (Getting your tools ready)#
Before we can build, we need our environment dialed in. I’ll keep this brief, assuming you have some basic programming knowledge.
1. Install Flutter#
If you haven't installed the Flutter SDK yet, head over to the official Flutter documentation and get it running on your machine. Run flutter doctor in your terminal to make sure everything is green.
2. Download Cursor#
Go to cursor.com and download the editor. Because Cursor is a fork of VS Code, it will automatically import all your VS Code extensions, keybindings, and settings. You won't have to relearn your workflow.
3. Essential Extensions#
Even though Cursor brings over your VS Code setup, make sure you have these installed:
- Flutter & Dart Extensions: Non-negotiable for syntax highlighting and hot reload.
- Error Lens: Makes it much easier to see exactly what line is throwing a Flutter error.
4. Configure Cursor's AI#
Open Cursor settings (usually the gear icon top right) and ensure you are using a top-tier model. For coding in Flutter, Claude 3.5 Sonnet is currently the undisputed champion. It understands Flutter's widget structures and state management patterns incredibly well.
Phase 2: Kicking Off the Project#
We're going to build a Personal Expense Tracker. It's complex enough to require state management and multiple screens, but simple enough to wrap your head around quickly.
Open Cursor, open a new terminal, and run:
flutter create expense_tracker
cd expense_tracker
Once the project is generated, open the expense_tracker folder in Cursor.
Normally, the next step would be manually deleting the counter app boilerplate in main.dart. Let's let Cursor do the heavy lifting instead.
Open main.dart, press Cmd + A to select all, then Cmd + K (the inline edit command). Type:
"Clear this file. Give me a clean starting point for an app called ExpenseTrackerApp with a basic Material 3 theme and a placeholder home screen."
Hit enter. Cursor will wipe the counter logic and leave you with a clean, modern structure.
Phase 3: How to Talk to Cursor (The Prompting Framework)#
Before we start building out the features, you need to understand how to interact with Cursor. If you just type "build an expense tracker", you'll get garbage output. AI needs guardrails.
Here are the three primary ways you'll use Cursor:
1. Inline Edits (`Cmd + K` / `Ctrl + K`)#
Use this for specific, localized changes.
Example: Highlight a Container, press Cmd+K, "Turn this into a nicely styled Card with a slight drop shadow."
2. The Chat Sidebar (`Cmd + L` / `Ctrl + L`)#
Use this for questions, brainstorming, or when you need the AI to write a completely new file for you. Example: "How should I structure the models for an expense tracking app using Riverpod?"
3. Composer (`Cmd + I` / `Ctrl + I`)#
This is the big gun. Composer allows Cursor to edit multiple files at once. You use this when building entire features. Example: "Create an Add Expense screen and wire it up to our existing router."
The @ Symbol (Context is King)#
Whenever you talk to Cursor, use the @ symbol to feed it context.
@Files: Pulls in specific files (e.g.,@expense_model.dart).@Codebase: Makes Cursor read your entire project before answering.@Docs: You can paste the link to a package documentation (like Riverpod or Hive) so Cursor knows the latest API methods.
Phase 4: Building the App#
Let's actually build this thing. We are going to go step-by-step, showing exactly what prompts to use.
Step 1: Defining the Data Model#
Open the Cursor Chat (Cmd + L) and type:
"I am building a Flutter expense tracker. Create a data model for an 'Expense' item. It needs an ID, a title, an amount, a date, and a category (using an enum for things like Food, Transport, Entertainment). Make sure to include a
copyWithmethod and factory constructors for JSON serialization. Put this inlib/models/expense.dart."
Cursor will generate the Dart code. It will likely use a package like uuid for the ID and give you clean, readable code. Hit the "Apply" button in the chat, and Cursor will create the file and drop the code in.
Step 2: Setting up State Management#
State management in Flutter can be a headache to set up manually. Let's use Riverpod, as it's the modern standard.
First, add the package. Open your terminal in Cursor:
flutter pub add flutter_riverpod
Now, open Composer (Cmd + I) and prompt:
"We are using
flutter_riverpod. Wrap our main app in aProviderScopein@main.dart. Then, create a new filelib/providers/expense_provider.dartthat contains aStateNotifier(orNotifierif using newer Riverpod) to manage a list ofExpenseobjects. It should have methods to add an expense and remove an expense."
Cursor will intelligently update main.dart to include the provider scope, create the new provider file, and write the logic for managing your list of expenses. Review the diffs and accept them.
Step 3: Building the UI (The Home Screen)#
Now for the fun part—the visuals. Let's build a dashboard that shows our expenses.
Open Composer (Cmd + I) and prompt:
*"Create a new file
lib/screens/home_screen.dart. This should be aConsumerWidgetthat listens to ourexpenseProviderfrom@expense_provider.dart.The UI should have:
- An AppBar with the title 'My Expenses'.
- A body containing a
ListView.builderthat displays the list of expenses.- Use a beautifully styled
CardandListTilefor each expense, showing the title, date (formatted nicely), category icon, and amount (bold, trailing).- A Floating Action Button at the bottom right with a '+' icon.
Make the UI look modern and premium, using Material 3."*
Because we referenced the provider, Cursor knows exactly what data it has to work with. It will generate a beautiful list view.
If you run the app now (press F5), you'll see your UI. But wait—it's empty because we don't have any data.
Step 4: The 'Add Expense' Feature#
Let's make that Floating Action Button actually do something. Instead of building a whole new screen, let's use a bottom sheet.
Highlight the FloatingActionButton code in home_screen.dart, press Cmd + K, and prompt:
"When this FAB is pressed, open a
showModalBottomSheet. Inside the sheet, create a form to add a new expense. It needs text fields for title and amount, a date picker, and a dropdown for the category enum. Include a 'Save' button that calls the add method on ourexpenseProviderand closes the sheet. Put the form logic in a separate widget in a new file calledlib/widgets/add_expense_form.dart."
Watch Cursor do its thing. It will scaffold the form, handle the text editing controllers, manage the date picker state, and wire it up to your Riverpod provider.
What would normally take 45 minutes of writing boilerplate layout code and state management wiring just took 30 seconds.
Phase 5: Polishing and Iterating with AI#
Getting the raw functionality built is fast, but where Cursor truly shines is in the iteration phase. Rarely is your app perfect on the first try.
Fixing UI Quirks#
Let's say the spacing on your bottom sheet looks a bit squished when the keyboard opens up. You don't need to hunt for the Padding widget and MediaQuery.of(context).viewInsets.bottom.
Just open Cmd + L, tag @add_expense_form.dart, and say:
"The bottom sheet content gets covered by the keyboard. Make it so the bottom sheet pushes up when the keyboard is open and add some padding to the bottom."
Cursor will suggest wrapping the form in a Padding widget mapped to the view insets, alongside making the sheet scrollable.
Adding Complex Logic (e.g., Chart Summaries)#
Let's say you want to add a summary chart above your list of expenses.
- Install the charts package:
flutter pub add fl_chart - Open Composer (
Cmd + I) and prompt:
"Create a new widget
lib/widgets/expense_summary_chart.dart. It should read the expenses from@expense_provider.dartand display a bar chart using thefl_chartpackage. The chart should group expenses by category and show the total amount spent per category. Insert this widget at the top of the body in@home_screen.dart."
Cursor will handle the data aggregation (looping through your expenses and summing them by category) and write the boilerplate required for fl_chart, which is notoriously verbose.
Phase 6: Debugging like a Pro#
One of the most frustrating things in app development is hitting a weird, cryptic error in your console.
With Cursor, debugging is almost a non-issue.
If you get a red screen of death on your emulator, go to the terminal in Cursor where the error is printed. Next to the error stack trace, you will see a small "Add to Chat" button, or you can just copy it and press Cmd + L.
Paste the error and ask: "Why am I getting this error and how do I fix it?"
Because Cursor has context of your entire codebase, it won't give you a generic Stack Overflow answer. It will say something like: "You are getting a ProviderNotFoundException because you forgot to wrap your HomeScreen in a ProviderScope in main.dart. Here is the fix."
Then you just hit apply. It is an absolute game-changer.
The Golden Rules of AI App Development#
As you continue building your Flutter apps with Cursor, keep these core principles in mind. If you rely too heavily on the AI without guiding it, you will end up with a messy, unmaintainable codebase.
1. Build Component by Component Do not ask Cursor to "Build an entire food delivery app." It will try, it will hallucinate, and it will fail. Ask it to build the auth screen. Then ask it to build the data model. Then the home screen. Break things down.
2. Enforce Architecture
Cursor will default to whatever is easiest. If you want a clean architecture (like MVVM or feature-first folder structures), you have to tell it. “Create this feature using a strict feature-first architecture, placing UI, providers, and models in a lib/features/expenses folder.”
3. Review the Diffs Always read the code Cursor generates before you hit 'Apply'. It is a highly advanced autocomplete, but it is not infallible. If it removes an important line of code by mistake, catch it in the diff view.
4. Keep your Context Clean
If you are asking about a bug in the routing, don't just use @Codebase. Specifically tag @app_router.dart and @main.dart. The more precise you are with providing context, the faster and more accurate the AI will be.
Final Thoughts#
Building a Flutter app with Cursor AI doesn't mean you stop being a developer. It means you step up from being a bricklayer to being an architect.
Instead of spending your mental energy remembering whether a Row takes mainAxisAlignment or crossAxisAlignment to center vertically, you spend your energy on the user experience, the system architecture, and the business logic.
The expense tracker we walked through today would easily take a junior developer a few days to build from scratch, accounting for UI polish, state management setup, and bug fixing. With Cursor, you can genuinely build the first working prototype in under an hour.
The barrier to entry for app development has never been lower, and the ceiling for what a single developer can accomplish has never been higher.
Now, fire up Cursor, create a new Flutter project, and start building that app idea you've been sitting on for the last year. You have no excuses left.
Happy coding.



