How to open OpenContainer programatically in flutter?

Viewed 19

I have an Open container in my flutter project. I want this to open on the basis of a condition. This is the code I have come up with:

      OpenContainer(
        useRootNavigator: true,
        closedShape: const CircleBorder(),
        closedColor: themePurple.withOpacity(0.9),
        transitionDuration: const Duration(milliseconds: 500),
        closedBuilder: (context, action) {
          if (widget.launchFromWidgetCommand == "add_todo") {
            action.call();//this doesn't work
          }
          return FloatingActionButton(
            tooltip: "Add New Task",
            onPressed: () {
              action.call();
            },
            backgroundColor: themePurple.withOpacity(0.9),
            child: const Icon(
              Icons.add,
              size: 30,
              color: Color.fromARGB(255, 47, 15, 83),
            ),
          );
        },
        openBuilder: (context, action) {
          return InputModal(
            goBack: () => action.call(),
            addTodo: widget.createTodo,
            time: widget.time, //time
            timeType: widget.timeType,
            index: widget.index, //index
          );
        },
      ),

When the condition is satisified I get this error:

Unhandled Exception: 'package:flutter/src/widgets/navigator.dart': Failed assertion: line 4437 pos 12: '!_debugLocked': is not true.

How can I fix this?

0 Answers
Related