Flutter - ShowDialog 띄우기

2023. 4. 8. 14:58Flutter

  • GestureDetector를 통해 icon버튼처럼 클릭시 팝업창을 띄우도록하겟습니다.

  • 팝업창
 void showPopup(context) {
    showDialog(
        context: context,
        builder: (context) {
          return Dialog(
            child: Container(
              width: MediaQuery.of(context).size.width,
              height: 400,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(16),
                color: Color.fromRGBO(250, 240, 220, 1),
              ),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisSize: MainAxisSize.max,
                children: [
                  Container(
                    color: Colors.white,
                    height: 30,
                    child: Row(
                      children: [
                        IconButton(
                          onPressed: () {
                            Navigator.of(context).pop();
                          },
                          icon: Icon(Icons.arrow_back_ios),
                        ),
                        Expanded(
                          child: Center(
                              child: Text(
                            "나의 포켓몬 정보",
                            style: TextStyle(
                                fontSize: 20, fontWeight: FontWeight.bold),
                          )),
                        ),
                        IconButton(
                            onPressed: () {
                              showDefaultHeightModalBottomSheet(context);
                            },
                            icon: SvgPicture.asset(
                                'assets/icons/Edit-24.svg'))
                      ],
                    ),
                  ),
                  Container(
                    color: Colors.white24,
                    padding: EdgeInsets.all(16),
                    width: MediaQuery.of(context).size.width,
                    height: 100,
                    child: IconButton(
                        onPressed: () {},
                        icon: Image.asset(
                          'assets/images/1.png',
                        )),
                  ),
                  Container(
                    color: Colors.white,
                    height: 200,
                    margin: EdgeInsets.all(8),
                    child: SingleChildScrollView(
                      child: Text("올해도 잘부탁합니다올해도 잘부탁합니다올해도 잘부탁합니다"
                          "올해도 잘부탁합니다올해도 잘부탁합니다올해도 잘부탁합니다올해도 잘부탁합니다"
                          "올해도 잘부탁합니다올해도 잘부탁합니다올해도 잘부탁합니다올해도 잘부탁합니다"
                          "올해도 잘부탁합니다올해도 잘부탁합니다올해도 잘부탁합니다올해도 잘부탁합니다"
                          "올해도 잘부탁합니다올해도 잘부탁합니다올해도 잘부탁합니다올해도 잘부탁합니다"
                          "올해도 잘부탁합니다올해도 잘부탁합니다올해도 잘부탁합니다올해도 잘부탁합니다"
                          "올해도 잘부탁합니다올해도 잘부탁합니다올해도 잘부탁합니다올해도 잘부탁합니다"
                          "올해도 잘부탁합니다올해도 잘부탁합니다"
                          "올해도 잘부탁합니다"
                          "올해도 잘부탁합니다올해도 잘부탁합니다"
                          "올해도 잘부탁합니다"
                          "올해도 잘부탁합니다올해도 잘부탁합니다올해도 잘부탁합니다"),
                    ),
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text(
                        "2023.04.05 ~ 2023.04.07",
                        style: TextStyle(fontStyle: FontStyle.italic),
                      ),
                      IconButton(
                          onPressed: () {
                          },
                          icon: SvgPicture.asset(
                              "assets/icons/Like-active-24.svg"))
                    ],
                  ),
                ],
              ),
            ),
          );
        });
  }

 

1.Singlechildscrollview를 통해 글자가넘어갈때  스크롤하도록햇습니다.

 

 

 

'Flutter' 카테고리의 다른 글

Flutter - CarouselSlider 위젯  (0) 2023.04.09
Flutter - ShowModalBottomSheet 위젯  (0) 2023.04.08
Flutter - Lottie 위젯  (0) 2023.04.07
Flutter - TextField, Appbar  (0) 2023.03.10
Flutter - routes 방식으로 데이터 전달하기  (0) 2023.03.07