Skip to content

Commit

Permalink
feat: 适配null safety
Browse files Browse the repository at this point in the history
  • Loading branch information
CaicaiNo committed Oct 12, 2021
1 parent fd85431 commit b2ef62a
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 31 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.7.0

* 适配Null Safety

## 0.0.1
## iOS 2.6.6
* TODO: Describe initial release.


13 changes: 6 additions & 7 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 27
compileSdkVersion 30

lintOptions {
disable 'InvalidPackage'
Expand All @@ -34,11 +34,10 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.growingio.plugin.fluttergrowingiotrackexample"
minSdkVersion 16
targetSdkVersion 27
minSdkVersion 17
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

resValue("string", "growingio_project_id", "9926fc6c1189e2fb")
resValue("string", "growingio_url_scheme", "growing.da7e6c2879469314")
Expand All @@ -58,8 +57,8 @@ flutter {
}

dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// testImplementation 'junit:junit:4.12'
// androidTestImplementation 'com.android.support.test:runner:1.0.2'
// androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.growingio.android:vds-android-agent:track-2.6.0'
}
6 changes: 5 additions & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
buildscript {
repositories {
google()
mavenCentral()
jcenter()
maven { url "https://s01.oss.sonatype.org/content/repositories/snapshots/" }
}

dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.android.tools.build:gradle:4.2.2'
}
}

allprojects {
repositories {
google()
mavenCentral()
jcenter()
maven { url "https://s01.oss.sonatype.org/content/repositories/snapshots/" }
}
}

Expand Down
2 changes: 2 additions & 0 deletions example/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
13 changes: 8 additions & 5 deletions example/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Users/growingio/Desktop/GIO/Flutter/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/growingio/Desktop/GIO/flutter_growingio-track_2.6.3/flutter-growingio-track/example"
export "FLUTTER_TARGET=/Users/growingio/Desktop/GIO/flutter_growingio-track_2.6.3/flutter-growingio-track/example/lib/main.dart"
export "FLUTTER_ROOT=/Users/sheng/GrowIO/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/sheng/GrowIO/git-public/flutter-growingio-track/example"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
export "FLUTTER_FRAMEWORK_DIR=/Users/growingio/Desktop/GIO/Flutter/flutter/bin/cache/artifacts/engine/ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "TRACK_WIDGET_CREATION=true"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=false"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.packages"
11 changes: 8 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class MyButton extends StatelessWidget {
final String text;

const MyButton({
Key key,
@required this.text,
@required this.onPressed
Key? key,
required this.text,
required this.onPressed
}): super(key: key);

@override
Expand Down Expand Up @@ -54,6 +54,7 @@ class _MyAppState extends State<MyApp> {
}

void _clickTrack(){
GrowingIO.track(null);
GrowingIO.track('eventId');
GrowingIO.track('testEventId', num: 23.0, variable: {'testKey': 'testValue', 'testNumKey': 233});
GrowingIO.track('eventId', num: 23.0);
Expand All @@ -64,23 +65,27 @@ class _MyAppState extends State<MyApp> {
GrowingIO.setEvar({
'testKey': 'testValue', 'testNumKey': 2333.0
});
GrowingIO.setEvar(null);
}

void _clickSetPeopleVariable(){
GrowingIO.setPeopleVariable(null);
GrowingIO.setPeopleVariable({
'testKey': 'testValue', 'testNumKey': 2333.0
});
}

void _clickSetUserId(){
GrowingIO.setUserId("testUserId");
GrowingIO.setUserId(null);
}

void _clickClearUserId(){
GrowingIO.clearUserId();
}

void _clickSetVisitor(){
GrowingIO.setVisitor(null);
GrowingIO.setVisitor({
"visitorKey": 'key', "visitorValue": 34
});
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description: Demonstrates how to use the flutter_growingio_track plugin.
version: 1.0.0+1

environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
sdk: ">=2.12.0 <3.0.0"

dependencies:
flutter:
Expand Down
18 changes: 11 additions & 7 deletions lib/flutter_growingio_track.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import 'dart:async';

import 'package:flutter/services.dart';

class GrowingIO {
static const MethodChannel _channel =
const MethodChannel('flutter_growingio_track');

static Future<Null> track(String eventId,
{double num, Map<String, dynamic> variable}) async {
static Future<Null> track(String? eventId,
{double? num, Map<String, dynamic>? variable}) async {
if (eventId == null) return;
Map<String, dynamic> args = {"eventId": eventId};
if (num != null) {
args['num'] = num;
Expand All @@ -18,23 +18,27 @@ class GrowingIO {
return await _channel.invokeMethod("track", args);
}

static Future<Null> setEvar(Map<String, dynamic> variable) async {
static Future<Null> setEvar(Map<String, dynamic>? variable) async {
if (variable == null) return;
return await _channel.invokeMethod("setEvar", variable);
}

static Future<Null> setPeopleVariable(Map<String, dynamic> variable) async {
static Future<Null> setPeopleVariable(Map<String, dynamic>? variable) async {
if (variable == null) return;
return await _channel.invokeMethod("setPeopleVariable", variable);
}

static Future<Null> setUserId(String userId) async {
static Future<Null> setUserId(String? userId) async {
if (userId == null) return;
return await _channel.invokeMethod("setUserId", {"userId": userId});
}

static Future<Null> clearUserId() async {
return await _channel.invokeMethod("clearUserId");
}

static Future<Null> setVisitor(Map<String, dynamic> variable) async {
static Future<Null> setVisitor(Map<String, dynamic>? variable) async {
if (variable == null) return;
return await _channel.invokeMethod("setVisitor", variable);
}
}
8 changes: 4 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: flutter_growingio_track
description: Flutter Plugin For GrowingIO SDK, is used for calling GrowingIO api in flutter.
version: 2.6.6
description: Flutter Plugin For GrowingIO SDK, is used for calling GrowingIO api in flutter.
version: 2.7.0
homepage: https://github.com/growingio/flutter-growingio-track

environment:
sdk: ">=2.0.0 <3.0.0"
flutter: ">=1.10.0 <2.0.0"
sdk: ">=2.12.0 <3.0.0"
flutter: ">=1.20.0"

dependencies:
flutter:
Expand Down

0 comments on commit b2ef62a

Please sign in to comment.