Skip to content

Commit c191726

Browse files
Antonny SantosAntonny Santos
Antonny Santos
authored and
Antonny Santos
committedApr 24, 2023
First commit 🎉
0 parents  commit c191726

27 files changed

+497
-0
lines changed
 

‎.gitignore

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
migrate_working_dir/
12+
13+
# IntelliJ related
14+
*.iml
15+
*.ipr
16+
*.iws
17+
.idea/
18+
19+
# The .vscode folder contains launch configuration and tasks you configure in
20+
# VS Code which you may wish to be included in version control, so this line
21+
# is commented out by default.
22+
#.vscode/
23+
24+
# Flutter/Dart/Pub related
25+
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
26+
/pubspec.lock
27+
**/doc/api/
28+
.dart_tool/
29+
.packages
30+
build/

‎.metadata

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: 7048ed95a5ad3e43d697e0c397464193991fc230
8+
channel: stable
9+
10+
project_type: package

‎.vscode/launch.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "experiment_sdk_flutter",
9+
"request": "launch",
10+
"type": "dart"
11+
},
12+
{
13+
"name": "experiment_sdk_flutter (profile mode)",
14+
"request": "launch",
15+
"type": "dart",
16+
"flutterMode": "profile"
17+
},
18+
{
19+
"name": "experiment_sdk_flutter (release mode)",
20+
"request": "launch",
21+
"type": "dart",
22+
"flutterMode": "release"
23+
}
24+
]
25+
}

‎CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 0.0.1
2+
3+
* TODO: Describe initial release.

‎LICENSE

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TODO: Add your license here.

