我正在dlblack.dev 上慢慢建立我的个人网站,并且我正在尝试为它增添一点趣味。例如,从计算机(而不是平板电脑或手机,因为它们没有鼠标指针),如果您将鼠标悬停在任何可点击的项目上,它不会改变您的鼠标指针以表明它是可点击的,并且可点击的对象根本不会改变。我决定遵循这个 FilledStacks 教程,但它没有提到关于解决这个问题的任何内容。
基本上发生的事情是,当我通过教程视频(他在那里编写骨架扩展类)获得大约 2.5 分钟并尝试复制它时,VS Code 将几乎整个类声明(除了名称)红线。我正在写的内容与他在 2:26 屏幕上显示的内容完全相同,这是我的代码:
import 'package:flutter/material.dart';
import 'dart:html' as html;
extension HoverExtension on Widget{
}
Run Code Online (Sandbox Code Playgroud)
当我这样做时,“扩展”、“开”和“小部件”都被红线了。当我将鼠标悬停在“扩展”上时,它会显示以下内容:
Undefined class 'extension'.
Try changing the name to the name of an existing class, or creating a class with the name 'extension'. dartundefined_class
This requires the 'extension-methods' language feature to be enabled.
Try updating your pubspec.yaml to set the minimum SDK constraint to 2.6 or higher, and running 'pub get'. dart(experiment_not_enabled) …Run Code Online (Sandbox Code Playgroud)