flutter showDialog & ElevatedButton

flutterkage2k·2021년 5월 31일
0

flutter

목록 보기
3/11

flutter showDialog & ElevatedButton

Code as below example


floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.add),
        backgroundColor: Theme.of(context).accentColor,
        onPressed: () {
          showDialog(
            context: context,
            builder: (_) => SimpleDialog(
              contentPadding:
                  EdgeInsets.symmetric(horizontal: 25, vertical: 20),
              backgroundColor: Colors.grey[800],
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(20),
              ),
              title: Row(
                children: [
                  Text(
                    "Add Todo",
                    style: TextStyle(
                      fontSize: 20,
                      color: Colors.white,
                    ),
                  ),
                  Spacer(),
                  IconButton(
                    onPressed: () {
                      Navigator.pop(context);
                    },
                    icon: Icon(
                      Icons.cancel,
                      color: Colors.grey,
                      size: 30,
                    ),
                  ),
                ],
              ),
              children: [
                Divider(),
                TextFormField(
                  style:
                      TextStyle(fontSize: 18, height: 1.5, color: Colors.white),
                  autofocus: true,
                  decoration: InputDecoration(
                    hintText: "eg. exercise",
                    hintStyle: TextStyle(
                      color: Colors.white70,
                    ),
                    border: InputBorder.none,
                  ),
                ),
                SizedBox(
                  height: 20,
                ),
                SizedBox(
                  width: MediaQuery.of(context).size.width,
                  height: 50,
                  child: ElevatedButton(
                    onPressed: () {},
                    child: Text("Add"),
                    style: ElevatedButton.styleFrom(
                      primary: Theme.of(context).primaryColor,
                      onPrimary: Colors.white,
                      shape: RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(20),
                      ),
                    ),
                  ),
                )
              ],
            ),
          );
        },
      ),

End
⊙^⊙ Thank For Reading | Happy Coding ⊙-⊙

Setapp on Mac invite link flutterkage2k

The referrer gets a free month, up to a maximum of six months, for each friend who creates an account and signs in on their Mac.

Setapp_Logo.png

If it helps, buy me a cup of coffee.

buymeacoffee.png

0개의 댓글