‎README.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!--
2+
This README describes the package. If you publish this package to pub.dev,
3+
this README's contents appear on the landing page for your package.
4+
5+
For information about how to write a good package README, see the guide for
6+
[writing package pages](https://dart.dev/guides/libraries/writing-package-pages).
7+
8+
For general information about developing packages, see the Dart guide for
9+
[creating packages](https://dart.dev/guides/libraries/create-library-packages)
10+
and the Flutter guide for
11+
[developing packages and plugins](https://flutter.dev/developing-packages).
12+
-->
13+
14+
TODO: Put a short description of the package here that helps potential users
15+
know whether this package might be useful for them.
16+
17+
## Features
18+
19+
TODO: List what your package can do. Maybe include images, gifs, or videos.
20+
21+
## Getting started
22+
23+
TODO: List prerequisites and provide or point to information on how to
24+
start using the package.
25+
26+
## Usage
27+
28+
TODO: Include short and useful examples for package users. Add longer examples
29+
to `/example` folder.
30+
31+
```dart
32+
const like = 'sample';
33+
```
34+
35+
## Additional information
36+
37+
TODO: Tell users more about the package: where to find more information, how to
38+
contribute to the package, how to file issues, what response they can expect
39+
from the package authors, and more.

‎analysis_options.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include: package:flutter_lints/flutter.yaml
2+
3+
# Additional information about this file can be found at
4+
# https://dart.dev/guides/language/analysis-options
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package io.flutter.plugins;
2+
3+
import io.flutter.plugin.common.PluginRegistry;
4+
5+
/**
6+
* Generated file. Do not edit.
7+
*/
8+
public final class GeneratedPluginRegistrant {
9+
public static void registerWith(PluginRegistry registry) {
10+
if (alreadyRegisteredWith(registry)) {
11+
return;
12+
}
13+
}
14+
15+
private static boolean alreadyRegisteredWith(PluginRegistry registry) {
16+
final String key = GeneratedPluginRegistrant.class.getCanonicalName();
17+
if (registry.hasPlugin(key)) {
18+
return true;
19+
}
20+
registry.registrarFor(key);
21+
return false;
22+
}
23+
}

‎android/local.properties

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sdk.dir=/Users/antonnysantos/Library/Android/sdk
2+
flutter.sdk=/Users/antonnysantos/Development/flutter

‎ios/Flutter/Generated.xcconfig

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// This is a generated file; do not edit or check into version control.
2+
FLUTTER_ROOT=/Users/antonnysantos/Development/flutter
3+
FLUTTER_APPLICATION_PATH=/Users/antonnysantos/Projects/product-minds/experiment_sdk_flutter
4+
COCOAPODS_PARALLEL_CODE_SIGN=true
5+
FLUTTER_TARGET=lib/main.dart
6+
FLUTTER_BUILD_DIR=build
7+
FLUTTER_BUILD_NAME=0.0.1
8+
FLUTTER_BUILD_NUMBER=0.0.1
9+
EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386
10+
EXCLUDED_ARCHS[sdk=iphoneos*]=armv7
11+
DART_OBFUSCATION=false
12+
TRACK_WIDGET_CREATION=true
13+
TREE_SHAKE_ICONS=false
14+
PACKAGE_CONFIG=.dart_tool/package_config.json
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
# This is a generated file; do not edit or check into version control.
3+
export "FLUTTER_ROOT=/Users/antonnysantos/Development/flutter"
4+
export "FLUTTER_APPLICATION_PATH=/Users/antonnysantos/Projects/product-minds/experiment_sdk_flutter"
5+
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
6+
export "FLUTTER_TARGET=lib/main.dart"
7+
export "FLUTTER_BUILD_DIR=build"
8+
export "FLUTTER_BUILD_NAME=0.0.1"
9+
export "FLUTTER_BUILD_NUMBER=0.0.1"
10+
export "DART_OBFUSCATION=false"
11+
export "TRACK_WIDGET_CREATION=true"
12+
export "TREE_SHAKE_ICONS=false"
13+
export "PACKAGE_CONFIG=.dart_tool/package_config.json"
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// Generated file. Do not edit.
3+
//
4+
5+
// clang-format off
6+
7+
#ifndef GeneratedPluginRegistrant_h
8+
#define GeneratedPluginRegistrant_h
9+
10+
#import <Flutter/Flutter.h>
11+
12+
NS_ASSUME_NONNULL_BEGIN
13+
14+
@interface GeneratedPluginRegistrant : NSObject
15+
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry;
16+
@end
17+
18+
NS_ASSUME_NONNULL_END
19+
#endif /* GeneratedPluginRegistrant_h */
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// Generated file. Do not edit.
3+
//
4+
5+
// clang-format off
6+
7+
#import "GeneratedPluginRegistrant.h"
8+
9+
@implementation GeneratedPluginRegistrant
10+
11+
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
12+
}
13+
14+
@end

‎lib/experiment_sdk_flutter.dart

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
library experiment_sdk_flutter;
2+
3+
import 'dart:convert';
4+
import 'dart:developer';
5+
import 'dart:io';
6+
import 'package:experiment_sdk_flutter/models/experiment_fetch_input.dart';
7+
import 'package:experiment_sdk_flutter/models/experiment_fetch_item.dart';
8+
import 'package:http/http.dart' as http;
9+
10+
/// A Calculator.
11+
class AmplitudeExperiment {
12+
final String apiKey;
13+
14+
final _baseUri = "api.lab.amplitude.com";
15+
final Map<String, FetchItem> _fetchResult = {};
16+
17+
/// Initialize SDK
18+
AmplitudeExperiment({required this.apiKey});
19+
20+
Future<void> fetch(
21+
{String? userId,
22+
String? deviceId,
23+
Map<String, dynamic>? userProperties}) async {
24+
final input = FetchInput(
25+
userId: userId, deviceId: deviceId, userProperties: userProperties);
26+
27+
final uri = Uri.https(_baseUri, '/v1/vardata', input.toJson());
28+
29+
final response = await http.get(uri,
30+
headers: {HttpHeaders.authorizationHeader: 'Api-Key $apiKey'});
31+
32+
if (response.statusCode == 200) {
33+
Map<String, dynamic> data =
34+
jsonDecode(const Utf8Decoder().convert(response.bodyBytes));
35+
36+
data.forEach((key, value) {
37+
_fetchResult[key] = FetchItem.fromMap(value);
38+
});
39+
} else {
40+
String data = response.body;
41+
42+
// If the server did not return a 200 OK response,
43+
// then throw an exception.
44+
throw Exception({
45+
'message': 'Failed to fetch through SDK!',
46+
'status': response.statusCode,
47+
'trace': data
48+
});
49+
}
50+
}
51+
52+
FetchItem? variant(String flagKey) {
53+
return _fetchResult[flagKey];
54+
}
55+
}
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class FetchInput {
2+
final String? userId;
3+
final String? deviceId;
4+
final Map<String, dynamic>? userProperties;
5+
6+
FetchInput({this.userId, this.deviceId, this.userProperties});
7+
8+
factory FetchInput.fromMap(Map<String, dynamic> map) {
9+
return FetchInput(
10+
userId: map['user_id'],
11+
deviceId: map['device_id'],
12+
userProperties: map['user_properies']);
13+
}
14+
15+
Map<String, dynamic> toJson() {
16+
return {
17+
'user_id': userId,
18+
'device_id': deviceId,
19+
'context': {'user_properties': userProperties.toString()}.toString()
20+
};
21+
}
22+
}

‎lib/models/experiment_fetch_item.dart

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class FetchItem {
2+
final String key;
3+
final Map<String, dynamic>? payload;
4+
5+
FetchItem({required this.key, this.payload});
6+
7+
factory FetchItem.fromMap(Map<String, dynamic> map) {
8+
return FetchItem(key: map['key'], payload: map['payload']);
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//
2+
// Generated file. Do not edit.
3+
//
4+
5+
// clang-format off
6+
7+
#include "generated_plugin_registrant.h"
8+
9+
10+
void fl_register_plugins(FlPluginRegistry* registry) {
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// Generated file. Do not edit.
3+
//
4+
5+
// clang-format off
6+
7+
#ifndef GENERATED_PLUGIN_REGISTRANT_
8+
#define GENERATED_PLUGIN_REGISTRANT_
9+
10+
#include <flutter_linux/flutter_linux.h>
11+
12+
// Registers Flutter plugins.
13+
void fl_register_plugins(FlPluginRegistry* registry);
14+
15+
#endif // GENERATED_PLUGIN_REGISTRANT_

‎linux/flutter/generated_plugins.cmake

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#
2+
# Generated file, do not edit.
3+
#
4+
5+
list(APPEND FLUTTER_PLUGIN_LIST
6+
)
7+
8+
list(APPEND FLUTTER_FFI_PLUGIN_LIST
9+
)
10+
11+
set(PLUGIN_BUNDLED_LIBRARIES)
12+
13+
foreach(plugin ${FLUTTER_PLUGIN_LIST})
14+
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
15+
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
16+
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
17+
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
18+
endforeach(plugin)
19+
20+
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
21+
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
22+
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
23+
endforeach(ffi_plugin)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//
2+
// Generated file. Do not edit.
3+
//
4+
5+
import FlutterMacOS
6+
import Foundation
7+
8+
9+
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// This is a generated file; do not edit or check into version control.
2+
FLUTTER_ROOT=/Users/antonnysantos/Development/flutter
3+
FLUTTER_APPLICATION_PATH=/Users/antonnysantos/Projects/product-minds/experiment_sdk_flutter
4+
COCOAPODS_PARALLEL_CODE_SIGN=true
5+
FLUTTER_BUILD_DIR=build
6+
FLUTTER_BUILD_NAME=0.0.1
7+
FLUTTER_BUILD_NUMBER=0.0.1
8+
DART_OBFUSCATION=false
9+
TRACK_WIDGET_CREATION=true
10+
TREE_SHAKE_ICONS=false
11+
PACKAGE_CONFIG=.dart_tool/package_config.json
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
# This is a generated file; do not edit or check into version control.
3+
export "FLUTTER_ROOT=/Users/antonnysantos/Development/flutter"
4+
export "FLUTTER_APPLICATION_PATH=/Users/antonnysantos/Projects/product-minds/experiment_sdk_flutter"
5+
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
6+
export "FLUTTER_BUILD_DIR=build"
7+
export "FLUTTER_BUILD_NAME=0.0.1"
8+
export "FLUTTER_BUILD_NUMBER=0.0.1"
9+
export "DART_OBFUSCATION=false"
10+
export "TRACK_WIDGET_CREATION=true"
11+
export "TREE_SHAKE_ICONS=false"
12+
export "PACKAGE_CONFIG=.dart_tool/package_config.json"

0 commit comments

Comments
 (0)
Please sign in to comment.