Skip to content

Commit

Permalink
Update dependencies to fix ABausG#102 and ABausG#117 (ABausG#132)
Browse files Browse the repository at this point in the history
* Update dependencies to fix ABausG#102 and ABausG#117

* Update example to fix integration tests

* Update Flutter

* Formatting

---------

Co-authored-by: Anton Borries <[email protected]>
  • Loading branch information
bradrushworth and ABausG authored May 13, 2023
1 parent 96ef734 commit ea1ad41
Show file tree
Hide file tree
Showing 16 changed files with 52 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Analyze
run: flutter analyze
- name: Format
run: flutter format . --set-exit-if-changed
run: dart format . --set-exit-if-changed
- name: Publishability
run: flutter pub publish --dry-run
- name: Test
Expand Down
8 changes: 4 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ group 'es.antonborri.home_widget'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.5.10'
ext.kotlin_version = '1.8.0'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.0.3'
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -25,7 +25,7 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 31
compileSdkVersion 33

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -39,5 +39,5 @@ android {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
4 changes: 2 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 31
compileSdkVersion 33

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -40,7 +40,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "es.antonborri.home_widget_example"
minSdkVersion 16
targetSdkVersion 31
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down
6 changes: 3 additions & 3 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.5.20'
ext.kotlin_version = '1.8.0'
repositories {
google()
mavenCentral()
}

dependencies {
classpath "com.android.tools.build:gradle:7.0.3"
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Nov 20 22:03:31 CET 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
2 changes: 1 addition & 1 deletion example/integration_test/android_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ void main() {
});
}

void backgroundCallback(Uri uri) {}
void backgroundCallback(Uri? uri) {}
2 changes: 1 addition & 1 deletion example/integration_test/ios_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ void main() {
});
}

