-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FlutterFireRemoteParameterFetcher example package
- Loading branch information
Showing
7 changed files
with
257 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
`````` |
29 changes: 29 additions & 0 deletions
29
packages/flutterfire_remote_parameter_fetcher/example/android/app/google-services.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
30 changes: 30 additions & 0 deletions
30
packages/flutterfire_remote_parameter_fetcher/example/ios/Runner/GoogleService-Info.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
7 changes: 7 additions & 0 deletions
7
packages/flutterfire_remote_parameter_fetcher/example/ios/firebase_app_id_file.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
80 changes: 80 additions & 0 deletions
80
packages/flutterfire_remote_parameter_fetcher/example/lib/firebase_options.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
); | ||
} |
74 changes: 74 additions & 0 deletions
74
packages/flutterfire_remote_parameter_fetcher/example/lib/main.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'), | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |