Coder Social home page Coder Social logo

kenaragorn / create_flutter_provider_app Goto Github PK

View Code? Open in Web Editor NEW
398.0 21.0 118.0 1.9 MB

A boilerplate project created in Flutter using Provider and Firebase.

License: MIT License

Kotlin 0.63% Swift 0.60% Objective-C 0.06% Dart 98.72%
flutter dart boilerplate boilerplate-template flutter-boilerplate provider state-management flutter-state-management flutter-examples flutter-demo

create_flutter_provider_app's People

Contributors

ahmadalibaloch avatar kenaragorn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

create_flutter_provider_app's Issues

How to manage user settings from firebase ?

Hi,

In this architecture if we wanted to have global parameters for a specific user, stored in firebase, how would you do it?

Make another widget / stream + provider like widgetAuthBuilder, below this one? Or is there a better way? Overload the "flat" user from firebase ?

I'm a little lost, if you can clarify this :)

Thanks

Gradle build failed to produce

Hi Ken,

just wanna thank you, this project is amazing

I just wanna share my problem with this project

I got this error

Exception: Gradle build failed to produce an .apk file. It's likely that this file was generated under
/home/myusername/Git/create_flutter_provider_app/build, but the tool couldn't find it.

And i do solve it with creating new flutter project then copy build.grade in app folder, and paste it to your amazing template

No user creation

Updated:
Used the instructions and inserted the following in register_screen in order to patch the app so that user creation actually lead to a user record in the database. Alas it throws the dreaded "Error: Could not find the correct provider ..." - So what is the deal with register_screen?

FirestoreDatabase firestoreDatabase = Provider.of<FirestoreDatabase>(context);

lang/ asset not found

Hi,

I keep getting this error:

image

I have tried to add it in the pubspec file under :

flutter:
   assets:
   - lang/
   // And - assets/lang

any idea what I need to add also?

Storage service

Excellent code. How would you implement the storage service?

Dependency issue upon running flutter pub get: firebase_auth requires firebase_auth_web

I wanted to test out this project but upon trying to run flutter pub get I receive a long list of dependency issues related to firebase_auth_web. I tried adding the version of firebase_auth_web it requested but that led to further dependency issues.

Log:

