YUYANE

FLUTTER / Remove Tooltip of PopupMenuButton Widget 본문

Framework/FLUTTER

FLUTTER / Remove Tooltip of PopupMenuButton Widget

YUYA 2021. 6. 19. 17:33

출처 : https://github.com/flutter/flutter/issues/60418

 

 

해당 위젯 : PopupMenuButton

 

클릭 시 팝업 창에 메뉴를 띄워주는 편리한 위젯. 마우스가 버튼위를 지날 때(on hover) 버튼의 기능을 설명해주는 tooltip property를 가지고 있다.

 

 

문제

 

tooltip을 보여주고 싶지 않은데 그 기능을 제어하는 property는 따로 없다. 

 

 

해결

 

 - PopupMenuButton 위젯을 Theme 위젯으로 감싸고, Theme 위젯에서 tooltip 컬러를 투명으로 지정하면 된다.

 - PopupMenuButton 위젯의 tooltip 값은 ' '

 

 

코드

Theme(
                data: Theme.of(context).copyWith(
                  tooltipTheme: TooltipThemeData(
                    decoration: BoxDecoration(
                      color: Colors.transparent
                    )
                  )
                ),
                child: PopupMenuButton(
                  elevation: 0,
                  tooltip: "",
                  icon: Row(
                    children: [
                      Text('ㅁㅁ',style: TextStyle(fontWeight: FontWeight.bold),
                      ),

                      AnimatedBuilder(animation: _arrowAnimationController, builder: (context, child)=>Transform.rotate(
                        angle: _arrowAnimation.value,
                        child: Icon(
                          Icons.arrow_drop_down,
                        ),
                      )),


                    ],
                  ),
                    itemBuilder: (context)=>[
                  PopupMenuItem(
                  child: Text('first'),
                  value: 'first',
                ),
                  PopupMenuItem(
                    child: Text('first'),
                    value: 'first',
                  ),
                ]),
              ),

'Framework > FLUTTER' 카테고리의 다른 글

FLUTTER/ Drawer, Expanded, Responsive  (0) 2021.05.06
FLUTTER / Stack, RichText, Navigator  (0) 2021.05.05
Comments