我想在TextSpan中的WebView中打开URL
这是我的密码我想在TextSpan中的WebView中打开URL,url,flutter,webview,textspan,Url,Flutter,Webview,Textspan,这是我的密码 Center( child: SingleChildScrollView( child: Container( child: RichText( text: TextSpan( //style: DefaultTextStyle.of(context).style, children: [ TextSpan( text: 'URL IS IN HERE
Center(
child: SingleChildScrollView(
child: Container(
child: RichText(
text: TextSpan(
//style: DefaultTextStyle.of(context).style,
children: [
TextSpan(
text: 'URL IS IN HERE.COM!\n',
style: TextStyle(letterSpacing: 1, fontSize: 26.0, fontWeight: FontWeight.bold, color: Colors.black)
),
...
我想点击文本字符串('URL在HERE.COM!),然后在我的webview小部件中打开它?您可以使用textspan的识别器属性,对于在浏览器中打开的URL,您可以使用此属性 小部件
TextSpan(text: 'Non touchable. ', children: [
new TextSpan(
text: 'Tap here.',
recognizer: new TapGestureRecognizer()..onTap = () => {
_launchURL();
},
)
])
方法
_launchURL() async {
const url = 'https://flutter.dev';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
经过大量的阅读和研究,我已经解决了这个问题,这是使用URL方案的最佳解决方案
onTap: () async {
const url = "https:www.example.com";
if (await canLaunch(url)) {
await launch(url, forceWebView: true);
} else {
throw "Could not launch $url";
}
},
您是否已经实现了WebView?是否要在应用程序外部打开url?是否要在应用程序中打开浏览器的选项卡?这些都是不同的解决方案。请在您的帖子中添加更多信息。是的,我已经在一个单独的小部件中实现了一个WebView。因此,我想使用WebView小部件打开应用程序内部的URL。我不希望在应用程序或任何浏览器选项卡之外打开,谢谢!这是我的WebView小部件。我不希望使用url\u启动器使用浏览器或浏览器选项卡。我的意图是使用我已经实现的WebView作为一个单独的小部件,并在我的应用程序中打开它。将文本字符串用作可单击的“URL”。。!我的WebView有状态小部件代码如下。。。!我想打开WebView而不是Web浏览器。。??。