Flutter應用進行自動化測試

Tecode發表於2021-08-12

前言

開發過程中,我們都會有一個很重要的環節,那就是測試。Flutter開發也一樣,我們當我們完成了應用的開發之後,需要對我們的軟體進行測試。市面上也有很多可以用於測試的一些自動化的軟體。在這裡介紹一下flutter自帶的測試,我們可以通過這個外掛,對我們的整個應用進行自動化的測試。

執行環境

[√] Flutter (Channel stable, 2.2.3, on Microsoft Windows [Version 10.0.19042.1110], locale zh-CN)
    • Flutter version 2.2.3 at D:\flutter
    • Framework revision f4abaa0735 (6 weeks ago), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn
複製程式碼

安裝依賴

首先,我們需要安裝flutter_driver外掛。安裝完成以後,我們在專案中新建一個資料夾(我的檔名是test_driver自己定義資料夾名字)。這個資料夾就用於我們的測試程式碼的編寫。

dev_dependencies:
  flutter_driver:
    sdk: flutter
  test: any
複製程式碼

程式碼編寫

我要寫的一個測試程式碼,就是我要通過程式碼去找到我需要的元件,比如按鈕,我需要去點選它。滑動列表我需要往下划動到第多少頁。然後我再往回劃,切換到下一個頁面,如此迴圈的。按照我們人類思維的流程,把整個專案全部模擬操作。

app.dart測試入口檔案

import 'package:flutter_driver/driver_extension.dart';
import 'package:dynamic_theme/main.dart' as app;

void main() {
  // This line enables the extension.
  enableFlutterDriverExtension();

  // Call the `main()` function of the app, or call `runApp` with
  // any widget you are interested in testing.
  app.main();
}
複製程式碼

app_test.dart執行需要測試模組

我寫了entrance的檔案模組,裡面包含了頁面點選滾動的模擬事件,如果需要全模組的測試可以在main函式加多個group需要測試某個功能也可以按需測試。

import 'package:test/test.dart';

import 'entrance.dart';

void main() {
  group('切換導航滑動頁面', entrance);
}
複製程式碼

entrance.dart模擬測試指令碼

import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart';

void entrance() {
  late FlutterDriver driver;
  // Connect to the Flutter driver before running any tests.
  setUpAll(() async {
    driver = await FlutterDriver.connect();
  });
  // Close the connection to the driver after the tests have completed.
  tearDownAll(() async {
    await driver.close();
  });
// test('starts at 0', () async {
// Use the `driver.getText` method to verify the counter starts at 0.
// expect(await driver.getText(counterTextFinder), '0');
//    });

  test('切換頁面', () async {
    await Future.delayed(Duration(seconds: 2));
    await driver.tap(find.byValueKey('tab_3'));
    await Future.delayed(Duration(seconds: 5));
    await driver.tap(find.byValueKey('tab_2'));
    await Future.delayed(Duration(seconds: 5));
    await driver.tap(find.byValueKey('tab_1'));
    await Future.delayed(Duration(seconds: 5));
    await driver.tap(find.byValueKey('tab_0'));
  });

  test('滑動頁面到底部', () async {
    await driver.runUnsynchronized(() async {
      final listFinder = find.byValueKey('message_list');
      final itemFinder = find.byValueKey('item_78');
      await driver.scrollUntilVisible(
        listFinder,
        itemFinder,
        dyScroll: -300.0,
      );
    });
  });

  test('滑動頁面到頂部', () async {
    await driver.runUnsynchronized(() async {
      final listFinder = find.byValueKey('message_list');
      final itemFinder = find.byValueKey('item_1');
      await driver.scrollUntilVisible(
        listFinder,
        itemFinder,
        dyScroll: 300.0,
      );
    });
  });

  test('跳轉頁面', () async {
    // First, tap the button.
    await driver.tap(find.byValueKey('jump_list'));

    // Then, verify the counter text is incremented by 1.
    expect(await driver.getText(find.byValueKey('title')), 'NewList-路由傳參');
  });

  test('返回頁面', () async {
    await Future.delayed(Duration(seconds: 5));
    final buttonFinder = find.byValueKey('back');
    // First, tap the button.
    await driver.tap(buttonFinder);

    // Then, verify the counter text is incremented by 1.
    // expect(await driver.getText(counterTextFinder), '1');
  });
}
複製程式碼

