Dialog nedtill

Skapa en funktion som genererar dialogrutan:

_showModal() {
    return showModalBottomSheet(
      context: context,
      builder: (context) {
        return Container(
          height: 250,
          padding: EdgeInsets.symmetric(vertical: 30, horizontal: 15.0),
          child: Wrap(
            children: <Widget>[
              Container(
                margin: EdgeInsets.only(bottom: 20.0),
                child: Text(
                  'Lorem ipsum dolor sit amet consectetur adipisicing elit. Minus fuga excepturi nisi dolores reprehenderit officia rerum porro.',
                  textAlign: TextAlign.center,
                  style: TextStyle(fontSize: 15.0),
                ),
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  RaisedButton(
                    child: Text('Nej', style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Colors.white)),
                    elevation: 0,
                    color: Colors.red,
                    onPressed: () {
                      Navigator.of(context).pop();
                    },
                  ),
                  RaisedButton(
                    child: Text('Ja', style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Colors.white)),
                    elevation: 0,
                    color: Colors.green,
                    onPressed: () {
                      // Gå vidare;
                    },
                  ),
                ],
              )
            ],
          ),
        );
      }
    );
  }

För att visa den, anropa funktionen ovan:

RaisedButton(
    child: Text('Show bottom sheet'),
    onPressed: () {
    	_showModal();
    },
),

Lämna ett svar

Stäng meny