update dart and flutter version

This commit is contained in:
wgh19
2024-04-17 20:55:23 +08:00
parent 32aac42c19
commit bfa25c4b83
13 changed files with 505 additions and 266 deletions

View File

@@ -6,7 +6,6 @@
* @LastEditTime: 2020-08-02 12:39:26
*/
import 'dart:math';
import 'dart:ui';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_highlight/themes/a11y-light.dart';
@@ -30,16 +29,16 @@ List<TextSpan> _convert(String code) {
stack.add(currentSpans);
currentSpans = tmp;
node.children.forEach((n) {
node.children!.forEach((n) {
_traverse(n);
if (n == node.children.last) {
if (n == node.children!.last) {
currentSpans = stack.isEmpty ? spans : stack.removeLast();
}
});
}
}
for (var node in nodes) {
for (var node in nodes!) {
_traverse(node);
}
@@ -47,18 +46,19 @@ List<TextSpan> _convert(String code) {
}
class CodeInputController extends TextEditingController {
CodeInputController({String text}) : super(text: text);
CodeInputController({required String text}) : super(text: text);
TextSpan oldSpan = TextSpan();
Future<void> spanCall;
Future<void>? spanCall;
@override
TextSpan buildTextSpan(
{@required BuildContext context, TextStyle style, bool withComposing}) {
{required BuildContext context, TextStyle? style,
bool? withComposing}) {
String oldText = oldSpan.toPlainText();
String newText = value.text;
if (oldText == newText) return oldSpan;
(spanCall?.timeout(Duration.zero) ?? Future.value())
spanCall?.timeout(Duration.zero)
.then((_) => spanCall = compute(_convert, value.text).then((lsSpan) {
TextSpan newSpan = TextSpan(style: style, children: lsSpan);
if (newSpan.toPlainText() == value.text) oldSpan = newSpan;
@@ -70,7 +70,7 @@ class CodeInputController extends TextEditingController {
int splitAt = value.selection.start;
if (splitAt < 0) splitAt = newText.length ~/ 2;
int start = 0;
InlineSpan leftSpan;
InlineSpan? leftSpan;
oldSpan.children?.indexWhere((element) {
String elementText = element.toPlainText();
if (start + elementText.length > splitAt ||
@@ -78,14 +78,14 @@ class CodeInputController extends TextEditingController {
leftSpan = element;
return true;
}
beforeSpans.add(element);
beforeSpans.add(element as TextSpan);
start += elementText.length;
return false;
});
List<TextSpan> endSpans = [];
int end = 0;
InlineSpan rightSpan;
oldSpan.children?.sublist(beforeSpans.length)?.lastIndexWhere((element) {
InlineSpan? rightSpan;
oldSpan.children?.sublist(beforeSpans.length).lastIndexWhere((element) {
String elementText = element.toPlainText();
if (splitAt + end + elementText.length >= newText.length ||
!newText
@@ -94,7 +94,7 @@ class CodeInputController extends TextEditingController {
rightSpan = element;
return true;
}
endSpans.add(element);
endSpans.add(element as TextSpan);
end += elementText.length;
return false;
});
@@ -102,8 +102,8 @@ class CodeInputController extends TextEditingController {
return TextSpan(style: style, children: [
...beforeSpans,
TextSpan(
style: leftSpan != null && leftSpan == rightSpan
? leftSpan.style
style: leftSpan != null && leftSpan == rightSpan!
? leftSpan!.style
: style,
text: newText.substring(start, max(start, newText.length - end))),
...endSpans.reversed

View File

@@ -17,7 +17,7 @@ void main() {
}
class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
@@ -25,9 +25,9 @@ class MyApp extends StatelessWidget {
title: 'flutter_qjs',
debugShowCheckedModeBanner: false,
theme: ThemeData(
appBarTheme: AppBarTheme(brightness: Brightness.dark, elevation: 0),
backgroundColor: Colors.grey[300],
primaryColorBrightness: Brightness.dark,
brightness: Brightness.dark,
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue, brightness: Brightness.dark),
useMaterial3: true
),
routes: {
'home': (BuildContext context) => TestPage(),
@@ -43,8 +43,8 @@ class TestPage extends StatefulWidget {
}
class _TestPageState extends State<TestPage> {
String resp;
IsolateQjs engine;
String? resp;
IsolateQjs? engine;
CodeInputController _controller = CodeInputController(
text: 'import("hello").then(({default: greet}) => greet("world"));');
@@ -79,7 +79,7 @@ class _TestPageState extends State<TestPage> {
onPressed: () async {
await _ensureEngine();
try {
resp = (await engine.evaluate(_controller.text ?? '',
resp = (await engine!.evaluate(_controller.text,
name: "<eval>"))
.toString();
} catch (e) {
@@ -91,7 +91,7 @@ class _TestPageState extends State<TestPage> {
child: Text("reset engine"),
onPressed: () async {
if (engine == null) return;
await engine.close();
await engine!.close();
engine = null;
}),
],

View File

@@ -2,6 +2,8 @@
// Generated file. Do not edit.
//
// clang-format off
#include "generated_plugin_registrant.h"
#include <flutter_qjs/flutter_qjs_plugin.h>

View File

@@ -2,6 +2,8 @@
// Generated file. Do not edit.
//
// clang-format off
#ifndef GENERATED_PLUGIN_REGISTRANT_
#define GENERATED_PLUGIN_REGISTRANT_

View File

@@ -6,6 +6,9 @@ list(APPEND FLUTTER_PLUGIN_LIST
flutter_qjs
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST
)
set(PLUGIN_BUNDLED_LIBRARIES)
foreach(plugin ${FLUTTER_PLUGIN_LIST})
@@ -14,3 +17,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin)
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)

View File

@@ -5,56 +5,56 @@ packages:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev"
source: hosted
version: "2.8.2"
version: "2.11.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
version: "2.1.1"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
version: "1.3.0"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
url: "https://pub.dev"
source: hosted
version: "1.1.0"
version: "1.1.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.15.0"
version: "1.18.0"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
version: "1.3.1"
ffi:
dependency: transitive
description:
name: ffi
url: "https://pub.dartlang.org"
sha256: "35d0f481d939de0d640b3db9a7aa36a52cd22054a798a73b4f50bdad5ce12678"
url: "https://pub.dev"
source: hosted
version: "1.1.2"
flutter:
@@ -66,9 +66,10 @@ packages:
dependency: "direct main"
description:
name: flutter_highlight
url: "https://pub.dartlang.org"
sha256: "7b96333867aa07e122e245c033b8ad622e4e3a42a1a2372cbb098a2541d8782c"
url: "https://pub.dev"
source: hosted
version: "0.6.0"
version: "0.7.0"
flutter_qjs:
dependency: "direct main"
description:
@@ -85,37 +86,66 @@ packages:
dependency: "direct main"
description:
name: highlight
url: "https://pub.dartlang.org"
sha256: "5353a83ffe3e3eca7df0abfb72dcf3fa66cc56b953728e7113ad4ad88497cf21"
url: "https://pub.dev"
source: hosted
version: "0.6.0"
version: "0.7.0"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
url: "https://pub.dev"
source: hosted
version: "10.0.0"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
url: "https://pub.dev"
source: hosted
version: "2.0.1"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
url: "https://pub.dev"
source: hosted
version: "2.0.1"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.dev"
source: hosted
version: "0.12.11"
version: "0.12.16+1"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
url: "https://pub.dev"
source: hosted
version: "0.1.4"
version: "0.8.0"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
url: "https://pub.dev"
source: hosted
version: "1.7.0"
version: "1.11.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
version: "1.8.1"
version: "1.9.0"
sky_engine:
dependency: transitive
description: flutter
@@ -125,58 +155,66 @@ packages:
dependency: transitive
description:
name: source_span
url: "https://pub.dartlang.org"
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.8.2"
version: "1.10.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.10.0"
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.0"
version: "2.1.2"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
version: "1.2.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
url: "https://pub.dev"
source: hosted
version: "1.2.0"
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
version: "0.4.9"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "0.6.1"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
version: "2.1.4"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
url: "https://pub.dev"
source: hosted
version: "13.0.0"
sdks:
dart: ">=2.14.0 <3.0.0"
flutter: ">=1.20.0"
dart: ">=3.2.0-0 <4.0.0"
flutter: ">=3.0.0"

View File

@@ -6,7 +6,7 @@ description: Demonstrates how to use the flutter_qjs plugin.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
environment:
sdk: ">=2.7.0 <3.0.0"
sdk: ">=3.0.0"
dependencies:
flutter:
@@ -20,8 +20,8 @@ dependencies:
# the parent directory to use the current plugin's version.
path: ../
highlight: 0.6.0
flutter_highlight: 0.6.0
highlight: any
flutter_highlight: any
dev_dependencies:
flutter_test:

View File

@@ -10,6 +10,11 @@ include(${EPHEMERAL_DIR}/generated_config.cmake)
# https://github.com/flutter/flutter/issues/57146.
set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
# Set fallback configurations for older versions of the flutter tool.
if (NOT DEFINED FLUTTER_TARGET_PLATFORM)
set(FLUTTER_TARGET_PLATFORM "windows-x64")
endif()
# === Flutter Library ===
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
@@ -92,7 +97,7 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E env
${FLUTTER_TOOL_ENVIRONMENT}
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
windows-x64 $<CONFIG>
${FLUTTER_TARGET_PLATFORM} $<CONFIG>
VERBATIM
)
add_custom_target(flutter_assemble DEPENDS

View File

@@ -20,6 +20,13 @@ add_executable(${BINARY_NAME} WIN32
# that need different build settings.
apply_standard_settings(${BINARY_NAME})
# Add preprocessor definitions for the build version.
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}")
# Disable Windows macros that collide with C++ standard library functions.
target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")

View File

@@ -60,14 +60,14 @@ IDI_APP_ICON ICON "resources\\app_icon.ico"
// Version
//
#ifdef FLUTTER_BUILD_NUMBER
#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER
#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD)
#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD
#else
#define VERSION_AS_NUMBER 1,0,0
#define VERSION_AS_NUMBER 1,0,0,0
#endif
#ifdef FLUTTER_BUILD_NAME
#define VERSION_AS_STRING #FLUTTER_BUILD_NAME
#if defined(FLUTTER_VERSION)
#define VERSION_AS_STRING FLUTTER_VERSION
#else
#define VERSION_AS_STRING "1.0.0"
#endif