Quickstarters
CRUD Samples
How to Build a CRUD App with Flutter?
29 min
overview in this guide, you'll develop a flutter application that handles essential crud operations—create, read, update, and delete—by leveraging back4app as your backend service we will walk you through setting up a back4app project, designing a flexible data schema, and integrating your flutter app with the backend using the parse sdk for flutter initially, you will create a new back4app project named basic crud app flutter this project provides a reliable data storage solution for your mobile application you will then define your data model by creating collections and fields either manually or with the help of back4app's ai agent next, you'll use the intuitive back4app admin app to manage your data seamlessly finally, you will connect your flutter application to back4app by using the parse server sdk flutter package, enabling secure and efficient crud operations by the end of this tutorial, you will have a production ready flutter application capable of performing basic crud functions along with secure user authentication and data management key insights build a flutter app that interacts with a powerful backend learn to design a scalable backend schema on back4app utilize the back4app admin app for effortless data management implement robust security measures including acls and user authentication prerequisites before you start, make sure you have a back4app account with an active project need assistance? visit getting started with back4app https //www back4app com/docs/get started/new parse app a flutter development environment install flutter and choose an ide like visual studio code or android studio a basic understanding of flutter, dart, and rest apis check out the flutter documentation https //flutter dev/docs if needed step 1 – project initialization creating a new back4app project log in to your back4app account click the “new app” button on your dashboard name your project basic crud app flutter and follow the prompts to complete the setup create new project after your project is created, it will appear on your dashboard, ready for backend configuration step 2 – crafting the data model setting up your data structures for this flutter application, you will establish several collections within your back4app project below are examples of the key collections and fields required to support the crud functionality 1\ products collection this collection stores details about individual products field type description id objectid automatically assigned unique identifier name string the name of the product details string a brief description of the product createdat date timestamp when the product was added updatedat date timestamp when the product was last updated 2\ users collection this collection manages user credentials and authentication details field type description id objectid auto generated unique identifier username string unique username for the user email string unique email address of the user passwordhash string encrypted password for secure authentication createdat date timestamp when the account was created updatedat date timestamp when the account was last updated you can create these collections manually in the back4app dashboard create new class to add fields, simply select the data type, specify the field name, set a default value if necessary, and mark it as required create column using back4app's ai agent for schema creation the integrated ai agent in back4app can automatically generate your data schema based on your description, streamlining the setup process how to use the ai agent access the ai agent open your back4app dashboard and locate the ai agent in your project settings describe your schema provide a detailed prompt outlining the collections and fields you need review and confirm once the ai agent processes your input, review the proposed schema and confirm to apply it sample prompt create the following collections in my back4app project 1\) collection products \ fields \ id objectid (auto generated) \ name string \ details string \ createdat date (auto generated) \ updatedat date (auto updated) 2\) collection users \ fields \ id objectid (auto generated) \ username string (unique) \ email string (unique) \ passwordhash string \ createdat date (auto generated) \ updatedat date (auto updated) this approach saves time and ensures that your data schema is both consistent and optimized step 3 – activating the admin app & managing crud operations introduction to the admin app the back4app admin app offers a no code interface for managing your backend data its drag and drop functionality allows you to effortlessly perform crud operations such as creating, reading, updating, and deleting records enabling the admin app navigate to the “more” menu in your back4app dashboard select “admin app” and then click “enable admin app ” set up your admin credentials by creating an initial administrator account, which will also configure roles like b4aadminuser enable admin app after enabling, log in to the admin app to manage your application data admin app dashboard managing crud operations within the admin app, you can create entries use the “add record” option in a collection (e g , products) to insert new data view and edit entries click on a record to inspect details or update fields delete entries remove records that are no longer needed this user friendly interface simplifies the process of managing your backend data step 4 – connecting your flutter app with back4app with your backend configured, it's time to integrate your flutter application with back4app using the parse sdk for flutter add the dependency open your pubspec yaml and include the parse server sdk flutter package dependencies flutter sdk flutter parse server sdk flutter ^3 1 0 initialize parse in your app in your main dart , initialize parse with your back4app credentials import 'package\ flutter/material dart'; import 'package\ parse server sdk flutter/parse server sdk dart'; future\<void> main() async { widgetsflutterbinding ensureinitialized(); await parse() initialize( 'your application id', 'https //parseapi back4app com', clientkey 'your flutter key', debug true, ); runapp(myapp()); } class myapp extends statelesswidget { @override widget build(buildcontext context) { return materialapp( title 'basic crud app', home homepage(), ); } } implementing crud operations create a dart file (e g , product service dart ) to handle your crud actions import 'package\ parse server sdk flutter/parse server sdk dart'; class productservice { future\<list\<parseobject>> fetchproducts() async { final query = querybuilder\<parseobject>(parseobject('products')); final response = await query query(); if (response success && response results != null) { return response results as list\<parseobject>; } return \[]; } future\<void> addproduct(string name, string details) async { final product = parseobject('products') set('name', name) set('details', details); final response = await product save(); if (response success) { print('product added successfully '); } else { print('error adding product ${response error? message}'); } } future\<void> updateproduct(string objectid, string newname, string newdetails) async { final query = querybuilder\<parseobject>(parseobject('products')); query whereequalto('objectid', objectid); final response = await query first(); if (response != null && response success) { final product = response results! first as parseobject; product set('name', newname) set('details', newdetails); final saveresponse = await product save(); if (saveresponse success) { print('product updated '); } } } future\<void> deleteproduct(string objectid) async { final query = querybuilder\<parseobject>(parseobject('products')); query whereequalto('objectid', objectid); final response = await query first(); if (response != null && response success) { final product = response results! first as parseobject; final deleteresponse = await product delete(); if (deleteresponse success) { print('product deleted '); } } } } this service file enables your flutter ui to interact smoothly with your back4app backend alternative using rest/graphql in flutter if you choose not to use the parse sdk, you can make rest calls using packages like http however, the parse sdk is recommended for a more integrated experience step 5 – securing your backend access control lists (acls) to protect your data, configure acls for your objects for example, create a product that is visible only to its creator import 'package\ parse server sdk flutter/parse server sdk dart'; future\<void> addprivateproduct(string name, string details, parseuser owner) async { final product = parseobject('products') set('name', name) set('details', details); final acl = parseacl(owner) setpublicreadaccess(false) setpublicwriteaccess(false); product setacl(acl); final response = await product save(); if (response success) { print('private product created '); } else { print('error ${response error? message}'); } } class level permissions (clps) in your back4app dashboard, configure clps to enforce default security rules, ensuring that only authenticated users can access or modify specific collections step 6 – implementing user authentication setting up user registration and login back4app utilizes the parse user class for handling authentication in your flutter app, implement user registration and login as follows import 'package\ parse server sdk flutter/parse server sdk dart'; class authservice { future\<void> registeruser(string username, string password, string email) async { final user = parseuser createuser(username, password, email); final response = await user signup(); if (response success) { print('user registered successfully!'); } else { print('registration failed ${response error? message}'); } } future\<void> loginuser(string username, string password) async { final user = await parseuser login(username, password); if (user success) { print('logged in as ${user result? username}'); } else { print('login error ${user error? message}'); } } } this setup covers user registration, login, and additional authentication management for your flutter application step 7 – conclusion and future enhancements congratulations! you have successfully built a flutter based crud application integrated with back4app in this tutorial, you created a project named basic crud app flutter , defined collections for products and users, and managed your backend using the admin app additionally, you connected your flutter app with back4app using the parse server sdk flutter package while implementing robust security and user authentication next steps expand your app add features like advanced search, detailed views, or real time updates enhance backend functionality explore cloud functions, third party api integrations, or more granular role based access controls continue learning review the back4app documentation https //www back4app com/docs and additional tutorials to further optimize your application happy coding and best wishes on your flutter development journey!