void backgroundCallback(Uri uri) {}
void backgroundCallback(Uri? uri) {}
5 changes: 4 additions & 1 deletion example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 51;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -292,10 +292,12 @@
/* Begin PBXShellScriptBuildPhase section */
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
Expand Down Expand Up @@ -323,6 +325,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down
2 changes: 2 additions & 0 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,7 @@
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
18 changes: 9 additions & 9 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'package:workmanager/workmanager.dart';
void callbackDispatcher() {
Workmanager().executeTask((taskName, inputData) {
final now = DateTime.now();
return Future.wait<bool>([
return Future.wait<bool?>([
HomeWidget.saveWidgetData(
'title',
'Updated from Background',
Expand All @@ -34,10 +34,10 @@ void callbackDispatcher() {

/// Called when Doing Background Work initiated from Widget
@pragma("vm:entry-point")
void backgroundCallback(Uri data) async {
void backgroundCallback(Uri? data) async {
print(data);

if (data.host == 'titleclicked') {
if (data?.host == 'titleclicked') {
final greetings = [
'Hello',
'Hallo',
Expand Down Expand Up @@ -92,7 +92,7 @@ class _MyAppState extends State<MyApp> {
super.dispose();
}

Future<void> _sendData() async {
Future _sendData() async {
try {
return Future.wait([
HomeWidget.saveWidgetData<String>('title', _titleController.text),
Expand All @@ -103,7 +103,7 @@ class _MyAppState extends State<MyApp> {
}
}

Future<void> _updateWidget() async {
Future _updateWidget() async {
try {
return HomeWidget.updateWidget(
name: 'HomeWidgetExampleProvider', iOSName: 'HomeWidgetExample');
Expand All @@ -112,14 +112,14 @@ class _MyAppState extends State<MyApp> {
}
}

Future<void> _loadData() async {
Future _loadData() async {
try {
return Future.wait([
HomeWidget.getWidgetData<String>('title', defaultValue: 'Default Title')
.then((value) => _titleController.text = value),
.then((value) => _titleController.text = value ?? ''),
HomeWidget.getWidgetData<String>('message',
defaultValue: 'Default Message')
.then((value) => _messageController.text = value),
.then((value) => _messageController.text = value ?? ''),
]);
} on PlatformException catch (exception) {
debugPrint('Error Getting Data. $exception');
Expand All @@ -135,7 +135,7 @@ class _MyAppState extends State<MyApp> {
HomeWidget.initiallyLaunchedFromHomeWidget().then(_launchedFromWidget);
}

void _launchedFromWidget(Uri uri) {
void _launchedFromWidget(Uri? uri) {
if (uri != null) {
showDialog(
context: context,
Expand Down
4 changes: 2 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Demonstrates how to use the home_widget plugin.
publish_to: 'none'

environment:
sdk: ">=2.7.0 <3.0.0"
sdk: ">=2.12.0 <4.0.0"

dependencies:
flutter:
Expand All @@ -17,7 +17,7 @@ dependencies:
home_widget:
path: ../

cupertino_icons: ^0.1.3
cupertino_icons: ^1.0.5

dev_dependencies:
integration_test:
Expand Down
27 changes: 0 additions & 27 deletions example/test/widget_test.dart

This file was deleted.

6 changes: 3 additions & 3 deletions lib/home_widget_callback_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import 'package:flutter/services.dart';
/// Dispatcher used for calling dart code from Native Code while in the background
@pragma("vm:entry-point")
void callbackDispatcher() {
const _backgroundChannel = MethodChannel('home_widget/background');
const backgroundChannel = MethodChannel('home_widget/background');
WidgetsFlutterBinding.ensureInitialized();

_backgroundChannel.setMethodCallHandler((call) async {
backgroundChannel.setMethodCallHandler((call) async {
final args = call.arguments;

final callback = PluginUtilities.getCallbackFromHandle(
Expand All @@ -23,5 +23,5 @@ void callbackDispatcher() {
callback?.call(uri);
});

_backgroundChannel.invokeMethod('HomeWidget.backgroundInitialized');
backgroundChannel.invokeMethod('HomeWidget.backgroundInitialized');
}
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 0.2.0+1
repository: https://github.com/ABausG/home_widget

environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.12.0 <4.0.0'
flutter: ">=1.17.0"

dependencies:
Expand All @@ -14,7 +14,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.4
flutter_lints: ^2.0.1

flutter:
plugin:
Expand Down
10 changes: 6 additions & 4 deletions test/background_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ void main() {
PluginUtilities.getCallbackHandle(testCallback)?.toRawHandle();
const testUri = 'homeWidget://homeWidgetTest';

// ignore: body_might_complete_normally_nullable
backgroundChannel.setMockMethodCallHandler((call) {
tester.binding.defaultBinaryMessenger
// ignore: body_might_complete_normally_nullable
.setMockMethodCallHandler(backgroundChannel, (call) {
if (call.method == 'HomeWidget.backgroundInitialized') {
emitEvent(
tester,
backgroundChannel.codec
.encodeMethodCall(MethodCall('', [callbackHandle, testUri])),
);
Expand All @@ -32,8 +34,8 @@ void main() {
});
}

void emitEvent(ByteData? event) {
backgroundChannel.binaryMessenger.handlePlatformMessage(
void emitEvent(WidgetTester tester, ByteData? event) {
tester.binding.defaultBinaryMessenger.handlePlatformMessage(
backgroundChannel.name,
event,
(ByteData? reply) {},
Expand Down
17 changes: 11 additions & 6 deletions test/home_widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ void main() {
setUp(() {
launchUri = null;
passedArguments = Completer();
channel.setMockMethodCallHandler((MethodCall methodCall) async {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
// ignore: body_might_complete_normally_nullable
.setMockMethodCallHandler(channel, (MethodCall methodCall) async {
passedArguments.complete(methodCall.arguments);
switch (methodCall.method) {
case 'saveWidgetData':
Expand All @@ -41,7 +43,8 @@ void main() {
});

tearDown(() {
channel.setMockMethodCallHandler(null);
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(channel, null);
});

test('getWidgetData', () async {
Expand Down Expand Up @@ -140,9 +143,10 @@ void main() {

group('Widget Clicked', () {
test('Send Uris to Stream', () async {
updateChannel.binaryMessenger.setMockMessageHandler(updateChannel.name,
// ignore: body_might_complete_normally_nullable
(message) async {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMessageHandler(updateChannel.name,
// ignore: body_might_complete_normally_nullable
(message) async {
emitEvent(
updateChannel.codec
.encodeSuccessEnvelope('homeWidget://homeWidgetTest'),
Expand All @@ -166,7 +170,8 @@ void main() {
}

void emitEvent(ByteData? event) {
updateChannel.binaryMessenger.handlePlatformMessage(
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.handlePlatformMessage(
updateChannel.name,
event,
(ByteData? reply) {},
Expand Down

0 comments on commit ea1ad41

Please sign in to comment.