Skip to content

How do i add a dissmiss button to the Flushbar ย #166

@nnyamekye

Description

@nnyamekye

I'm trying to show a Flushbar when a TimeoutException is thrown. My implementation can be seen below.

My IDE complains that "Local variable 'flush' can't be referenced before it is declared." which make sense but i see a lot of examples where people do this. Please help

on TimeoutException {
      var flush = Flushbar(
        title: 'Server Unavailable',
        backgroundColor: primaryColor,
        message: '๐Ÿ˜“ Sorry the server is currently unavailable',
        flushbarPosition: FlushbarPosition.TOP,
        margin: EdgeInsets.all(8),
        borderRadius: 8,
        icon: Icon(
          Icons.error_outline,
          size: 28.0,
          color: Colors.white,
        ),
        mainButton: FlatButton(
          onPressed: () {
            flush.dismiss(true); // result = true
          },
          child: Text(
            "DISMISS",
            style: TextStyle(
                color: Colors.white,
                fontWeight: FontWeight.bold,
                fontSize: 10
            ),
          ),
        ),
    ).show(context);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions