Skip to content

🚨 A citizen-centric app : Respond and Alert in distress, view government data and more. CZ2006 project.

Notifications You must be signed in to change notification settings

robertocarlosjuan/beanSafetyApp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

B.E.A.N.S

logo

Video demo is on youtube here

Firebase:

  • Set up a new firebase project, and link it with an android app (work with the /android folder in flutter). Follow along the steps.
  • In the firebase console under "Authentication", set up email and anonymous login methods.
  • Don't forget to add your google-services.json in the android/app/ folder!

Showing local notifications

  • import : import 'package:firebase_tutorial/services/localNotifications.dart';
  • use : showNotification(id, "Title", "Body"); (id is an integer)

Learnings

  • keep models(classes) seperate from the UI files. Also bunch related UI files together.
  • We use Streams in dart to lisen for changes (eg: listen for change in authentication status in the wrapper).
    • Each peice of information in a Stream in being continually sent. Basically, dont send shit all at once, but send it as and when you recieve it.
  • We use the Provider package for listening to changes lower in the widget tree from somewhere higher in the widget tree. It is the recommended way for state management in flutter. It is used in the root widget (main.dart here)
  • Can pass functions to children as parameters, which toggle the parent's state (here, to switch views). For example, check out how register and sign in are switched. There is no Material.push() or whatever that is, to manually push/pop a page from the stack. It's all handled by a parent class controlling both the states.
  • We are also use another stream from firebase, which notifies us of and document/document changes that happen in our database. We user Provider again, in the home.dart (the homepage)
  • getters are usually used for stream definition, so other classes just call this getter.
  • make sure streams are getting updated with the data they are listening to changes for
  • Can actually have more than 1 emulator running, with each acting as a seperate user.
  • flutter clean when you have no clue on why your app won't build.
  • Make sure returned value from firebase cloud function,eg, in index.ts, is JSON-serialisable.
  • Devices are identified with a fcm (got in getDeviceToken in pushNotification.dart). You can't use the the Firebase Auth uid as the fcm. Gotta store and use it seperately.
  • Sometimes users will have to be re-registered for fcm token to be valid. (Do this if the notifications are not working)
  • can use if within columns etc to show/hide widgets, like so.

TODO:

  • do something with the toggle dengue button in alertMe.dart
  • user currentlocation service for getting current location of the user everywhere.
  • remove api key from android/app/src/main/AndroidManifest.xml and everywhere else after project is over.

Login process

img

References

About

🚨 A citizen-centric app : Respond and Alert in distress, view government data and more. CZ2006 project.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 97.5%
  • TypeScript 1.7%
  • Other 0.8%