More
Collecting User Feedback in Flutter Using the Feedback Component and Storing Data on Back4app
11 min
introduction user feedback is essential for developers to understand what works well in their app and what needs improvement implementing a feedback mechanism can be time consuming, but with the feedback package in flutter, you can quickly set up a feedback panel that allows users to submit text input and annotated screenshots in this tutorial, we'll show you how to integrate this feedback component into your flutter app and store the collected feedback in back4app prerequisites before getting started, ensure you have the following a back4app account sign up for a free account at back4app com https //www back4app com a flutter development environment set up on your local machine follow the flutter installation guide https //flutter dev/docs/get started/install if you haven't set it up yet basic knowledge of dart, flutter widgets, and using back4app for backend services step 1 – setting up your back4app backend create a back4app project log in to your back4app account https //www back4app com/ and create a new project create parse classes for this tutorial, create a parse class named userfeedback to store the feedback submitted by users username (string) the name of the user (optional) feedbacktext (string) the text feedback provided by the user screenshot (file) the screenshot annotated by the user get your back4app credentials navigate to your project settings to retrieve your application id and client key, which you’ll need to connect your flutter app to back4app step 2 – setting up the flutter project create a new flutter project open your terminal or command prompt and run flutter create feedback example add dependencies open pubspec yaml and add the following dependencies dependencies flutter sdk flutter feedback latest version parse server sdk flutter latest version run flutter pub get to install these dependencies initialize parse in your app in lib/main dart , initialize the parse sdk import 'package\ flutter/material dart'; import 'package\ parse server sdk flutter/parse server sdk flutter dart'; import 'package\ feedback/feedback dart'; void main() async { widgetsflutterbinding ensureinitialized(); const keyapplicationid = 'your back4app app id'; const keyclientkey = 'your back4app client key'; const keyparseserverurl = 'https //parseapi back4app com'; await parse() initialize(keyapplicationid, keyparseserverurl, clientkey keyclientkey, autosendsessionid true); runapp(myapp()); } class myapp extends statelesswidget { @override widget build(buildcontext context) { return betterfeedback( child materialapp( home feedbackscreen(), ), onfeedbacksubmitted sendfeedbacktobackend, ); } future\<void> sendfeedbacktobackend(userfeedback feedback) async { final parseobject = parseobject('userfeedback') set('feedbacktext', feedback text) set('screenshot', parsefile(await feedback screenshot)); await parseobject save(); } } replace 'your back4app app id' and 'your back4app client key' with your actual back4app credentials step 3 – implementing the feedback component create the feedbackscreen widget in lib/main dart , create a new screen that allows users to submit feedback class feedbackscreen extends statelesswidget { @override widget build(buildcontext context) { return scaffold( appbar appbar(title text('feedback example')), body center( child elevatedbutton( onpressed () { betterfeedback of(context) show(); }, child text('give feedback'), ), ), ); } } this widget displays a simple button that, when pressed, opens the feedback panel customize the feedback panel you can customize the appearance and behavior of the feedback panel by passing additional parameters to the betterfeedback widget for instance betterfeedback( child materialapp( home feedbackscreen(), ), onfeedbacksubmitted sendfeedbacktobackend, feedbacktheme feedbackthemedata( background colors grey\[900], feedbacksheetcolor colors white, activecolor colors blue, drawingcolor colors red, ), ) this customization allows you to change the colors and style of the feedback panel to match your app’s theme step 4 – running the app run your app using flutter run you should see the feedback button displayed on the screen clicking it will open the feedback panel, allowing the user to capture a screenshot, annotate it, and provide text feedback verify the data in back4app by logging into your back4app dashboard and checking the userfeedback class you should see entries corresponding to the feedback submitted from the flutter app, including the text and the screenshot conclusion in this tutorial, we demonstrated how to integrate a feedback component into a flutter app using the feedback package we also showed how to store the collected feedback, including annotated screenshots, in back4app this setup allows you to quickly gather valuable insights from your users, helping you improve your app based on their feedback for more information on using flutter widgets, check out the flutter documentation https //flutter dev/docs , and for backend integration tips, visit the back4app documentation https //www back4app com/docs happy coding!