PS C:\Users\eric1\OneDrive\Desktop\Flutter\create_flutter_provider_app> flutter pub get
Resolving dependencies... (2.7s)
    Because firebase_auth >=3.2.0 <3.3.0 depends on firebase_auth_web ^3.2.0 and firebase_auth >=3.3.0 <3.3.1 depends on firebase_auth_web ^3.3.0, firebase_auth
      >=3.2.0 <3.3.1 requires firebase_auth_web ^3.2.0.
    And because firebase_auth >=3.3.1 <3.3.2 depends on firebase_auth_web ^3.3.2 and firebase_auth >=3.3.2 <3.3.3 depends on firebase_auth_web ^3.3.3, firebase_auth
      >=3.2.0 <3.3.3 requires firebase_auth_web ^3.2.0.
    And because firebase_auth >=3.3.3 <3.3.4 depends on firebase_auth_web ^3.3.4 and firebase_auth >=3.3.4 <3.3.5 depends on firebase_auth_web ^3.3.5, firebase_auth
      >=3.2.0 <3.3.5 requires firebase_auth_web ^3.2.0.
    And because firebase_auth >=3.3.5 <3.3.6 depends on firebase_auth_web ^3.3.6 and firebase_auth >=3.3.6 <3.3.8 depends on firebase_auth_web ^3.3.7, firebase_auth
      >=3.2.0 <3.3.8 requires firebase_auth_web ^3.2.0.
    And because firebase_auth >=3.3.8 <3.3.9 depends on firebase_auth_web ^3.3.8 and firebase_auth >=3.3.9 <3.3.12 depends on firebase_auth_web ^3.3.9, firebase_auth
      >=3.2.0 <3.3.12 requires firebase_auth_web ^3.2.0.
    And because firebase_auth >=3.3.12 <3.3.13 depends on firebase_auth_web ^3.3.10 and firebase_auth >=3.3.13 <3.3.14 depends on firebase_auth_web ^3.3.11,
      firebase_auth >=3.2.0 <3.3.14 requires firebase_auth_web ^3.2.0.
    And because firebase_auth >=3.3.14 <3.3.15 depends on firebase_auth_web ^3.3.12 and firebase_auth >=3.3.15 <3.3.17 depends on firebase_auth_web ^3.3.13,
      firebase_auth >=3.2.0 <3.3.17 requires firebase_auth_web ^3.2.0.
    And because firebase_auth >=3.3.17 <3.3.18 depends on firebase_auth_web ^3.3.14 and firebase_auth >=3.3.18 <3.3.19 depends on firebase_auth_web ^3.3.15,
      firebase_auth >=3.2.0 <3.3.19 requires firebase_auth_web ^3.2.0.
    And because firebase_auth >=3.3.19 <3.3.20 depends on firebase_auth_web ^3.3.16 and firebase_auth >=3.3.20 <3.4.0 depends on firebase_auth_web ^3.3.17,
      firebase_auth >=3.2.0 <3.4.0 requires firebase_auth_web ^3.2.0.
    And because firebase_auth >=3.4.0 <3.4.1 depends on firebase_auth_web ^3.3.18 and firebase_auth >=3.4.1 <3.4.2 depends on firebase_auth_web ^3.3.19, firebase_auth
      >=3.2.0 <3.4.2 requires firebase_auth_web ^3.2.0.
    And because firebase_auth >=3.4.2 <3.5.0 depends on firebase_auth_web ^4.0.0 and firebase_auth >=3.5.0 <3.5.1 depends on firebase_auth_web ^4.1.0, firebase_auth
      >=3.2.0 <3.5.1 requires firebase_auth_web ^3.2.0 or >=4.0.0 <5.0.0.
    And because firebase_auth >=3.5.1 <3.6.0 depends on firebase_auth_web ^4.1.1 and firebase_auth >=3.6.0 <3.6.1 depends on firebase_auth_web ^4.2.0, firebase_auth
      >=3.2.0 <3.6.1 requires firebase_auth_web ^3.2.0 or >=4.0.0 <5.0.0.
    And because firebase_auth >=3.6.1 <3.6.2 depends on firebase_auth_web ^4.2.1 and firebase_auth >=3.6.2 <3.6.3 depends on firebase_auth_web ^4.2.2, firebase_auth
      >=3.2.0 <3.6.3 requires firebase_auth_web ^3.2.0 or >=4.0.0 <5.0.0.
    And because firebase_auth >=3.6.3 <3.6.4 depends on firebase_auth_web ^4.2.3 and firebase_auth >=3.6.4 <3.7.0 depends on firebase_auth_web ^4.2.4, firebase_auth
      >=3.2.0 <3.7.0 requires firebase_auth_web ^3.2.0 or >=4.0.0 <5.0.0.
    And because firebase_auth >=3.7.0 <3.8.0 depends on firebase_auth_web ^4.3.0 and firebase_auth >=3.8.0 <3.9.0 depends on firebase_auth_web ^4.4.0, firebase_auth
      >=3.2.0 <3.9.0 requires firebase_auth_web ^3.2.0 or >=4.0.0 <5.0.0.
    And because firebase_auth >=3.9.0 <3.10.0 depends on firebase_auth_web ^4.4.1 and firebase_auth >=3.10.0 <3.11.0 depends on firebase_auth_web ^4.5.0,
      firebase_auth >=3.2.0 <3.11.0 requires firebase_auth_web ^3.2.0 or >=4.0.0 <5.0.0.
(1) So, because firebase_auth >=3.11.0 <3.11.2 depends on firebase_auth_web ^4.6.0 and firebase_auth ^3.11.2 depends on firebase_auth_web ^4.6.1, firebase_auth ^3.2.0
      requires firebase_auth_web ^3.2.0 or >=4.0.0 <5.0.0.

    Because firebase_auth >=3.1.5 <3.2.0 depends on firebase_auth_web ^3.1.4 and firebase_auth >=3.1.4 <3.1.5 depends on firebase_auth_web ^3.1.3, firebase_auth
      >=3.1.4 <3.2.0 requires firebase_auth_web ^3.1.3.
    And because firebase_auth >=3.1.3 <3.1.4 depends on firebase_auth_web ^3.1.2 and firebase_auth >=3.1.0 <3.1.2 depends on firebase_auth_web ^3.1.0, firebase_auth
      >=3.1.0 <3.1.2-∞ or >=3.1.3 <3.2.0-∞ requires firebase_auth_web ^3.1.0.
    And because no versions of firebase_auth match >3.0.2 <3.1.0 and firebase_auth >=3.1.2 <3.1.3 depends on firebase_auth_web ^3.1.1, firebase_auth >3.0.2 <3.2.0
      requires firebase_auth_web ^3.1.0.
    And because firebase_auth ^3.2.0 requires firebase_auth_web ^3.2.0 or >=4.0.0 <5.0.0 (1), firebase_auth >3.0.2 <4.0.0 requires firebase_auth_web >=3.1.0 <4.0.0 or
      >=4.0.0 <5.0.0.
    And because firebase_auth 3.0.2 depends on firebase_auth_web ^3.0.1, firebase_auth ^3.0.2 requires firebase_auth_web >=3.0.1 <4.0.0 or >=4.0.0 <5.0.0.
    And because firebase_auth_web >=1.0.0 <5.2.2 depends on intl ^0.17.0 and every version of flutter_localizations from sdk depends on intl 0.18.0, firebase_auth
      ^3.0.2 is incompatible with flutter_localizations from sdk.
    So, because noteapp depends on both flutter_localizations from sdk and firebase_auth ^3.0.2, version solving failed.
PS C:\Users\eric1\OneDrive\Desktop\Flutter\create_flutter_provider_app> 

App state for SignIn Screen

It seems that the 'userSnapshot.hasData' function is always returning true and the 'SignIn' screen is not called on line 80 of the 'my_app.dart' file. I'm new with flutter, I'm still understanding the use of the 'Provider' approach.

Firebase changes

Hi Ken

Any plans to apply the changes required for the latest Firebase updates?

Thanks
Bigtaff

Question: where does uid come from?

Thought there was a lot of good stuff in this repo. I've been looking at this one line for a while and curious how it works. You stopped just short of explaining this in your medium article.

In this line databaseBuilder: (_, uid) => FirestoreDatabase(uid: uid), I understand that FirestoreDatabase takes a named parameter called uid, and that the value for that is coming from (_, uid). What I'm not following is where the uid for (_, uid) is actually created and emitted in the first place.

If you have any insights I would appreciate it.

Thanks!

databaseBuilder: (_, uid) => FirestoreDatabase(uid: uid),

App crash after build: FATAL EXCEPTION: main - java.lang.RuntimeException: Unable to instantiate activity - java.lang.ClassNotFoundException: Didn't find class "com.NAME.APPNAME.MainActivity" on path: DexPathList

I took me way to long to fix this error, so I hope this helps someone else:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.NAME.APPNAME.dev/com.NAME.APPNAME.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.NAME.APPNAME.MainActivity" on path: DexPathList[[zip file "/data/app/com.NAME.APPNAME.dev-XzP2FDlcF7ok_QeihJlBQQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.NAME.APPNAME.dev-XzP2FDlcF7ok_QeihJlBQQ==/lib/x86, /data/app/com.NAME.APPNAME.dev-XzP2FDlcF7ok_QeihJlBQQ==/base.apk!/lib/x86, /system/lib]]

Maybe this error came because I renamed the bundle itentifier in the AndroidManifest files and everywhere else I could find it. This step wasn´t explicitly explained in the setup of the project.

My solution in the end was to also rename the "android/app/src/main/kotlin/com/venturearkstudio/noteapp" folder structure into my bundle identifier ".../com/NAME/APPNAME". And then also in the MainActivity.kt file the "package com.venturearkstudio.noteapp" to "package com.NAME/APPNAME".

Not sure if these steps should be added into the setup instructions or if I made something wrong and then ran into this issue.

Flutter application is created using an older version of the Android embedding

Currently cannot compile caused by deprecated support of Android embedding v1. The link supplied explain quite well the changes necessary for the migration.

$ flutter build apk
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Warning
────────────────────────────────────────────────────────────
Your Flutter application is created using an older version of the Android
embedding. It is being deprecated in favor of Android embedding v2. To migrate
your project, follow the steps at:

https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects

The detected reason was:

 .../android/app/src/main/AndroidManifest.xml uses
  `android:name="io.flutter.app.FlutterApplication"`

Build failed due to use of deprecated Android v1 embedding.

Reflect Real Time Change from Database

Hi Ken,
Thank you for making this. This is a not an issue but rather a question:
I am building a Chat App with Flutter and FireStore. At first I just stream the data directly to Stream Builder and store reusable data like user data in Shared Preferences, but this might cause a lot of calls to the database for non-reusable data. So I search and find out about using provider with Firestore and find your project. My question is, if using Provider, can the data reflect changes in real time if there are changes in the database, like if an user change their name and all people in their friend list can see the changed name? Or in a chat group, if someone send a message, will other see them also or do they have to refresh the data? I know it might not related too much to the project but I am planning on scrapping my current one and use your as a template to build it if it match the above critia.

