canGoBack method

  1. @override
Future<bool> canGoBack()

Checks whether there's a back history item.

Implementation

@override
Future<bool> canGoBack() async {
  if (jsBridge.hasReady) {
    final int length =
        await jsBridge.evalJavaScript<int>('window.history.length');

    /// 为什么加2
    /// 默认进入的是个空白页面,记为1
    /// 栈顶页面得保留再退出iframe,记为1
    return length > (_goBackCount + 2);
  } else {
    return false;
  }
}