Skip to content

Commit

Permalink
Remove Firebase options from git-crypt
Browse files Browse the repository at this point in the history
  • Loading branch information
Xennis committed Feb 7, 2025
1 parent 2cd237e commit 7ac1112
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 1 deletion.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,12 @@ Build the app
```shell
flutter build <platform> --dart-define MAPBOX_ACCESS_TOKEN=...
```

Copy the Firebase config from https://console.firebase.google.com/project/<project-id>/settings/general/ and use it the same way:

```shell
--dart-define FIREBASE_API_KEY=...
--dart-define FIREBASE_APP_ID=....
--dart-define FIREBASE_MESSAGING_SENDER_ID=...
--dart-define FIREBASE_PROJECT_ID=...
```
7 changes: 7 additions & 0 deletions green_walking/lib/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ class CustomMapboxStyles {
static const String outdoor = 'mapbox://styles/xennis/ckfbioyul1iln1ap0pm5hrcgy';
static const String satellite = 'mapbox://styles/xennis/ckfc5mxh33tjg19qvk6m5f5hj';
}

// env
const mapboxAccessToken = String.fromEnvironment("MAPBOX_ACCESS_TOKEN");
const firebaseApiKey = String.fromEnvironment("FIREBASE_API_KEY");
const firebaseAppId = String.fromEnvironment("FIREBASE_APP_ID");
const firebaseMessagingSenderId = String.fromEnvironment("FIREBASE_MESSAGING_SENDER_ID");
const firebaseProjectId = String.fromEnvironment("FIREBASE_PROJECT_ID");
62 changes: 62 additions & 0 deletions green_walking/lib/firebase_options.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// File generated by FlutterFire CLI.
// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb, TargetPlatform;

import 'config.dart';

/// Default [FirebaseOptions] for use with your Firebase apps.
///
/// Example:
/// ```dart
/// import 'firebase_options.dart';
/// // ...
/// await Firebase.initializeApp(
/// options: DefaultFirebaseOptions.currentPlatform,
/// );
/// ```
class DefaultFirebaseOptions {
static FirebaseOptions get currentPlatform {
if (kIsWeb) {
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for web - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
}
switch (defaultTargetPlatform) {
case TargetPlatform.android:
return android;
case TargetPlatform.iOS:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for ios - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
case TargetPlatform.macOS:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for macos - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
case TargetPlatform.windows:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for windows - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
case TargetPlatform.linux:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for linux - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
default:
throw UnsupportedError(
'DefaultFirebaseOptions are not supported for this platform.',
);
}
}

static const FirebaseOptions android = FirebaseOptions(
apiKey: firebaseApiKey,
appId: firebaseAppId,
messagingSenderId: firebaseMessagingSenderId,
projectId: firebaseProjectId,
);
}
3 changes: 2 additions & 1 deletion green_walking/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart';
import 'package:provider/provider.dart';

import 'config.dart';
import 'firebase_options.dart';
import 'provider/prefs_provider.dart';
import 'routes.dart';
Expand All @@ -19,7 +20,7 @@ Future<void> main() async {
// Pass all uncaught errors from the framework to Crashlytics.
FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterError;

MapboxOptions.setAccessToken(const String.fromEnvironment("MAPBOX_ACCESS_TOKEN"));
MapboxOptions.setAccessToken(mapboxAccessToken);

runApp(const GreenWalkingApp());
}
Expand Down

0 comments on commit 7ac1112

Please sign in to comment.