0

I am new to Flutter, I just separate the Drawer() to a new file call side_drawer.dart. After i separate them, this error comes, IF i do not serpate them, there is no Error.

══╡ EXCEPTION CAUGHT BY GESTURE     ╞═══════════════════════════════════════════════════════════════════
The following assertion was thrown while handling a gesture:
Assertion failed:
file:///C:/flutter/flutter_win_3.3.4/packages/flutter/lib/src/widgets/scroll_controller.dart    :107:12
_positions.isNotEmpty
"ScrollController not attached to any scroll views."
When the exception was thrown, this was the stack:
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-    sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 266:49      throw_
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-    sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 29:3        assertFailed

Here is the HowView:

 class HomeView extends GetView<HomeController> {
    const HomeView({Key? key}) : super(key: key);
    @override
    Widget build(BuildContext context) {
    return Scaffold(
      key: controller.scaffoldKey,
      appBar: AppBar(),
      drawer: SideDrawer(),
      body: PageView(
        controller: controller.pageController,
        children: controller.pages,
        onPageChanged: (index){
          controller.setCurrentIndex(index);
        },
      ),
    );
  }

And this is the side_drawer.dart

class SideDrawer extends StatelessWidget {
  HomeController controller = HomeController();

  SideDrawer({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Drawer(
      child: Column(
        children: [
          InkWell(
            onTap: () {controller.pageController.jumpToPage(0);},
            child: Text("Page 1"),
          ),
          SizedBox(height: 50,),
          InkWell(
            onTap: () {controller.pageController.jumpToPage(1);},
            child: Text("Page 2"),
          )
        ],
      ),
    );
  }
}

0 Answers0