diff --git a/.gitignore b/.gitignore index 908b165..d0c6d98 100644 --- a/.gitignore +++ b/.gitignore @@ -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 @@ -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 diff --git a/README.md b/README.md new file mode 100644 index 0000000..b446541 --- /dev/null +++ b/README.md @@ -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" +`````` \ No newline at end of file diff --git a/packages/flutterfire_remote_parameter_fetcher/example/android/app/google-services.json b/packages/flutterfire_remote_parameter_fetcher/example/android/app/google-services.json new file mode 100644 index 0000000..304dff6 --- /dev/null +++ b/packages/flutterfire_remote_parameter_fetcher/example/android/app/google-services.json @@ -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" +} \ No newline at end of file diff --git a/packages/flutterfire_remote_parameter_fetcher/example/ios/Runner/GoogleService-Info.plist b/packages/flutterfire_remote_parameter_fetcher/example/ios/Runner/GoogleService-Info.plist new file mode 100644 index 0000000..0a77073 --- /dev/null +++ b/packages/flutterfire_remote_parameter_fetcher/example/ios/Runner/GoogleService-Info.plist @@ -0,0 +1,30 @@ + + + + + API_KEY + AIzaSyDW2cbXfGjFB4EdKJTFojoAt_7wM-P10lg + GCM_SENDER_ID + 282061201204 + PLIST_VERSION + 1 + BUNDLE_ID + jp.co.altive.flutterfireremoteparameterfetcher.example + PROJECT_ID + flutterfire-adapter + STORAGE_BUCKET + flutterfire-adapter.appspot.com + IS_ADS_ENABLED + + IS_ANALYTICS_ENABLED + + IS_APPINVITE_ENABLED + + IS_GCM_ENABLED + + IS_SIGNIN_ENABLED + + GOOGLE_APP_ID + 1:282061201204:ios:0971ee1979644c5eb04f61 + + \ No newline at end of file diff --git a/packages/flutterfire_remote_parameter_fetcher/example/ios/firebase_app_id_file.json b/packages/flutterfire_remote_parameter_fetcher/example/ios/firebase_app_id_file.json new file mode 100644 index 0000000..c2bb2bc --- /dev/null +++ b/packages/flutterfire_remote_parameter_fetcher/example/ios/firebase_app_id_file.json @@ -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" +} \ No newline at end of file diff --git a/packages/flutterfire_remote_parameter_fetcher/example/lib/firebase_options.dart b/packages/flutterfire_remote_parameter_fetcher/example/lib/firebase_options.dart new file mode 100644 index 0000000..4e163ef --- /dev/null +++ b/packages/flutterfire_remote_parameter_fetcher/example/lib/firebase_options.dart @@ -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', + ); +} diff --git a/packages/flutterfire_remote_parameter_fetcher/example/lib/main.dart b/packages/flutterfire_remote_parameter_fetcher/example/lib/main.dart new file mode 100644 index 0000000..f8d67e9 --- /dev/null +++ b/packages/flutterfire_remote_parameter_fetcher/example/lib/main.dart @@ -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 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 createState() => _MainAppState(); +} + +class _MainAppState extends State { + 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'), + ), + ], + ), + ), + ); + } +}