Home > other >  Unhandled Exception: '!_debugLocked': is not true
Unhandled Exception: '!_debugLocked': is not true

Time:12-02

When I click on an expandable listtile by tapping on the listtile, this error is thrown through the following code.

I've not been able to figure out how to resolve it.

       
        title: Text(tile.title,  
        style: TextStyle(
          
        fontSize: 18),
        ),
        
        onTap: tile.tiles.isEmpty
            ? () => Utils.showSnackBar(
                  context,
                  text: 'Clicked on: ${tile.title}',
                  color: Colors.green,
                )
            : null,
      );
}

Error :

E/flutter (18015): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:flutter/src/widgets/navigator.dart': Failed assertion: line 4475 pos 12: '!_debugLocked': is not true.

CodePudding user response:

Your ontap syntax is wrong. Try

onTap: () => tile.tiles.isEmpty
            ? Utils.showSnackBar(
                  context,
                  text: 'Clicked on: ${tile.title}',
                  color: Colors.green,
                )
            : null,

CodePudding user response:

Your onTap syntax is wrong. Try this solution. Hope it will work.

onTap: () => book.books.isEmpty
            ? Utils.showSnackBar(
                  context,
                  text: 'Clicked on: ${book.bookId}',
                  color: Colors.green,
                )
            : null,
  • Related