Skip to content

Commit

Permalink
Flutter analyze issues were fixed, fixed testing coverage , added git…
Browse files Browse the repository at this point in the history
…hub actions workflow
  • Loading branch information
al-af committed May 15, 2024
1 parent 95a4348 commit 7d5e68f
Show file tree
Hide file tree
Showing 13 changed files with 243 additions and 148 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/build-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build Android

on:
workflow_dispatch:

jobs:
build-android:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: 'latest'

- name: Install dependencies
run: |
cd example
flutter pub get
- name: Build APK
run: |
cd example
flutter build apk
30 changes: 30 additions & 0 deletions .github/workflows/build-ios.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build iOS

on:
workflow_dispatch:

jobs:
build-ios:
runs-on: macos-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies
run: |
cd example
flutter pub get
- name: Install CocoaPods
run: sudo gem install cocoapods

- name: Install Pods
run: |
cd example/ios
pod install --repo-update
- name: Build iOS app
run: |
cd example
flutter build ios --release --no-codesign
26 changes: 26 additions & 0 deletions .github/workflows/pluginQA.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Plugin QA

on:
push:
branches:
- releases/[0-9].x.x/[0-9].[0-9]+.x/[0-9].[0-9]+.[0-9]+-rc[0-9]+
- testWorkflow
- CI-Actions

jobs:
Run-Unit-Tests:
uses: ./.github/workflows/runTest.yml

Build-Sample-Apps-Android:
needs: [ Run-Unit-Tests ]
uses: ./.github/workflows/build-android.yml

Build-Sample-Apps-iOS:
needs: [ Run-Unit-Tests ]
uses: ./.github/workflows/build-ios.yml

Deploy-To-QA:
needs: [ Build-Sample-Apps-Android, Build-Sample-Apps-iOS ]
runs-on: ubuntu-latest
steps:
#need to add steps
21 changes: 21 additions & 0 deletions .github/workflows/runTest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Run Tests

on:
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install dependencies
run: flutter pub get

- name: Run tests
run: flutter test

