getCurrentView static method

FlutterView? getCurrentView([
  1. BuildContext? context
])

访问当前视图,如果不传递 context,则访问全局实例中的第一个视图, 若传递 context,则返回目标 context 所在的视图

Implementation

static FlutterView? getCurrentView([BuildContext? context]) => context == null
    ? WidgetsBinding.instance.platformDispatcher.views.firstOrNull
    : View.maybeOf(context);