shiburagi / Drawer-Behavior-Flutter

Drawer behavior is a library that provide an extra behavior on drawer, such as, move view or scaling view's height while drawer on slide.
MIT License
209 stars 36 forks source link

NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE #22

Closed vaibhavrock closed 4 years ago

vaibhavrock commented 4 years ago

I have a issue with menuView.

Error:

══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞════════════════════════════ The following assertion was thrown building DrawerScaffoldMenuController(dirty, state: DrawerScaffoldMenuControllerState#989c4): RenderBox was not laid out: RenderConstrainedBox#74325 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE 'package:flutter/src/rendering/box.dart': Failed assertion: line 1702 pos 12: 'hasSize'

The relevant error-causing widget was: MenuView-[GlobalKey#e9b13 MenuScreen] -----/lib/ui/drawer/Home.dart:58:17

When the exception was thrown, this was the stack:

2 RenderBox.size (package:flutter/src/rendering/box.dart:1702:12)

3 _MenuViewState.build. (package:drawerbehavior/menu_screen.dart:254:56)

4 DrawerScaffoldMenuControllerState.build (package:drawerbehavior/drawer_scaffold.dart:334:26)

5 StatefulElement.build (package:flutter/src/widgets/framework.dart:4663:28)

6 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4546:15)

7 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4719:11)

8 Element.rebuild (package:flutter/src/widgets/framework.dart:4262:5)

9 StatefulElement.update (package:flutter/src/widgets/framework.dart:4751:5)

10 Element.updateChild (package:flutter/src/widgets/framework.dart:3245:15)

11 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4571:16)

12 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4719:11)

13 Element.rebuild (package:flutter/src/widgets/framework.dart:4262:5)

14 StatefulElement.update (package:flutter/src/widgets/framework.dart:4751:5)

15 Element.updateChild (package:flutter/src/widgets/framework.dart:3245:15)

16 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3480:38)

17 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5991:32)

... Normal element mounting (148 frames)

165 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)

166 Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)

167 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5624:32)

168 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6001:17)

169 Element.updateChild (package:flutter/src/widgets/framework.dart:3245:15)

170 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4571:16)

171 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4719:11)

172 Element.rebuild (package:flutter/src/widgets/framework.dart:4262:5)

173 StatefulElement.update (package:flutter/src/widgets/framework.dart:4751:5)

174 Element.updateChild (package:flutter/src/widgets/framework.dart:3245:15)

175 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4571:16)

176 Element.rebuild (package:flutter/src/widgets/framework.dart:4262:5)

177 ProxyElement.update (package:flutter/src/widgets/framework.dart:4906:5)

178 _InheritedNotifierElement.update (package:flutter/src/widgets/inherited_notifier.dart:183:11)

179 Element.updateChild (package:flutter/src/widgets/framework.dart:3245:15)

180 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5881:14)

181 Element.updateChild (package:flutter/src/widgets/framework.dart:3245:15)

182 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4571:16)

183 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4719:11)

184 Element.rebuild (package:flutter/src/widgets/framework.dart:4262:5)

185 StatefulElement.update (package:flutter/src/widgets/framework.dart:4751:5)

186 Element.updateChild (package:flutter/src/widgets/framework.dart:3245:15)

187 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5881:14)

188 Element.updateChild (package:flutter/src/widgets/framework.dart:3245:15)

189 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5881:14)

190 Element.updateChild (package:flutter/src/widgets/framework.dart:3245:15)

191 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4571:16)

192 Element.rebuild (package:flutter/src/widgets/framework.dart:4262:5)

193 StatelessElement.update (package:flutter/src/widgets/framework.dart:4627:5)

194 Element.updateChild (package:flutter/src/widgets/framework.dart:3245:15)

195 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4571:16)

196 Element.rebuild (package:flutter/src/widgets/framework.dart:4262:5)

197 ProxyElement.update (package:flutter/src/widgets/framework.dart:4906:5)