Additional Features

Hey, I'm really impressed with this starter architecture. Would be really nice if you added some additional features:

  1. Other authentication methods (google, facebook, twitter, biometrics)
  2. Responsive UI boilerplate code (sounds challenging to add responsiveness as a boilerplate code! Maybe settle with deviceWidth and deviceHeight as constants)
  3. Firebase Queries service. Some examples that came to my mind:
  • Query a collection based on one value
  • Query a collection based on multiple values, .where('docField', 'in', '[values]')
  • Query SubCollections with same name, subCollectionNames.where('docField', 'condition', 'value').groupByParent('parentCollection')
  • order a collection based on field, ascending or descending.
  1. Firebase messaging service, for sending notifications.
  2. Firebase Storage service.
  3. Firebase Analytics Service.
  4. String Validators Service. Check out this implementation
  5. Error handling service.

I know that's a lot, but you're doing a great job so far. This boilerplate structure has a high potential of easing the process for many developers.

Firebase / initializeApp()

Hello,

First of all, thank you for the code, it can have a lot of value.

That being said, I found some issues when trying to start the app.

First I had to go to pubspec.yaml and do:

  assets:
    - assets/lang/en.json
    - assets/lang/zh.json
 
  fonts:
    - family: ProductSans
      fonts:
        - asset: assets/fonts/Product-Sans-Regular.ttf
        - asset: assets/fonts/Product-Sans-Italic.ttf
          style: italic
        - asset: assets/fonts/Product-Sans-Bold.ttf
          weight: 700
        - asset: assets/fonts/Product-Sans-Bold-Italic.ttf
          style: italic
          weight: 700

and change line 27 on the app_localizations.dart to

await rootBundle.loadString('assets/lang/${locale.languageCode}.json');

or the app wouldn't even start.

Then I had to add

await Firebase.initializeApp();

between lines 15/16 of the main.dart and main_prod.dart, or again, the app wouldn't even start. (Also had to add firebase_core: ^1.6.0 to the pubspec.yaml, and the import to main.dart and and main_prod.dart of course).

Then in line 81 of the my_app.dart I had to change it to:

return userSnapshot.data?.uid != 'null'
  ? HomeScreen()
  : SignInScreen();

because userSnapshot.hasData always had "something", and that was causing records to be inserted in the database with uid as null meaning /user/null/todos/<todo_item_id>.

But now I can't move on.

The issue itself is when I log out and login with another user, I have the data from the old user.

I know you say on the README.md that:

To achieve this, FirestoreDatabase will be re-created everytime onAuthStateChanged changed.

But this doesn't seem to be happening.

Might be due to my changes as mentioned above.

Any help would be much appreciated. Regards to all.

SharedPreferences / not loading on app initialization

The issue is when I close and reopen my app, the color theme and language is not set according to my settings, it's always the default.

In lib/my_app.dart lines 40

locale: languageProviderRef.appLocale,

and 73

themeMode: themeProviderRef.isDarkModeOn

are the issue.

As these are async methods, from lib/providers/language_provider.dart and lib/providers/theme_provider.dart respectively, when the app initially runs, the information isn't there yet.

Let me know if anyone has thoughts how to fix it.

Question: Access Firestore from Register while trying to register.

I am very new to flutter so Im still trying to wrap my head around how this project is structured and understand how data is flowing. But what I am trying to do is when a new user try's to register an account I want to first query Firestore to see if they have been invited before allowing registration to happen.

My first guess was to simply use Provider of to gain access to the FirestoreDatabase service inside the register_screen.dart file like so:

Widget _buildForm(BuildContext context) { final authProvider = Provider.of<AuthProvider>(context); final firestoreDatabase = Provider.of<FirestoreDatabase>(context, listen: false);

but got and error saying:
Could not find the correct Provider<FirestoreDatabase>

I believe this has something to do with the widget tree hierarchy and how the FirestoreDatabase is not above the register page but im not sure. Any suggestions?

Also a related question I have is FirestoreDatabase does not extend ChangeNotifier so how are we even able to use something like

Provider.of<FirestoreDatabase>(context, listen: false);

when FirestoreDatabase is not a real provider, it doesn't notify any changes? Can any regular class be pulled in with Provider.of ??

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.