Firebase Tutorial for Flutter: Getting Started | raywenderlich.com

In this tutorial, youā€™ll learn how to use Firebase Firestore databases in Flutter by creating a fun app that will help you take care of your pets.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/7426050-firebase-tutorial-for-flutter-getting-started

Donā€™t we need to add cloud_firestore: ^0.13.4+2 to flutter dependencies?

There is a section of the article that states:
" In Android Studio open pubspec.yaml and add cloud_firestore: ^0.13.0+1 after flutter_form_builder: ^3.7.2 . Then click Packages get to add the firestore library."

Trying to build after the step Add DataRepository to Main always gave me the same error. I tried to take the finished the project and set it up as well and it still failed. It seemed to be an issue with pods but I could never track down a solution.

Ever run into this?

Thanks for finding this. It took me awhile to figure it out. Turns out that the flutter_form_builder library depended on the flutter_chips_input library which had the problem. I updated the flutter_form_builder library to the latest version and the problem went away. Luckily Android Studio will let you know if the versions can be updated. I have:

flutter_form_builder: ^3.11.5
cloud_firestore: ^0.13.7

** UPDATE: After a day of playing with this I found a fix within 10 minutes of this post!

Problem with flutter_form_builder version. Set to this version. Worked for me with code from the download.

flutter_form_builder: ^3.14.0-alpha.2

*** End Update ***

First let me say this tutorial has the best look/feel of any tutorial Iā€™ve followed (both free and paid)! The work you put into this project shows. Unfortunately I have a similar issues posted above by colesluggett. From the start after downloading and PubGet the app errors. I have updated the form builder as Kevin suggested and further updated to latest available. I cleaned, doctored, removed Podfile.lock and had it rebuild. Continues to error out
ā€“ event sent after app closed: {id: 0, progressId: null, message: Running ā€œflutter pub getā€ in beginā€¦}
event sent after app closed: {id: 0, progressId: null, finished: true}
Launching lib/main.dart on iPhone 11 Pro Max in debug modeā€¦
Running pod installā€¦
Warning: Podfile is out of date
This can cause issues if your application depends on plugins that do not support iOS.
See Developing packages & plugins | Flutter for details.
If you have local Podfile edits you would like to keep, see Move logic from user project's Podfile to a Ruby script in Flutter tools Ā· Issue #45197 Ā· flutter/flutter Ā· GitHub for instructions.
To regenerate the Podfile, run:
rm ios/Podfile

Running Xcode buildā€¦
Xcode build done. 152.9s
Failed to build iOS app
Error output from Xcode build:
ā†³
** BUILD FAILED **

Xcodeā€™s output:
ā†³
ā€¦/ā€¦/ā€¦/ā€¦/ā€¦/ā€¦/.pub-cache/hosted/pub.dartlang.org/flutter_form_builder-3.13.5/lib/src/fields/form_builder_range_slider.dart:21:9: Error: Type ā€˜RangeSemanticFormatterCallbackā€™ not found.
final RangeSemanticFormatterCallback semanticFormatterCallback;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ā€¦/ā€¦/ā€¦/ā€¦/ā€¦/ā€¦/.pub-cache/hosted/pub.dartlang.org/flutter_form_builder-3.13.5/lib/src/fields/form_builder_range_slider.dart:21:9: Error: ā€˜RangeSemanticFormatterCallbackā€™ isnā€™t a type.
final RangeSemanticFormatterCallback semanticFormatterCallback;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Command PhaseScriptExecution failed with a nonzero exit code
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description

Could not build the application for the simulator.
Error launching application on iPhone 11 Pro Max.

I have found that running flutter clean can help too

Hi, great tutorial.
Any possibility to update or create more tutorials like this about firebase?
I saw many changes in firebase documentation, if I want to use the new version, still exist Document Reference in the code or change?

Your tutorial is great.

I believe I ran into 2 minor problems, unrelated to Firebase.

Problem 1: If you donā€™t change the pet name or note fields from their previous values, they are over-written with null on ā€œUpdateā€. (Just initialize them in initState())
Problem 2: Adding even one prescription gets you ā€œBOTTOM OVERFLOWED BY X PIXELSā€. Just add a SingleChildScrollView.

class _PetDetailFormState extends State {
final DataRepository repository = DataRepository();
final _formKey = GlobalKey();
final dateFormat = DateFormat(ā€˜yyyy-MM-ddā€™);
String name;
String type;
String notes;

@override
void initState() {
// TODO set type to pet type

name = widget.pet.name;
type = widget.pet.type;
notes = widget.pet.notes;

super.initState();
}

@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),
child: FormBuilder(
key: _formKey,
autovalidateMode: AutovalidateMode.always,
// autovalidate: true,
child: SingleChildScrollView(
padding: EdgeInsets.only(bottom: 15),
child: Column(

Thanks so much for the suggestion. Now that I see those changes, they make total sense.

Any possibility of updating this tutorial? It is very good, but the content is outdated and the samples do not run out of the box. I realize that tech tutorials are moving targets these days as well.

I will let them know. Weā€™ll have to schedule an update

Building the begin project before adding code to it on an M1 MacBook fails with an error message from Xcode:

Error output from Xcode build:
ā†³
objc[5936]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x203319160) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1201fc2b8). One of the two will be used. Which one is undefined.
objc[5936]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x2033191b0) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1201fc308). One of the two will be used. Which one is undefined.
** BUILD FAILED **

Any ideas how to solve?

I donā€™t know if this will solve the problem, but my first thing I try is ā€œflutter cleanā€, ā€œflutter getā€ and then try again

Hello for every one;

Thank you so much for your efforts guys, we are appreciating every line you made
so, i have a suggestion for us :
Please if you can make an update these projects to null safety because we are learning from this course a lot.
I hope you take this in consideration, and we can continue learning.
Honestly, this new feature(null safety) is a mind-blowing.
.
So thank you so much in advance.
We hope we can get response soon.
Thanks for time

This has been updated! Please see:
https://www.raywenderlich.com/26435435-firestore-tutorial-for-flutter-getting-started

Hi, Iā€™m new member so apologies if Iā€™m not supposed to post tutorial errors/edit requests here.

So in the book Firestore tutorial for flutter getting started, in the updating the pet model section, I experienced an error with the following code in the pets.dart file:

newPet.reference = snapshot.reference.id;

I had to change it to this code which is also in the final repository folder:

newPet.referenceId = snapshot.reference.id;