Alert para confirmar cerrar Sesión Flutter






Edit mas opciones:

Alert Material

Alert Cupertino

Comparto ejemplo

LogoutConfirm() {
      showDialog(
        context: context,
        barrierDismissible: false,
        builder: (BuildContext context) {

          return Dialog(
            elevation: 0.0,
            shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(10.0)),
            child: Container(
              height: 135.0,
              padding: EdgeInsets.all(20.0),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: <Widget>[
                  Text(
                    "Seguro que quieres cerrar sesión?",
                    style: blackBigTextStyle,
                  ),
                  SizedBox(
                    height: 20.0,
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceAround,
                    children: <Widget>[
                      InkWell(
                        onTap: () {
                          Navigator.pop(context);
                        },
                        child: Container(
                          width: (width / 3.5),
                          alignment: Alignment.center,
                          padding: EdgeInsets.all(10.0),
                          decoration: BoxDecoration(
                            color: Colors.grey[300],
                            borderRadius: BorderRadius.circular(5.0),
                          ),
                          child: Text(
                            'Cancelar',
                            style: blackColorButtonTextStyle,
                          ),
                        ),
                      ),
                      InkWell(
                        onTap: () async {

                               SharedPreferences preferences =
                        await SharedPreferences.getInstance();
                    preferences.clear();
                    Provider.of<TaskData>(context, listen: false)
                        .clearOrderData();
                        Navigator.pop(context);
                        Navigator.pop(context);
                        
                        },
                        child: Container(
                          width: (width / 3.5),
                          alignment: Alignment.center,
                          padding: EdgeInsets.all(10.0),
                          decoration: BoxDecoration(
                            color: primaryColor,
                            borderRadius: BorderRadius.circular(5.0),
                          ),
                          child: Text(
                            'Cerrar Sesión',
                            style: whiteColorButtonTextStyle,
                          ),
                        ),
                      ),
                    ],
                  ),
                ],
              ),
            ),
          );
        },
      );
    }

Comentarios

Entradas más populares de este blog

Ejemplo de suma Pascal

Solucion al error collation desconocida: 'utf8mb4_0900_ai_ci'