怎樣找到我們需要的元件?

測試指令碼使用find.byValueKey('key的名稱')來找到我們需要的元件,找到以後我們可以進行點選、滾動、雙擊等模擬操作。這裡我使用的是find.byValueKey方法,下面介紹它的使用。

找到滾動列表,滾動某個位置

首先我們要找到我們需要滑動的列表,我find.byValueKey這個方法去找到滑動元件,在開始寫業務程式碼的時候我已經加了一個key名稱是message_listkey不要重複避免查詢元件出現問題。

業務程式碼

EasyRefresh.custom(
  key: Key('message_list'),
  enableControlFinishRefresh: true,
  ...
複製程式碼

測試程式碼例子

driver.scrollUntilVisible模擬滑動,itemFinder參數列示滑動到key:item_78這個元素的時候就不滑動了,接下來每次滑動300畫素。

test('滑動頁面到底部', () async {
  await driver.runUnsynchronized(() async {
    final listFinder = find.byValueKey('message_list');
    final itemFinder = find.byValueKey('item_78');
    await driver.scrollUntilVisible(
      listFinder,
      itemFinder,
      dyScroll: -300.0,
    );
  });
});
複製程式碼

driver支援的方法

-   [checkHealth](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/checkHealth.html)(​{[Duration](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/Duration-class.html) timeout }) → [Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​[Health](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/Health-class.html)>

-   Checks the status of the Flutter Driver extension.

-   [clearTimeline](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/clearTimeline.html)(​{[Duration](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/Duration-class.html) timeout: _kUnusuallyLongTimeout }) → [Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​void>

-   Clears all timeline events recorded up until now. [[...]](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/clearTimeline.html)

-   [close](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/close.html)(​) → [Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​void>

-   Closes the underlying connection to the VM service. [[...]](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/close.html)

-   [enterText](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/enterText.html)(​[String](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/String-class.html) text, { [Duration](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/Duration-class.html) timeout }) → [Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​void>

-   Enters `text` into the currently focused text input, such as the [EditableText](https://docs-flutter-io.firebaseapp.com/flutter/widgets/EditableText-class.html) widget. [[...]](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/enterText.html)

-   [forceGC](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/forceGC.html)(​) → [Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​void>

-   Force a garbage collection run in the VM.

-   [getRenderTree](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/getRenderTree.html)(​{[Duration](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/Duration-class.html) timeout }) → [Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​[RenderTree](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/RenderTree-class.html)>

-   Returns a dump of the render tree.

-   [getSemanticsId](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/getSemanticsId.html)(​[SerializableFinder](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/SerializableFinder-class.html) finder, { [Duration](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/Duration-class.html) timeout }) → [Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​[int](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/int-class.html)>

-   Retrieves the semantics node id for the object returned by `finder`, or the nearest ancestor with a semantics node. [[...]](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/getSemanticsId.html)

-   [getText](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/getText.html)(​[SerializableFinder](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/SerializableFinder-class.html) finder, { [Duration](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/Duration-class.html) timeout }) → [Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​[String](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/String-class.html)>

-   Returns the text in the `Text` widget located by `finder`.

-   [getVmFlags](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/getVmFlags.html)(​) → [Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​[List](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/List-class.html)<​[Map](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/Map-class.html)<​[String](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/String-class.html), dynamic>>>

-   Returns the Flags set in the Dart VM as JSON. [[...]](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/getVmFlags.html)

-   [requestData](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/requestData.html)(​[String](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/String-class.html) message, { [Duration](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/Duration-class.html) timeout }) → [Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​[String](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/String-class.html)>

-   Sends a string and returns a string. [[...]](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/requestData.html)

-   [runUnsynchronized](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/runUnsynchronized.html)<​T>(​[Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​T> action(), { [Duration](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/Duration-class.html) timeout }) → [Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​T>

-   `action` will be executed with the frame sync mechanism disabled. [[...]](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/runUnsynchronized.html)

-   [screenshot](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/screenshot.html)(​) → [Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​[List](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/List-class.html)<​[int](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/int-class.html)>>

-   Take a screenshot. [[...]](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/screenshot.html)

-   [scroll](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/scroll.html)(​[SerializableFinder](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/SerializableFinder-class.html) finder, [double](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/double-class.html) dx, [double](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/double-class.html) dy, [Duration](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/Duration-class.html) duration, { [int](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/int-class.html) frequency: 60, [Duration](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/Duration-class.html) timeout }) → [Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​void>

-   Tell the driver to perform a scrolling action. [[...]](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/scroll.html)

-   [scrollIntoView](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/scrollIntoView.html)(​[SerializableFinder](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/SerializableFinder-class.html) finder, { [double](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/double-class.html) alignment: 0.0, [Duration](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/Duration-class.html) timeout }) → [Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​void>

-   Scrolls the Scrollable ancestor of the widget located by `finder` until the widget is completely visible. [[...]](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/scrollIntoView.html)

-   [scrollUntilVisible](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/scrollUntilVisible.html)(​[SerializableFinder](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/SerializableFinder-class.html) scrollable, [SerializableFinder](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/SerializableFinder-class.html) item, { [double](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/double-class.html) alignment: 0.0, [double](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/double-class.html) dxScroll: 0.0, [double](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/double-class.html) dyScroll: 0.0, [Duration](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/Duration-class.html) timeout }) → [Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​void>

-   Repeatedly [scroll](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/scroll.html) the widget located by `scrollable` by `dxScroll` and `dyScroll` until `item` is visible, and then use [scrollIntoView](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/scrollIntoView.html) to ensure the item's final position matches `alignment`. [[...]](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/scrollUntilVisible.html)

-   [setSemantics](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/setSemantics.html)(​[bool](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/bool-class.html) enabled, { [Duration](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/Duration-class.html) timeout }) → [Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​[bool](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/bool-class.html)>

-   Turns semantics on or off in the Flutter app under test. [[...]](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/setSemantics.html)

-   [setTextEntryEmulation](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/setTextEntryEmulation.html)(​{[bool](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/bool-class.html) enabled, [Duration](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/Duration-class.html) timeout }) → [Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​void>

-   Configures text entry emulation. [[...]](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/setTextEntryEmulation.html)

-   [startTracing](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/startTracing.html)(​{[List](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/List-class.html)<​[TimelineStream](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/TimelineStream-class.html)> streams: _defaultStreams, [Duration](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/Duration-class.html) timeout: _kUnusuallyLongTimeout }) → [Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​void>

-   Starts recording performance traces. [[...]](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/startTracing.html)

-   [stopTracingAndDownloadTimeline](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/stopTracingAndDownloadTimeline.html)(​{[Duration](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/Duration-class.html) timeout: _kUnusuallyLongTimeout }) → [Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​[Timeline](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/Timeline-class.html)>

-   Stops recording performance traces and downloads the timeline. [[...]](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/stopTracingAndDownloadTimeline.html)

-   [tap](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/tap.html)(​[SerializableFinder](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/SerializableFinder-class.html) finder, { [Duration](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/Duration-class.html) timeout }) → [Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​void>

-   Taps at the center of the widget located by `finder`.

-   [traceAction](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/traceAction.html)(​[Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html) action(), { [List](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/List-class.html)<​[TimelineStream](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/TimelineStream-class.html)> streams: _defaultStreams, [bool](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/bool-class.html) retainPriorEvents: false }) → [Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​[Timeline](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/Timeline-class.html)>

-   Runs `action` and outputs a performance trace for it. [[...]](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/traceAction.html)

-   [waitFor](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/waitFor.html)(​[SerializableFinder](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/SerializableFinder-class.html) finder, { [Duration](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/Duration-class.html) timeout }) → [Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​void>

-   Waits until `finder` locates the target.

-   [waitForAbsent](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/waitForAbsent.html)(​[SerializableFinder](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/SerializableFinder-class.html) finder, { [Duration](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/Duration-class.html) timeout }) → [Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​void>

-   Waits until `finder` can no longer locate the target.

-   [waitUntilNoTransientCallbacks](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/waitUntilNoTransientCallbacks.html)(​{[Duration](https://docs-flutter-io.firebaseapp.com/flutter/dart-core/Duration-class.html) timeout }) → [Future](https://docs-flutter-io.firebaseapp.com/flutter/dart-async/Future-class.html)<​void>

-   Waits until there are no more transient callbacks in the queue. [[...]](https://docs-flutter-io.firebaseapp.com/flutter/flutter_driver/FlutterDriver/waitUntilNoTransientCallbacks.html)
複製程式碼

find方法支援的查詢方式find.text find.byValueKey find.bySemanticsLabel find.pageBack find.byType

SerializableFinder text(String text) => ByText(text);

/// Finds widgets by [key]. Only [String] and [int] values can be used.
SerializableFinder byValueKey(dynamic key) => ByValueKey(key);

/// Finds widgets with a tooltip with the given [message].
SerializableFinder byTooltip(String message) => ByTooltipMessage(message);

/// Finds widgets with the given semantics [label].
SerializableFinder bySemanticsLabel(Pattern label) => BySemanticsLabel(label);

/// Finds widgets whose class name matches the given string.
SerializableFinder byType(String type) => ByType(type);

/// Finds the back button on a Material or Cupertino page's scaffold.
SerializableFinder pageBack() => const PageBack();
複製程式碼

run flutter drive --target=test_driver/app.dart

現在我們已經寫好了自動化測試指令碼run flutter drive --target=test_driver/app.dart命令,會在控制檯上面看到很多輸出的資訊,說明已經開始自動化測試了,最後我們會看到控制檯輸出了All tests passed!的說明已經測試成功了。

測試模擬

Flutter應用進行自動化測試

測試輸出

螢幕錄製2021-08-11 18.19.35.2021-08-11 18_27_12.gif

D:\project\dynamic_theme>flutter drive --target=test_driver/app.dart
Running "flutter pub get" in dynamic_theme...                    1,399ms
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                        28.3s
√  Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...                803ms
00:00 +0: 切換導航滑動頁面 (setUpAll)

VMServiceFlutterDriver: Connecting to Flutter application at http://127.0.0.1:62607/4xhdHTUuf_U=/
VMServiceFlutterDriver: Isolate found with number: 3474149526286947
VMServiceFlutterDriver: Isolate is paused at start.
VMServiceFlutterDriver: Attempting to resume isolate
I/flutter ( 2384): debug版本--KK
VMServiceFlutterDriver: Connected to Flutter application.
00:02 +0: 切換導航滑動頁面 切換頁面

I/flutter ( 2384): initial link:
I/flutter ( 2384): initialLink--
00:20 +1: 切換導航滑動頁面 滑動頁面到底部

VMServiceFlutterDriver: waitFor message is taking a long time to complete...
00:39 +2: 切換導航滑動頁面 滑動頁面到頂部

VMServiceFlutterDriver: waitFor message is taking a long time to complete...
00:52 +3: 切換導航滑動頁面 跳轉頁面

I/flutter ( 2384): 進入NewView
I/flutter ( 2384): _NewViewState#0c082(lifecycle state: initialized)
00:53 +4: 切換導航滑動頁面 返回頁面

I/flutter ( 2384): 資料傳參
00:58 +5: 切換導航滑動頁面 (tearDownAll)

00:58 +5: All tests passed!  -
複製程式碼

專案地址

到這裡就已經結束,感興趣的小夥伴可以去下載原始碼體驗。如果不能執行請先檢查flutter的版本。

相關文章