Skip to content

Commit

Permalink
Feat: Add flutter 3.22 support (#624)
Browse files Browse the repository at this point in the history
This patch adds support for Flutter 3.22.x without breaking
compatibility with versions 3.13.x, 3.16.x, and 3.19.x.
  • Loading branch information
andycall authored Jul 8, 2024
2 parents 4aa824f + f71b730 commit efe0664
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration_test_flutter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on: [workflow_dispatch, pull_request]
env:
nodeVersion: "16"
cmakeVersion: "3.22.x"
flutter: "3.19.3"
flutter: "3.22.2"

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand Down
2 changes: 1 addition & 1 deletion bridge/scripts/code_generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@types/lodash": "^4.14.172",
"@types/lodash": "4.14.172",
"@types/node": "16.9.2",
"commander": "^8.1.0",
"glob": "^7.1.7",
Expand Down
3 changes: 2 additions & 1 deletion integration_tests/lib/bridge/to_native.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ class _ExecuteTestContext {
_ExecuteTestContext(this.completer, this.profileOp);
}

void _handleExecuteTestResult(_ExecuteTestContext context, Pointer<NativeString> resultData) {
void _handleExecuteTestResult(Object handle, Pointer<NativeString> resultData) {
_ExecuteTestContext context = handle as _ExecuteTestContext;
String status = nativeStringToString(resultData);
context.completer.complete(status);

Expand Down
2 changes: 1 addition & 1 deletion integration_tests/macos/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
33CC10EC2044A3C60003C045 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
16 changes: 13 additions & 3 deletions integration_tests/spec_group.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,20 @@
]
},
{
"name": "TransformsAndAnimations",
"name": "Transforms",
"specs": [
"specs/css/css-transforms/**/*.{js,jsx,ts,tsx,html}"
]
},
{
"name": "Transitions",
"specs": [
"specs/css/css-transitions/**/*.{js,jsx,ts,tsx,html}"
]
},
{
"name": "Animations",
"specs": [
"specs/css/css-transforms/**/*.{js,jsx,ts,tsx,html}",
"specs/css/css-transitions/**/*.{js,jsx,ts,tsx,html}",
"specs/css/css-animations/**/*.{js,jsx,ts,tsx,html}"
]
},
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/specs/css/css-display/opacity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('Opacity', () => {
opacity: 0.5,
});

await snapshot();
await snapshot(0.5);
done();
});
});
Expand Down
2 changes: 1 addition & 1 deletion webf/example/macos/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "The Flutter Authors";
TargetAttributes = {
33CC10EC2044A3C60003C045 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
3 changes: 2 additions & 1 deletion webf/lib/src/bridge/binding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ Future<void> _dispatchCaptureEventToNative(Event event) async {
await _dispatchEventToNative(event, true);
}

void _handleDispatchResult(_DispatchEventResultContext context, Pointer<NativeValue> returnValue) {
void _handleDispatchResult(Object contextHandle, Pointer<NativeValue> returnValue) {
_DispatchEventResultContext context = contextHandle as _DispatchEventResultContext;
Pointer<EventDispatchResult> dispatchResult = fromNativeValue(context.controller.view, returnValue).cast<EventDispatchResult>();
Event event = context.event;
event.cancelable = dispatchResult.ref.canceled;
Expand Down
3 changes: 2 additions & 1 deletion webf/lib/src/bridge/from_native.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ class _InvokeModuleResultContext {
{this.errmsgPtr, this.data, this.stopwatch});
}

void _handleInvokeModuleResult(_InvokeModuleResultContext context, Pointer<NativeValue> result) {
void _handleInvokeModuleResult(Object handle, Pointer<NativeValue> result) {
_InvokeModuleResultContext context = handle as _InvokeModuleResultContext;
var returnValue = fromNativeValue(context.currentView, result);

if (enableWebFCommandLog && context.stopwatch != null) {
Expand Down
21 changes: 14 additions & 7 deletions webf/lib/src/bridge/to_native.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ typedef NativeInvokeModuleCallback = Void Function(Handle object, Pointer<Native
final DartInvokeEventListener _invokeModuleEvent =
WebFDynamicLibrary.ref.lookup<NativeFunction<NativeInvokeEventListener>>('invokeModuleEvent').asFunction();

void _invokeModuleCallback(_InvokeModuleCallbackContext context, Pointer<NativeValue> dispatchResult) {
void _invokeModuleCallback(Object handle, Pointer<NativeValue> dispatchResult) {
_InvokeModuleCallbackContext context = handle as _InvokeModuleCallbackContext;
dynamic result = fromNativeValue(context.controller.view, dispatchResult);
malloc.free(dispatchResult);
malloc.free(context.extraData);
Expand Down Expand Up @@ -272,7 +273,8 @@ class _EvaluateScriptsContext {
_EvaluateScriptsContext(this.completer, this.originalCodeBytes, this.codePtr, this.url, this.cacheKey);
}

void handleEvaluateScriptsResult(_EvaluateScriptsContext context, int result) {
void handleEvaluateScriptsResult(Object handle, int result) {
_EvaluateScriptsContext context = handle as _EvaluateScriptsContext;
if (context.bytecodes != null) {
Uint8List bytes = context.bytecodes!.value.asTypedList(context.bytecodeLen!.value);
// Save to disk cache
Expand Down Expand Up @@ -361,7 +363,8 @@ class _EvaluateQuickjsByteCodeContext {
_EvaluateQuickjsByteCodeContext(this.completer, this.bytes);
}

void handleEvaluateQuickjsByteCodeResult(_EvaluateQuickjsByteCodeContext context, int result) {
void handleEvaluateQuickjsByteCodeResult(Object handle, int result) {
_EvaluateQuickjsByteCodeContext context = handle as _EvaluateQuickjsByteCodeContext;
malloc.free(context.bytes);
context.completer.complete(result == 1);
}
Expand All @@ -385,7 +388,8 @@ Future<bool> evaluateQuickjsByteCode(double contextId, Uint8List bytes, { Evalua
return completer.future;
}

void _handleParseHTMLContextResult(_ParseHTMLContext context) {
void _handleParseHTMLContextResult(Object handle) {
_ParseHTMLContext context = handle as _ParseHTMLContext;
context.completer.complete();
}

Expand Down Expand Up @@ -466,7 +470,8 @@ class _DumpQuickjsByteCodeContext {
_DumpQuickjsByteCodeContext(this.completer, this.bytecodes, this.bytecodeLen);
}

void _handleQuickjsByteCodeResults(_DumpQuickjsByteCodeContext context) {
void _handleQuickjsByteCodeResults(Object handle) {
_DumpQuickjsByteCodeContext context = handle as _DumpQuickjsByteCodeContext;
Uint8List bytes = context.bytecodes.value.asTypedList(context.bytecodeLen.value);
context.completer.complete(bytes);
}
Expand Down Expand Up @@ -529,7 +534,8 @@ typedef DartDisposePageSync = void Function(double, Pointer<Void>, Pointer<Void>
final DartDisposePageSync _disposePageSync =
WebFDynamicLibrary.ref.lookup<NativeFunction<NativeDisposePageSync>>('disposePageSync').asFunction();

void _handleDisposePageResult(_DisposePageContext context) {
void _handleDisposePageResult(Object handle) {
_DisposePageContext context = handle as _DisposePageContext;
context.completer.complete();
}

Expand Down Expand Up @@ -578,7 +584,8 @@ final DartAllocateNewPageSync _allocateNewPageSync =
final DartAllocateNewPage _allocateNewPage =
WebFDynamicLibrary.ref.lookup<NativeFunction<NativeAllocateNewPage>>('allocateNewPage').asFunction();

void _handleAllocateNewPageResult(_AllocateNewPageContext context, Pointer<Void> page) {
void _handleAllocateNewPageResult(Object handle, Pointer<Void> page) {
_AllocateNewPageContext context = handle as _AllocateNewPageContext;
assert(!_allocatedPages.containsKey(context.contextId));
_allocatedPages[context.contextId] = page;
context.completer.complete();
Expand Down
4 changes: 4 additions & 0 deletions webf/lib/src/dom/sliver_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ class RenderSliverElementChildManager implements RenderSliverBoxChildManager {
final int remainingCount = childCount - lastIndex - 1;
return trailingScrollOffset + averageExtent * remainingCount;
}

@override
// TODO: add impl for estimatedChildCount
int? get estimatedChildCount => null;
}

/// Used for the placeholder for empty sliver item.
Expand Down
18 changes: 18 additions & 0 deletions webf/lib/src/launcher/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import 'package:flutter/animation.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart'
show RouteInformation, WidgetsBinding, WidgetsBindingObserver, AnimationController, BuildContext, View;
import 'package:webf/css.dart';
Expand Down Expand Up @@ -815,6 +816,23 @@ class WebFViewController implements WidgetsBindingObserver {
Future<ui.AppExitResponse> didRequestAppExit() async {
return ui.AppExitResponse.exit;
}

@override
void handleCancelBackGesture() {
}

@override
void handleCommitBackGesture() {
}

@override
bool handleStartBackGesture(backEvent) {
return true;
}

@override
void handleUpdateBackGestureProgress(backEvent) {
}
}

// An controller designed to control kraken's functional modules.
Expand Down

0 comments on commit efe0664

Please sign in to comment.