PDF
1FlutterContents .................................................................................................... 1 ............................................................................................... 2使线 ........................................................................... 4线 2使children: <Widget>[ _profileImage(), Observer( builder: (_) { return _userStore.isBusy ? _progressBar() : _input(context); }, )],@actionFuture<bool> login(ProtectedValue masterPassword) async { setBusy(); bool success = false; try { final PasswordCredential credential = await _loginService.checkUserCredential(masterPassword); _errorMessage = null; _userCredential = credential; success = true; } catch (_) { _userCredential = null; _errorMessage = ""; } setIdle(); return success;}使flutter profile怀busy怀 3 线4I/Choreographer(15562): Skipped 107 frames! The application may be doing too much work on its main thread.怀便oid onPasswordSubmitted(BuildContext context, String password) async { print('login with: ${password}'); for(int i = 0; i < 100000; i++) { }}线Flutter线线线线Skipped 107 frames! The application may be doing too much work on its main thread.Future.microtask()线Isolate线使Isolate西线使使compute使Isolate.spawnFuture<List<Photo>> fetchPhotos(http.Client client) async { final response = await client.get('https://jsonplaceholder.typicode.com/photos'); // Use the compute function to run parsePhotos in a separate isolate. 线5 return compute(parsePhotos, response.body);}Compute使线线computetypedef ComputeCallback<Q, R> = FutureOr<R> Function(Q message);staticIsolate.spawnvar ourFirstReceivePort = new ReceivePort(); // ReceivePortawait Isolate.spawn(echo, ourFirstReceivePort.sendPort); // Isolatevar echoPort = await ourFirstReceivePort.first; // // IsolatesendPortsendPort.send(...);spawnexternal static Future<Isolate> spawn<T>( void entryPoint(T message), T message, {bool paused: false, bool errorsAreFatal, SendPort onExit, SendPort onError, @Since("2.3") String debugName});线 线6class Argon2Kdf implements Kdf { @override Future<Uint8List> derive(Uint8List password, Uint8List salt) async { Argon2 argon2 = new Argon2(); return await argon2.argon2i(password, salt) as Uint8List; }}Isolate线使class Argon2Kdf implements Kdf { static final Argon2 argon2 = Argon2(iterations: 2); static void argon2Call(SendPort replyPort) async { final receivePort = ReceivePort(); replyPort.send(receivePort.sendPort); final List<dynamic> params = await receivePort.first; final SendPort reportPort1 = params[0]; final String passwordHex = params[1]; final String saltHex = params[2]; final Uint8List password = hex.decode(passwordHex) as Uint8List; final Uint8List salt = hex.decode(saltHex) as Uint8List; final Uint8List result = await argon2.argon2i(password, salt) as Uint8List; reportPort1.send(hex.encode(result)); } @override Future<Uint8List> derive(Uint8List password, Uint8List salt) async { final ReceivePort response = ReceivePort(); final isolate = await FlutterIsolate.spawn(argon2Call, response.sendPort); final SendPort sendPort = await response.first; final ReceivePort response1 = ReceivePort(); sendPort.send([response1.sendPort, hex.encode(password), hex.encode(salt)]); final String result = await response1.first; isolate.kill(); 线7 return hex.decode(result); }}await response.first使使Isolate.spawnE/flutter (18071): [ERROR:flutter/runtime/dart_isolate.cc(808)] Unhandled exception:E/flutter (18071): error: native function 'Window_sendPlatformMessage' (4 arguments) cannot be found 线8线

HTML view coming soon.

Download PDF for the full formatted version.