0
votes

I have used the path package and when I try to use it I get error 'The argument type 'Context' can't be assigned to the parameter type 'BuildContext''. Could anyone help me with this? In my code when I am trying to get my token and call AlertDialog box, the context there gives the error saying 'The argument type 'Context' can't be assigned to the parameter type 'BuildContext''.

 String? token =
        await Provider.of<AuthenticationController>(context, listen: false)
            .getToken();



  Future<bool> _onWillPop() async {
    return (await showDialog(
          context:  context,
          builder: ( context) => AlertDialog(
            title: const Text('Are you sure?'),
            // content: Text('Do you want to exit an App'),
            actions: <Widget>[
              TextButton(
                onPressed: () {
                  Navigator.pop(context);
                  Navigator.pop(context);
                  Navigator.pop(context);
                  Navigator.push(
                      context,
                      MaterialPageRoute(
                          builder: (context) => BasicBooksCategory(
                              basicBookId: widget.basicBookId)));
                },
                child: const Text('Yes'),
              ),
              TextButton(
                onPressed: () {
                  Navigator.pop(context);
                },
                child: const Text('No'),
              ),
            ],
          ),
        )) ??
        false;
  }
You code is insufficient. Please provide the code from where you are getting the context. It might be different context that you are calling without giving more code can't tell. - Just a Person