This commit is contained in:
ekibun
2021-01-25 14:33:47 +08:00
parent ee110f55e1
commit 6fb2c4776b
12 changed files with 492 additions and 545 deletions

View File

@@ -1,16 +1,3 @@
# flutter_qjs_example
Demonstrates how to use the flutter_qjs plugin.
## Getting Started
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.

View File

@@ -6,9 +6,7 @@
* @LastEditTime: 2020-12-02 11:28:06
*/
import 'package:flutter/material.dart';
import 'dart:typed_data';
import 'package:dio/dio.dart';
import 'package:flutter/services.dart';
import 'package:flutter_qjs/isolate.dart';
@@ -44,28 +42,6 @@ class TestPage extends StatefulWidget {
State<StatefulWidget> createState() => _TestPageState();
}
dynamic methodHandler(String method, List arg) {
switch (method) {
case "http":
return Dio().get(arg[0]).then((response) => response.data);
case "test":
return arg[0]([
true,
1,
0.5,
"str",
{"key": "val", 0: 1},
Uint8List(2),
Int32List(2),
Int64List(2),
Float64List(2),
Float32List(2)
]);
default:
throw Exception("No such method");
}
}
class _TestPageState extends State<TestPage> {
String resp;
IsolateQjs engine;
@@ -82,9 +58,6 @@ class _TestPageState extends State<TestPage> {
"js/" + module.replaceFirst(new RegExp(r".js$"), "") + ".js");
},
);
final setToGlobalObject =
await engine.evaluate("(key, val) => this[key] = val;");
setToGlobalObject("channel", methodHandler);
}
@override

View File

@@ -43,13 +43,6 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.15.0-nullsafety.5"
dio:
dependency: "direct main"
description:
name: dio
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.10"
fake_async:
dependency: transitive
description:
@@ -82,7 +75,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.3.0"
version: "0.3.1"
flutter_test:
dependency: "direct dev"
description: flutter
@@ -95,13 +88,6 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.6.0"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.1.4"
matcher:
dependency: transitive
description:

View File

@@ -22,7 +22,6 @@ dependencies:
highlight: 0.6.0
flutter_highlight: 0.6.0
dio: 3.0.10
dev_dependencies:
flutter_test: