Search code examples
flutterdialogoverlay

Flutter : Dialog() widget overlay


return Dialog(...)

Information: This "Dialog()" has different sizes based on the input of the class.

Question: How can I put an overlay 20 pixels around it? Let's say red?

What did I try? I tried the "shadow" property; it isn't good enough and does not look how I want it.

Greetings


Solution

  • You can just use a container inside the dialog with custom BoxDecoration:

    Dialog(
      child: Container(
        decoration: BoxDecoration(
          color: Colors.white,
          boxShadow: const [
            BoxShadow(
              color: Colors.red,
              blurRadius: 10)])));
    

    See demo here: https://dartpad.dev/?id=d3f1fb7d3e50e1543f6899c57c7effb8