How to get the global context with getx in fluuter

Viewed 33

How to get the global context with getx in fluuter? I encapsulated a toast but how can I get the context. Is there any other way to get the context.

    CommonWidget.dart
    class CommonWidget {
      static toast(String error) async {
        BrnToast.show(
          error,
          context,
          gravity: BrnToastGravity.bottom,
          background: Color.fromRGBO(0, 0, 0, 0.5),
          radius: 3,
          duration: BrnDuration.long,
        );
      }
    }
    LoginController.dart
    class LoginController extends GetxController {
        verificationCode() async {
          CommonWidget.toast(res.message.toString());
        }
    }
   
0 Answers
Related