Skip to content

Flutter 3.16.1环境下,无法完成渲染树的构建,表现为APP在debug模式下启动后一直停留在启动界面,控制台抛出异常 #96

@0x1af2aec8f957

Description

@0x1af2aec8f957

Flutter 版本信息:

flutter --version

Flutter 3.16.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 7f20e5d18c (14 hours ago) • 2023-11-27 09:47:30 -0800
Engine • revision 22b600f240
Tools • Dart 3.2.1 • DevTools 2.28.3

主要的代码:

void main() async {
  // WidgetsFlutterBinding.ensureInitialized();
  MockBinding.ensureInitialized();

  // 运行会出现错误,一直停留在启动界面,无法进入APP
  return runMockApp(
    KeyboardRootWidget(
       child: App(),
    ));

  // 没有仍和问题
  // return runApp(App());


}

使用KeyboardRootWidget包裹的情况下:

flutter run ════════ Exception caught by Flutter framework ═════════════════════════════════ The following assertion was thrown: The render object for Stack cannot find ancestor render object to attach to. The ownership chain for the RenderObject in question was: Stack ← Directionality ← Builder ← MediaQuery ← KeyboardMediaQuery ← KeyboardRootWidget ← [root] Try wrapping your widget in a View widget or any other widget that is backed by a RenderTreeRootElement to serve as the root of the render tree. ════════════════════════════════════════════════════════════════════════════════

不使用KeyboardRootWidget包裹的情况下:

flutter run ════════ Exception caught by Flutter framework ═════════════════════════════════ The following assertion was thrown: The render object for Semantics cannot find ancestor render object to attach to. The ownership chain for the RenderObject in question was: Semantics ← _FocusInheritedScope ← Focus ← HeroControllerScope ← ScrollConfiguration ← MaterialApp ← WillPopScope ← NotificationListener ← _GlobalOverlaySupport-[LabeledGlobalKey>#a3d3e overlay_support] ← OverlaySupportTheme ← ⋯ Try wrapping your widget in a View widget or any other widget that is backed by a RenderTreeRootElement to serve as the root of the render tree. ════════════════════════════════════════════════════════════════════════════════

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions