text
stringlengths
1
372
print(await dogs()); // prints a list that include fido.
// update fido's age and save it to the database.
fido = dog(
id: fido.id,
name: fido.name,
age: fido.age + 7,
);
await updateDog(fido);
// print the updated results.
print(await dogs()); // prints fido with age 42.
// delete fido from the database.
await deleteDog(fido.id);
// print the list of dogs (empty).
print(await dogs());
}
class dog {
final int id;
final string name;
final int age;
dog({
required this.id,
required this.name,
required this.age,
});
// convert a dog into a map. the keys must correspond to the names of the
// columns in the database.
Map<String, object?> toMap() {
return {
'id': id,
'name': name,
'age': age,
};
}
// implement toString to make it easier to see information about
// each dog when using the print statement.
@override
string toString() {
return 'dog{id: $id, name: $name, age: $age}';
}
}
<code_end>
<topic_end>
<topic_start>
firebase
<topic_end>
<topic_start>
introduction
firebase is a Backend-as-a-Service (baas) app development platform
that provides hosted backend services such as a realtime database,
cloud storage, authentication, crash reporting, machine learning,
remote configuration, and hosting for your static files.
<topic_end>
<topic_start>
flutter and firebase resources
firebase supports flutter. to learn more,
check out the following resources.
<topic_end>
<topic_start>
documentation
<topic_end>
<topic_start>
blog posts
use firebase to host your flutter app on the web
<topic_end>
<topic_start>
tutorials
get to know firebase for flutter
<topic_end>
<topic_start>
flutter and firebase community resources
the flutter community created the following useful resources.
<topic_end>
<topic_start>
blog posts
building chat app with flutter and firebase
<topic_end>
<topic_start>
videos
<topic_end>
<topic_start>
google APIs
the google APIs package exposes dozens of google
services that you can use from dart projects.
this page describes how to use APIs that interact with
end-user data by using google authentication.
examples of user-data APIs include
calendar, gmail, YouTube, and firebase.
info
the only APIs you should use directly from your flutter
project are those that access user data using google authentication.
APIs that require service accounts should not
be used directly from a flutter application.
doing so requires shipping service credentials as part
of your application, which is not secure.
to use these APIs,
we recommend creating an intermediate service.
to add authentication to firebase explicitly, check out the
add a user authentication flow to a flutter app using FirebaseUI
codelab and the
get started with firebase authentication on flutter docs.