Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 颤振Web:url\u启动器链接小部件鼠标悬停_Flutter_Url_Flutter Web - Fatal编程技术网

Flutter 颤振Web:url\u启动器链接小部件鼠标悬停

Flutter 颤振Web:url\u启动器链接小部件鼠标悬停,flutter,url,flutter-web,Flutter,Url,Flutter Web,当我点击某个按钮时,我正在使用flatterurl\u启动程序包打开url 有了新的链接小部件,我现在可以在同一个选项卡上打开网页,但当用户悬停按钮时,我无法添加鼠标指针 import 'package:bianca/UI/botao_azul.dart'; import 'package:url_launcher/link.dart'; import 'package:flutter/material.dart'; String link = "https://www.google.

当我点击某个按钮时,我正在使用flatterurl\u启动程序包打开url

有了新的链接小部件,我现在可以在同一个选项卡上打开网页,但当用户悬停按钮时,我无法添加鼠标指针

import 'package:bianca/UI/botao_azul.dart';
import 'package:url_launcher/link.dart';
import 'package:flutter/material.dart';
String link = "https://www.google.com";
class MesmaAba extends StatelessWidget {
  final double tamanho;
  final String conteudo;
  MesmaAba({this.tamanho, this.conteudo});
  @override
  Widget build(BuildContext context) {
    return Link(
      uri: Uri.parse(link),
      builder: (BuildContext context, FollowLink followLink) => BotaoAzul(
          conteudo: conteudo,
          tamanho: tamanho,
          funcao: followLink 
          ),
    );
  }
}
import 'package:url_launcher/url_launcher.dart';
void launchLink(String link) async {
  await launch(
    link,
  );
}
博托阿祖级:

import 'package:flutter/material.dart';

class BotaoAzul extends StatelessWidget {
  final String conteudo;
  final double tamanho;
  final Function funcao;

  BotaoAzul({this.conteudo, this.tamanho,this.funcao});

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Padding(
        padding: const EdgeInsets.all(8.0),
        child: FlatButton(
            onPressed: funcao,
            child: Text(conteudo,
                style: TextStyle(
                    fontSize: tamanho,
                    color: Colors.white,
                    fontWeight: FontWeight.bold))),
      ),
      decoration: BoxDecoration(
          color: Colors.blue[900], borderRadius: BorderRadius.circular(20.0)),
    );
  }
}
我已经可以使用此功能在另一个选项卡上使用botaoAzul按钮打开URL(如果没有链接小部件,鼠标悬停按钮时会发生变化)

但是我需要在同一个选项卡上打开url

我已经尝试了其他问题的所有实现,但没有成功:

据我所知,最新版本的Flatter web支持自动为小部件手动光标。下面是简单类:

导入“包装:颤振/材料.省道”;
导入“package:url_launcher/url_launcher.dart”;
///提供指向web URL的锚链接。
类HoveredWebAnchor扩展StatefulWidget{
悬停网络锚(
{键,
@需要这个标签,
@需要此.url,
this.marderlined=true})
:assert(label!=null),
断言(url!=null),
断言(带下划线!=null),
超级(键:键);
///锚的标签
最终字符串标签;
///单击锚定时要打开的web URL
最终字符串url;
///标识锚定标签是否将加下划线。
带下划线的最终bool;
@凌驾
_HoveredWebAnchorState createState()=>_HoveredWebAnchorState();
}
类_HoveredWebAnchorState扩展状态{
///当前文本样式
TextStyle _TextStyle;
@凌驾
小部件构建(构建上下文){
回墨槽(
hoverColor:Colors.transparent,
子:文本(
widget.label,
样式:_textStyle,
),
悬停:(悬停){
设置状态(){
如果(悬停){
_textStyle=textStyle(颜色:Theme.of(context.accentColor));
if(widget.下划线){
_textStyle=\u textStyle.copyWith(
装饰:textEdition.underline,
);
}
}否则{
_textStyle=null;
}
});
},
onTap:(){
启动(widget.url,forceWebView:true);
},
);
}
}
使用:

HoveredWebAnchor(
标签:“打开谷歌”,
网址:'http://www.google.com',
),

昨晚找到了解决问题的方法:

我现在导入html包,而不是使用url_启动器链接

import 'dart:html' as html;
String link = "https://www.google.com";
.....

void openPage(){
html.window.location.assign(link);
}

...... (widget build method)

BotaoAzul(
  conteudo: "Hey",
  tamanho: 30,
   funcao: openPage
),

现在,它在同一选项卡上打开链接,我可以从chrome后退按钮返回到我的颤振应用程序

您的代码将链接打开到另一个选项卡,我正在同一选项卡中查找内容。