在 Flutter 中的 TextFormField 中,用户输入 url 或网站链接以将其保存到 firebase 数据库,并且应使用浏览器打开该链接

问题描述

在 Flutter 中的 TextFormField 中,我想输入一个 url 或网站链接以将其保存到 firebase 数据库,并且应使用浏览器打开该链接,即在保存并将其保存到 firebase 数据库之前,它应该是可点击的。

因此它应该打开网站或与浏览器等链接

如何在flutter中实现这个功能

我使用过 url_launcher: 插件并导入了 import 'package:url_launcher/url_launcher.dart';

我的代码如下

 child: TextFormField(
                        validator: (value){
                          if(value.isEmpty){
                            return "Please write the Company Website of production";
                          }else {
                            website = value;
                          }
                        },keyboardType: TextInputType.name,autofocus: false,// controller: _controller,decoration: InputDecoration(
                          labelText: ' Company Website ',hintText: 'Enter the Company Website',prefixIcon: IconButton(
                            onPressed: () async {
                              if (await canLaunch("url")) {
                                await launch("url");
                              }
                            },icon: Icon(Icons.open_in_browser),),maxLength: 15,)

请指导我解决这个问题。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)