-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
snippets/install-flutterfire/ #881
Comments
You can wrap the whole host choosing part for the Android emulator in an assert block to remove it from the production build automatically. // Wrap in assert with an anonymous function that returns true to exclude it from production
assert((() {
// If on Android emulator, don't use localhost
String host = Platform.isAndroid ? '10.0.2.2:8080' : 'localhost:8080';
FirebaseFirestore.instance.settings = Settings(
host: host,
sslEnabled: false,
persistenceEnabled: false,
);
return true;
})()); |
I don't know if I missed a step, but the "Additional Superpowers" code snippets are invalid. For example, the analytics needs to be initialized, and the "automatic traces" for performance give an issue with unused import, etc. |
This snippet seems to "fix" the analytics initialization: import 'package:firebase_analytics/firebase_analytics.dart';
FirebaseAnalytics? analytics;
void main() {
analytics = FirebaseAnalytics.instance;
runApp(const MyApp());
} |
(Below applies to: Flutter 3.3.2, Google Services 4.3.3, and Firebase-Crashlytics-Gradle 2.9.0, as well as minSdkVersion 21 in your 'app-level' build.gradle) For simplicity, I call both the Firebase Analytics and Firebase Crashlytics via their own method:
The above can be successfully called only after Firebase initialization is successful (so, like once "snapshot.connectionState == ConnectionState.done" is true). If you're having issues with initializing any of the above - here's my entire main.dart:
|
Flutter Firebase App Setup for Power Users
How to setup a new Flutter project with Firebase, Firestore, Crashlytics, Analytics, and more.
https://fireship.io/snippets/install-flutterfire/
The text was updated successfully, but these errors were encountered: