Skip to content

Commit

Permalink
add Firebase related files to
Browse files Browse the repository at this point in the history
FlutterFireRemoteParameterFetcher example package
  • Loading branch information
riscait committed Nov 5, 2023
1 parent 732f8fe commit a53d3e7
Show file tree
Hide file tree
Showing 7 changed files with 257 additions and 3 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ unlinked_spec.ds
**/android/.settings
**/android/.project
**/android/service-account.json
**/android/app/google-services.json
**/android/app/src/main/res/mipmap*/
*.jks
*.keystore
Expand Down Expand Up @@ -104,8 +103,6 @@ unlinked_spec.ds
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/GoogleService-Info.plist
**/ios/firebase_app_id_file.json
**/ios/Flutter/.last_build_id
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
Expand Down
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Development

## Add new example package

```shell
flutter create -e \
--org jp.co.altive \
--project-name ${PACKAGE_NAME}_example \
packages/${PACKAGE_NAME}/example
```

### Add dependencies to package

```shell
flutter pub add firebase_core \
firebase_analytics \
'${PACKAGE_NAME}:{"path":"../"}' \
dev:altive_lints
```

### Configure FlutterFire

```shell
cd packages/${PACKAGE_NAME}/example
flutterfire configure
```

https://console.firebase.google.com/project/flutterfire-adapter

### Update analysis_options.yaml

```yaml
include: package:altive_lints/altive_lints.yaml
analyzer:
exclude:
- "lib/firebase_options.dart"
``````
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"project_info": {
"project_number": "282061201204",
"project_id": "flutterfire-adapter",
"storage_bucket": "flutterfire-adapter.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:282061201204:android:86708a3c3a298e18b04f61",
"android_client_info": {
"package_name": "jp.co.altive.flutterfireremoteparameterfetcher.example"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyC-QqWrVIJNsh-DOmV4OY4gVAi1jXW4e6s"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>API_KEY</key>
<string>AIzaSyDW2cbXfGjFB4EdKJTFojoAt_7wM-P10lg</string>
<key>GCM_SENDER_ID</key>
<string>282061201204</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>jp.co.altive.flutterfireremoteparameterfetcher.example</string>
<key>PROJECT_ID</key>
<string>flutterfire-adapter</string>
<key>STORAGE_BUCKET</key>
<string>flutterfire-adapter.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:282061201204:ios:0971ee1979644c5eb04f61</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"file_generated_by": "FlutterFire CLI",
"purpose": "FirebaseAppID & ProjectID for this Firebase app in this directory",
"GOOGLE_APP_ID": "1:282061201204:ios:6601d34e83ae0bb5b04f61",
"FIREBASE_PROJECT_ID": "flutterfire-adapter",
"GCM_SENDER_ID": "282061201204"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// 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;

/// 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) {
return web;
}
switch (defaultTargetPlatform) {
case TargetPlatform.android:
return android;
case TargetPlatform.iOS:
return ios;
case TargetPlatform.macOS:
return macos;
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 web = FirebaseOptions(
apiKey: 'AIzaSyAK_pKdPX1e3q5S-Q0CrtHPs7AH7_wkgUc',
appId: '1:282061201204:web:724b1f695c81679eb04f61',
messagingSenderId: '282061201204',
projectId: 'flutterfire-adapter',
authDomain: 'flutterfire-adapter.firebaseapp.com',
storageBucket: 'flutterfire-adapter.appspot.com',
);

static const FirebaseOptions android = FirebaseOptions(
apiKey: 'AIzaSyC-QqWrVIJNsh-DOmV4OY4gVAi1jXW4e6s',
appId: '1:282061201204:android:86708a3c3a298e18b04f61',
messagingSenderId: '282061201204',
projectId: 'flutterfire-adapter',
storageBucket: 'flutterfire-adapter.appspot.com',
);

static const FirebaseOptions ios = FirebaseOptions(
apiKey: 'AIzaSyDW2cbXfGjFB4EdKJTFojoAt_7wM-P10lg',
appId: '1:282061201204:ios:6601d34e83ae0bb5b04f61',
messagingSenderId: '282061201204',
projectId: 'flutterfire-adapter',
storageBucket: 'flutterfire-adapter.appspot.com',
iosBundleId: 'jp.co.altive.flutterfireremoteparameterfetcher.example',
);

static const FirebaseOptions macos = FirebaseOptions(
apiKey: 'AIzaSyDW2cbXfGjFB4EdKJTFojoAt_7wM-P10lg',
appId: '1:282061201204:ios:1b277bae5641209db04f61',
messagingSenderId: '282061201204',
projectId: 'flutterfire-adapter',
storageBucket: 'flutterfire-adapter.appspot.com',
iosBundleId: 'jp.co.altive.flutterfireremoteparameterfetcher.example.RunnerTests',
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutterfire_remote_parameter_fetcher/remote_parameter_fetcher.dart';

import 'firebase_options.dart';

Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
final rpf = RemoteParameterFetcher();
await rpf.setDefaults({
'int_parameter': 123,
});

runApp(MainApp(rpf: rpf));
}

class MainApp extends StatefulWidget {
const MainApp({super.key, required this.rpf});

final RemoteParameterFetcher rpf;

@override
State<MainApp> createState() => _MainAppState();
}

class _MainAppState extends State<MainApp> {
late final rpf = widget.rpf;

late final _intRemoteParameter = rpf.getIntParameter('int_parameter');

late int _intParameterValue;

void listen(int value) {
debugPrint('remoteParameter value changed: $value');
_intParameterValue = value;
}

@override
void initState() {
super.initState();
_intParameterValue = _intRemoteParameter.value;
_intRemoteParameter.addListener(listen);
}

@override
void dispose() {
// TODO(riscait): adding
// remoteParameter.removeListener(listen);
super.dispose();
}

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('FlutterFireRemoteParameterFetcher')),
body: ListView(
padding: const EdgeInsets.all(16),
children: [
Text('RemoteParameter value: $_intParameterValue'),
const SizedBox(height: 16),
FilledButton(
onPressed: () async {
await _intRemoteParameter.activateAndRefetch();
},
child: const Text('Activate and refetch'),
),
],
),
),
);
}
}

0 comments on commit a53d3e7

Please sign in to comment.