198 Element.updateChild (package:flutter/src/widgets/framework.dart:3245:15)

199 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4571:16)

200 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4719:11)

201 Element.rebuild (package:flutter/src/widgets/framework.dart:4262:5)

202 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2667:33)

203 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:866:20)

204 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:286:5)

205 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1117:15)

206 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1056:9)

207 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:972:5)

211 _invoke (dart:ui/hooks.dart:253:10)

212 _drawFrame (dart:ui/hooks.dart:211:3)

(elided 5 frames from class _AssertionError and dart:async)

═════════════════════════════════════════════

════════ Exception caught by widgets library ══════════════════════════ The following assertion was thrown building DrawerScaffoldMenuController(dirty, state: DrawerScaffoldMenuControllerState#989c4): RenderBox was not laid out: RenderConstrainedBox#74325 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE 'package:flutter/src/rendering/box.dart': Failed assertion: line 1702 pos 12: 'hasSize'

The relevant error-causing widget was: MenuView-[GlobalKey#e9b13 MenuScreen] ----/lib/ui/drawer/Home.dart:58:17 When the exception was thrown, this was the stack:

2 RenderBox.size (package:flutter/src/rendering/box.dart:1702:12)

3 _MenuViewState.build. (package:drawerbehavior/menu_screen.dart:254:56)

4 DrawerScaffoldMenuControllerState.build (package:drawerbehavior/drawer_scaffold.dart:334:26)

5 StatefulElement.build (package:flutter/src/widgets/framework.dart:4663:28)

6 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4546:15)

... ══════════════════════════════════════════════════════════

My code is :

  return new DrawerScaffold(
      percentage: 1,
      cornerRadius: 0,
      appBar: AppBarProps(
          backgroundColor: getAppBarBgColor("default"),
          title: Text(AppTranslations != null ? AppTranslations.of(context).text("home_appbar_text"):"", style: TextStyle(color: getAppBarTxtColor("default")),),
          centerTitle: true,
          actions: [
            //
            //IconButton(icon: Icon(Icons.add), onPressed: () {}),
            IconButton(icon: Icon(Icons.account_circle), onPressed: () {
              goToScreen(context, ProfileScreen());
           /*   showDialog(
                context: context,
                builder: (BuildContext context) => RechargeByPINScreen(
                  title: "Recharge By PIN",
                  description: "Hello, this is dummy description",
                  okbuttontxt: "Okay",
                  cancelbuttontxt: "Cancel",
                  subsNo: 0,
                ),
              );*/
            }),
             IconButton(icon: Icon(Icons.language), onPressed: () {goToScreen(context, LanguageSelectorPage());}),

    ]),
      menuView: MenuView(
        selectorColor: drawerSelectedColor,
        menu: Menu(
          items: [
            new MenuItem(
              id: 'menuHome',
              icon: Icons.home,
              title: AppTranslations.of(context).text("menu_home"),
            ),
            new MenuItem(
              id: 'menuTransations',
              icon: Icons.transform,
              title: AppTranslations.of(context).text("menu_transaction"),
            ),
            new MenuItem(
              id: 'menuInvoice',
              icon: Icons.receipt,
              title: AppTranslations.of(context).text("menu_invoice"),
            ),
            new MenuItem(
              id: 'menuMySession',
              icon: Icons.timelapse,
              title: AppTranslations.of(context).text("menu_my_session"),
            ),
            /* new MenuItem(
        id: 'menuServices',
        icon: Icons.traffic,
        title: 'Services',
      ),*/
            new MenuItem(
              id: 'menuSubscriptions',
              icon: Icons.subscriptions,
              title: AppTranslations.of(context).text("menu_subscriptions"),
            ),
            new MenuItem(
              id: 'menuSessionHistory',
              icon: Icons.history,
              title: AppTranslations.of(context).text("menu_session_history"),
            ),
            new MenuItem(
              id: 'menuUsageSummary',
              icon: Icons.settings,
              title: AppTranslations.of(context).text("menu_usage_summary"),
            ),
            new MenuItem(
              id: 'menuRateUs',
              icon: Icons.question_answer,
              title: AppTranslations.of(context).text("menu_rate_us"),
            ),
            /*    new MenuItem(
        id: 'menuShare',
        icon: Icons.data_usage,
        title: 'Share',
      ),*/
            /*   new MenuItem(
        id: 'menuFeedback',
        icon: Icons.feedback,
        title: 'Feedback'
      ),*/
            new MenuItem(
              id: 'menuLogout',
              icon: Icons.all_out,
              title: AppTranslations.of(context).text("menu_logout"),
            ),
          ],
        ),
        animation: false,
        alignment: Alignment.topCenter,
        color: getThemeColor(),
        selectedItemId: selectedMenuItemId,
        onMenuItemSelected: (String itemId) {

          selectedMenuItemId = itemId;

          if (itemId == 'menuHome') {
            //setState(() => {});
            //Navigator.pushReplacementNamed(context, "/login");
          }
          else if(itemId == 'menuTransations'){
            goToScreen(context, Transactions(title: AppTranslations != null ?AppTranslations.of(context).text("transaction_appbar_text"):"",));
          }
          else if(itemId == 'menuInvoice'){
            goToScreen(context, InvoiceList(title: AppTranslations != null ?AppTranslations.of(context).text("invoice_appbar_text"):"",));
          }
          else if(itemId == 'menuMySession'){
            goToScreen(context, MySession(title: AppTranslations != null ?AppTranslations.of(context).text("mysession_appbar_text"):"",));
          }
          else if(itemId == 'menuSubscriptions'){
            goToScreen(context, Subscriptions(title: AppTranslations != null ?AppTranslations.of(context).text("subscriptions_appbar_text"):"",));
          }
          else if(itemId == 'menuSessionHistory'){
            goToScreen(context, SessionHistory(title: AppTranslations != null ?AppTranslations.of(context).text("session_history_appbar_text"):"",));
          }
          else if(itemId == 'menuUsageSummary'){
            goToScreen(context, UsageSummary(title: AppTranslations != null ?AppTranslations.of(context).text("usage_summary_appbar_text"):"",));
          }
          else if(itemId == 'menuRateUs'){
            //LaunchReview.launch(); use for current app open in play store
            LaunchReview.launch(androidAppId: "net.inventum.selfcare");
          }
          else{
            //menuLogout -- logout
            showDialog(
              context: context,
              builder: (BuildContext context) {
                // return object of type Dialog
                return AlertDialog(
                  title: new Text(AppTranslations != null ?AppTranslations.of(context).text("dialog_alert_text"):""),
                  content: new Text(AppTranslations != null ?AppTranslations.of(context).text("logout_text"):""),
                  actions: <Widget>[
                    // usually buttons at the bottom of the dialog
                    new FlatButton(
                      child: new Text(AppTranslations != null ?AppTranslations.of(context).text("no_text"):""),
                      onPressed: () {
                        Navigator.of(context).pop();
                      },
                    ),
                    new FlatButton(
                      child: new Text(AppTranslations != null ?AppTranslations.of(context).text("yes_text"):""),
                      onPressed: () {
                        Navigator.of(context).pop();
                        clearSharedData();
                      },
                    ),
                  ],
                );
              },
            );

          }

          // this used to always select home tag
          //start
          setState(() => {
            this.selectedMenuItemId = 'menuHome'
          });
          //end

        },
      ),
      contentView: Screen(
        contentBuilder: (context) => LayoutBuilder(
        builder: (context, constraint) =>  HomeView(),
    ),
    color: Colors.white,
    )

    );

Please suggest me for solving this issue ? I am using 'drawerbehavior: ^0.0.10'

vaibhavrock commented 4 years ago

Issue has fixed after upgrading "drawerbehavior: ^0.0.10 to" "drawerbehavior: ^1.0.3"