This is a simple chat app written in Flutter with Firestore backend. It was inspired by this dribbble shot.
It was created during Flutter Warsaw workshop #1 on March 23, 2019.
It contains already prepared google-services.json and GoogleService-Info.plist files, but they will stop working soon in the future, so you may need to recreate them in your own Firebase console by following this guide.
This project uses Firebase and Firestore to work.
Please run flutter upgrade
before. The project was developed with Flutter 1.3.8 initially.
Before starting you should have prepared your Firestore database as follows:
- Add collection
rooms
- In
rooms
add new document with auto id and following fields:
name
: stringlastMessage
: mapavatar
: stringfrom
: stringcontent
: stringid
: stringtimestamp
: timestamp
- Initially set all the security rules as public. Remember to turn them off later to protect your account quota.
Commits 82f9648
- 6cf58d1
At this point you have a simple one page app with Firebase and other small details preconfigured like file structure or required packages and plugins.
In this part we're going to write a basic login page login_page.dart
, chat_rooms_page.dart
and initial layout of messages_page.dart
.
Commits a1ec3a4
- 742dd3b
In this part we're goting to develop models for storing chat rooms and messages across the app in:
chat_room.dart
chat_rooms_model.dart
message.dart
messages_model.dart
We're going to use Scoped Model to update views after fetching from or uploading data to Firestore.
Bugfixes in later commits
We found that on iOS there's a problem with parsing timestamps, so in order to solve this we had to convert timestamp to date i.e.
return Message._new()
..id = map['id']
..content = map['content']
..from = map['from']
- ..timestamp = map['timestamp']
+ ..timestamp = convertTimestamp(map['timestamp']);
Thank you all for helping Flutter Warsaw team to organize our first workshop ever.
See more on Flutter Warsaw Meetup.