- name: Analyze Flutter
run: flutter analyze
93 changes: 43 additions & 50 deletions example/lib/home_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'utils.dart';
class HomeContainer extends StatefulWidget {
final Map onData;
final Future<bool?> Function(String, Map) logEvent;
Object deepLinkData;
final Object deepLinkData;

HomeContainer({
required this.onData,
Expand Down Expand Up @@ -38,55 +38,48 @@ class _HomeContainerState extends State<HomeContainer> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
padding: EdgeInsets.all(20.0),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
color: Colors.blueGrey,
width: 0.5
),
borderRadius: BorderRadius.circular(5),
),child: Column(
children: [
Text(
"APPSFLYER SDK",
style: TextStyle(
fontSize: 18,
color: Colors.black,
fontWeight: FontWeight.w500,
),
),
SizedBox(height: AppConstants.TOP_PADDING),
TextBorder(
controller: TextEditingController(
text: widget.onData.isNotEmpty
? Utils.formatJson(widget.onData)
: "Waiting for conversion data...",
Container(
padding: EdgeInsets.all(20.0),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: Colors.blueGrey, width: 0.5),
borderRadius: BorderRadius.circular(5),
),
labelText: "CONVERSION DATA",
),
SizedBox(height: 12.0),
TextBorder(
controller: TextEditingController(
text: widget.deepLinkData != null
? Utils.formatJson(widget.deepLinkData)
: "Waiting for attribution data...",
child: Column(
children: [
Text(
"APPSFLYER SDK",
style: TextStyle(
fontSize: 18,
color: Colors.black,
fontWeight: FontWeight.w500,
),
),
SizedBox(height: AppConstants.TOP_PADDING),
TextBorder(
controller: TextEditingController(
text: widget.onData.isNotEmpty
? Utils.formatJson(widget.onData)
: "Waiting for conversion data...",
),
labelText: "CONVERSION DATA",
),
SizedBox(height: 12.0),
TextBorder(
controller: TextEditingController(
text: Utils.formatJson(widget.deepLinkData),
),
labelText: "ATTRIBUTION DATA",
),
],
),
labelText: "ATTRIBUTION DATA",
),
],
),
),
SizedBox(height: 12.0),
Container(
padding: EdgeInsets.all(20.0),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
color: Colors.blueGrey,
width: 0.5
),
border: Border.all(color: Colors.blueGrey, width: 0.5),
borderRadius: BorderRadius.circular(5),
),
child: Column(
Expand All @@ -102,23 +95,22 @@ class _HomeContainerState extends State<HomeContainer> {
SizedBox(height: 12.0),
TextBorder(
controller: TextEditingController(
text: "Event Name: $eventName\nEvent Values: $eventValues"
),
text:
"Event Name: $eventName\nEvent Values: $eventValues"),
labelText: "EVENT REQUEST",
),
SizedBox(height: 12.0),
TextBorder(
labelText: "SERVER RESPONSE",
controller: TextEditingController(
text: _logEventResponse
),
controller: TextEditingController(text: _logEventResponse),
),
SizedBox(height: 20.0),
ElevatedButton(
onPressed: () {
widget.logEvent(eventName, eventValues).then((onValue) {
setState(() {
_logEventResponse = "Event Status: " + onValue.toString();
_logEventResponse =
"Event Status: " + onValue.toString();
});
}).catchError((onError) {
setState(() {
Expand All @@ -129,7 +121,8 @@ class _HomeContainerState extends State<HomeContainer> {
child: Text("Trigger Purchase Event"),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white,
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
padding:
EdgeInsets.symmetric(horizontal: 20, vertical: 10),
textStyle: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16,
Expand All @@ -144,4 +137,4 @@ class _HomeContainerState extends State<HomeContainer> {
),
);
}
}
}
4 changes: 2 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Future<void> main() async {
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new MainPage(),
return MaterialApp(
home: MainPage(),
);
}
}
25 changes: 13 additions & 12 deletions example/lib/main_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:developer';
import 'dart:io';
import 'package:appsflyer_sdk/appsflyer_sdk.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -62,15 +63,15 @@ class MainPageState extends State<MainPage> {

// Conversion data callback
_appsflyerSdk.onInstallConversionData((res) {
print("onInstallConversionData res: " + res.toString());
log("onInstallConversionData res: $res");
setState(() {
_gcd = res;
});
});

// App open attribution callback
_appsflyerSdk.onAppOpenAttribution((res) {
print("onAppOpenAttribution res: " + res.toString());
log("onAppOpenAttribution res: $res");
setState(() {
_deepLinkData = res;
});
Expand All @@ -80,20 +81,20 @@ class MainPageState extends State<MainPage> {
_appsflyerSdk.onDeepLinking((DeepLinkResult dp) {
switch (dp.status) {
case Status.FOUND:
print(dp.deepLink?.toString());
print("deep link value: ${dp.deepLink?.deepLinkValue}");
log(dp.deepLink!.toString());
log("deep link value: ${dp.deepLink?.deepLinkValue}");
break;
case Status.NOT_FOUND:
print("deep link not found");
log("deep link not found");
break;
case Status.ERROR:
print("deep link error: ${dp.error}");
log("deep link error: ${dp.error}");
break;
case Status.PARSE_ERROR:
print("deep link status parsing error");
log("deep link status parsing error");
break;
}
print("onDeepLinking res: " + dp.toString());
log("onDeepLinking res: $dp");
setState(() {
_deepLinkData = dp.toJson();
});
Expand All @@ -110,7 +111,7 @@ class MainPageState extends State<MainPage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('AppsFlyer SDK example app'),
title: const Text('AppsFlyer SDK example app'),
centerTitle: true,
backgroundColor: Colors.green,
),
Expand All @@ -137,7 +138,7 @@ class MainPageState extends State<MainPage> {
},
);
},
child: Text("START SDK"),
child: const Text("START SDK"),
)
],
),
Expand All @@ -151,9 +152,9 @@ class MainPageState extends State<MainPage> {
bool? logResult;
try {
logResult = await _appsflyerSdk.logEvent(eventName, eventValues);
print("Event logged");
log("Event logged");
} catch (e) {
print("Failed to log event: $e");
log("Failed to log event: $e");
}
return logResult;
}
Expand Down
6 changes: 3 additions & 3 deletions example/lib/text_border.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class TextBorder extends StatelessWidget {
maxLines: null,
decoration: InputDecoration(
labelText: labelText,
labelStyle: TextStyle(color: Colors.blueGrey), // Change the color of the label
border: OutlineInputBorder(
labelStyle: const TextStyle(color: Colors.blueGrey), // Change the color of the label
border: const OutlineInputBorder(
borderSide: BorderSide(
width: 1.0
),
),
focusedBorder: OutlineInputBorder(
focusedBorder: const OutlineInputBorder(
borderSide: BorderSide(
width: 1.0
),
Expand Down
2 changes: 1 addition & 1 deletion example/lib/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'dart:convert';
class Utils {
static String formatJson(jsonObj) {
// ignore: prefer_final_locals
JsonEncoder encoder = new JsonEncoder.withIndent(' ');
JsonEncoder encoder = const JsonEncoder.withIndent(' ');
return encoder.convert(jsonObj);
}
}
1 change: 1 addition & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies:
flutter_dotenv: ^5.1.0

dev_dependencies:
flutter_lints: ^3.0.2
flutter_test:
sdk: flutter

Expand Down
1 change: 1 addition & 0 deletions lib/src/appsflyer_sdk.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
part of appsflyer_sdk;

class AppsflyerSdk {
// ignore: unused_field
EventChannel _eventChannel;
static AppsflyerSdk? _instance;
final MethodChannel _methodChannel;
Expand Down
Loading

0 comments on commit 7d5e68f

Please sign in to comment.