Flutter web cursor with hand pointer style

栏目: IT技术 · 发布时间: 5年前

内容简介:Working with Flutter it is a pleasant experience. Easy, fast, productive, it just works.We can create Flutter Apps for iOS and Android in an extremly short time. But even more, we canGoolge says Flutter web it is

Working with Flutter it is a pleasant experience. Easy, fast, productive, it just works.

We can create Flutter Apps for iOS and Android in an extremly short time. But even more, we can deliver a web based experience to the users.  not just mobile  “native”.

Goolge says Flutter web it is not ready for production . I believe so, there are still some missing features when it comes to making your App ready for the web.

But that does not mean that we can just use it and be aware of the little limitations we still have.

I have been working on a web based  project with Flutter.  The first issue I found is that the user does not have the same experience as on the web.

The issue

One thing you just notice straight away is that the mouse is not like in the standard web when hovering on clickable elements Flutter web cursor with hand pointer style .

It does not change to a little hand Flutter web cursor with hand pointer style to let you know you can click on it.

Flutter web cursor with hand pointer style

Well, I wanted to deliver a web site! not a weird web!

So how can you make Flutter web look like a proper web showing the correct cursor style.

The Solution

Modify the index.html  giving an Id to the container.

<body id="flutter_container">

In your dart file:

Wrap your “clickable” widget into this MouseCursor widget that looks like this:

class MouseCursor extends MouseRegion{

  static var clickableArea = document.getElementById("flutter_container"); //your element id

  MouseCursor({@required Widget child}):super(
      child:child,
      onHover: _mouseOnHover,
       onExit: _mouseOnExit);

  static void _mouseOnHover(PointerHoverEvent event) {
      clickableArea.style.cursor = "pointer";
  }


  static void _mouseOnExit(PointerExitEvent event) {
    clickableArea.style.cursor = "default";
  }
}

So you should use it this way:

MouseCursor(child: TwitterHeart() ) );

Flutter web cursor with hand pointer style

That is it!  Easy right!?

If you like , you have any question or suggestions, please leave a comment or send me an email!

Happy coding with Flutter! :blue_heart:


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

翻转课堂的可汗学院

翻转课堂的可汗学院

萨尔曼·可汗(Salman Khan) / 刘婧 / 浙江人民出版社 / 2014-4-1 / 49.00元

MIT和哈佛毕业的高材生缘何放弃金融分析师工作投身教育事业?YouTube上的“可汗学院频道”至今共吸引了163.3万订阅者,观看次数超过3.55亿次,它为什么如此大受欢迎?创始人萨尔曼·可汗阐述属于未来的教育理念——让地球上的任何人都能随时随地享受世界一流的免费教育! 现行教育模式已有200余年历史,可汗认为,在互联网蓬勃发展、社交网络盛况空前的时代,免费、灵活、适合个体、全球共享的教育才......一起来看看 《翻转课堂的可汗学院》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

SHA 加密
SHA 加密

SHA 加密工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具