拨开荷叶行,寻梦已然成。仙女莲花里,翩翩白鹭情。
IMG-LOGO
主页 文章列表 Flutter-如何使用图示和网址启动器?

Flutter-如何使用图示和网址启动器?

白鹭 - 2022-03-16 1990 0 0

我正在自己学习颤振,我想制作一个可以使用的图示,url_launcher但我不知道该怎么做。当我使用图示时,onTap不起作用。我该如何解决这个问题?

Row(
  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  children: const [
    Icon(
      Icons.facebook_outlined,
      size: 80,
      color: Colors.black,
    )
  ],
),

uj5u.com热心网友回复:

您可以使用 Gesturedecture 或 IconButton

  Row(
      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
      children: [
        GestureDetector(
         onTap:(){
          launchUrl();
        }
         child:Icon(
          Icons.facebook_outlined,
          size: 80,
          color: Colors.black,
        )
       )
      ],
    )

图示按钮

IconButton(
icon: Icon(
      Icons.facebook_outlined,
      size: 80,
      color: Colors.black,
    ),
onPressed:(){
 launchUrl();
}

)

uj5u.com热心网友回复:

InkWell提供onTap,你可以Icon用它包裹,我更喜欢飞溅效果。此外,您可以IconButton像@Afridi Kaya 评论的那样使用

Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
  InkWell(
    onTap: () {
      print("tapped InkWell");
      /// todo: your launch
    },
    customBorder: const CircleBorder(),
    child: const Icon(
      Icons.facebook_outlined,
      size: 80,
      color: Colors.black,
    ),
  ),
  IconButton(
    onPressed: () {
      /// todo: your launch
      print("tapped IconButton");
    },
    iconSize: 80,
    padding: EdgeInsets.zero,
    alignment: Alignment.center,
    icon: const Icon(
      Icons.facebook_outlined,
      color: Colors.black,
    ),
  )

uj5u.com热心网友回复:

您可以使用IconButton

           Center(
            child: IconButton(
    
              icon: Icon(Icons.facebook_outlined),
    
              onPressed: () {
    
                setState(() {
    
                 _isBluetoothOn = !_isBluetoothOn;
    
                });
    
              },
    
            ),
    
          ),
标签:

0 评论

发表评论

您的电子邮件地址不会被公开。 必填的字段已做标记 *