Flutter meta 关键字

简介: Flutter meta 关键字

官方库包


meta library - Dart API

开发人员可以用来表达意图的注释,否则无法通过静态分析源代码来推论这些意图。

另请参见 dart:core 库中的 @deprecated@override


注释提供了语义信息,工具可以使用这些语义信息来提供更好的用户体验。例如,IDE 可能不会自动完成标记为 @deprecated 的函数的名称,或者它可能以不同的方式显示该函数的名称。


有关安装和导入该库的信息,请参见pub.dev上的meta包。有关使用注释的示例,请参阅语言导览中的元数据。


关键字


alwaysThrows → const _AlwaysThrows

Used to annotate a function f. Indicates that f always throws an exception. Any functions that override f, in class inheritance, are also expected to conform to this contract. [...]const _AlwaysThrows()


checked → const _Checked

Used to annotate a parameter of an instance method that overrides another method. [...]@Deprecated('Use the covariant modifier instead')const _Checked()


doNotStore → const _DoNotStore

Used to annotate a method, getter or top-level getter or function to indicate that the value obtained by invoking it should not be stored in a field or top-level variable. The annotation can also be applied to a class to implicitly annotate all of the valid members of the class, or applied to a library to annotate all of the valid members of the library, including classes. If a value returned by an element marked as doNotStore is returned from a function or getter, that function or getter should be similarly annotated. [...]const _DoNotStore()


experimental → const _Experimental

Used to annotate a library, or any declaration that is part of the public interface of a library (such as top-level members, class members, and function parameters) to indicate that the annotated API is experimental and may be removed or changed at any-time without updating the version of the containing package, despite the fact that it would otherwise be a breaking change. [...]const _Experimental()


工厂 factory → const _Factory

Used to annotate an instance or static method m. Indicates that m must either be abstract or must return a newly allocated object or null. In addition, every method that either implements or overrides m is implicitly annotated with this same annotation. [...]const _Factory()


immutable → const Immutable

Used to annotate a class C. Indicates that C and all subtypes of C must be immutable. [...]const [Immutable]

(<https://pub.dev/documentation/meta/latest/meta/Immutable/Immutable.html>)()


internal → const _Internal


Used to annotate a declaration which should only be used from within the package in which it is declared, and which should not be exposed from said package's public API. [...]const _Internal()


isTest → const _IsTest

Used to annotate a test framework function that runs a single test. [...]const _IsTest()


isTestGroup → const _IsTestGroup

Used to annotate a test framework function that runs a group of tests. [...]const _IsTestGroup()


literal → const _Literal

Used to annotate a const constructor c. Indicates that any invocation of the constructor must use the keyword const unless one or more of the arguments to the constructor is not a compile-time constant. [...]const _Literal()


强制重写 mustCallSuper → const _MustCallSuper

Used to annotate an instance method m. Indicates that every invocation of a method that overrides m must also invoke m. In addition, every method that overrides m is implicitly annotated with this same annotation. [...]const _MustCallSuper()


nonVirtual → const _NonVirtual

Used to annotate an instance member (method, getter, setter, operator, or field) m in a class C or mixin M. Indicates that m should not be overridden in any classes that extend or mixin C or M. [...]const _NonVirtual()


optionalTypeArgs → const _OptionalTypeArgs

Used to annotate a class, mixin, or extension declaration C. Indicates that any type arguments declared on C are to be treated as optional. Tools such as the analyzer and linter can use this information to suppress warnings that would otherwise require type arguments on C to be provided.const _OptionalTypeArgs()


保护 protected → const _Protected

Used to annotate an instance member (method, getter, setter, operator, or field) m in a class C. If the annotation is on a field it applies to the getter, and setter if appropriate, that are induced by the field. Indicates that m should only be invoked from instance methods of C or classes that extend, implement or mix in C, either directly or indirectly. Additionally indicates that m should only be invoked on this, whether explicitly or implicitly. [...]const _Protected()


required → const Required

Used to annotate a named parameter p in a method or function f. Indicates that every invocation of f must include an argument corresponding to p, despite the fact that p would otherwise be an optional parameter. [...]const [Required](<https://pub.dev/documentation/meta/latest/meta/Required/Required.html>)()


sealed → const _Sealed

Annotation marking a class as not allowed as a super-type. [...]const _Sealed()


virtual → const _Virtual

Used to annotate a field that is allowed to be overridden in Strong Mode. [...]@Deprecated('No longer has meaning')const _Virtual()


visibleForOverriding → const _VisibleForOverriding

Used to annotate an instance member that was made public so that it could be overridden but that is not intended to be referenced from outside the defining library. [...]const _VisibleForOverriding()


visibleForTesting → const _VisibleForTesting

Used to annotate a declaration that was made public, so that it is more visible than otherwise necessary, to make code testable. [...]const _VisibleForTesting()


目录
相关文章
|
Dart
【Flutter】Future 异步编程 ( 简介 | then 方法 | 异常捕获 | async、await 关键字 | whenComplete 方法 | timeout 方法 )(一)
【Flutter】Future 异步编程 ( 简介 | then 方法 | 异常捕获 | async、await 关键字 | whenComplete 方法 | timeout 方法 )(一)
326 0
|
Dart 开发者
【Flutter】Future 异步编程 ( 简介 | then 方法 | 异常捕获 | async、await 关键字 | whenComplete 方法 | timeout 方法 )(二)
【Flutter】Future 异步编程 ( 简介 | then 方法 | 异常捕获 | async、await 关键字 | whenComplete 方法 | timeout 方法 )(二)
558 0
|
1月前
|
Android开发 iOS开发 容器
鸿蒙harmonyos next flutter混合开发之开发FFI plugin
鸿蒙harmonyos next flutter混合开发之开发FFI plugin
|
5月前
|
开发框架 前端开发 测试技术
Flutter开发常见问题解答
Flutter开发常见问题解答
|
21天前
|
开发者
鸿蒙Flutter实战:07-混合开发
鸿蒙Flutter混合开发支持两种模式:1) 基于har包,便于主项目开发者无需关心Flutter细节,但不支持热重载;2) 基于源码依赖,利于代码维护与热重载,需配置Flutter环境。项目结构包括AppScope、flutter_module等目录,适用于不同开发需求。
57 3
|
6天前
|
传感器 开发框架 物联网
鸿蒙next选择 Flutter 开发跨平台应用的原因
鸿蒙(HarmonyOS)是华为推出的一款旨在实现多设备无缝连接的操作系统。为了实现这一目标,鸿蒙选择了 Flutter 作为主要的跨平台应用开发框架。Flutter 的跨平台能力、高性能、丰富的生态支持和与鸿蒙系统的良好兼容性,使其成为理想的选择。通过 Flutter,开发者可以高效地构建和部署多平台应用,推动鸿蒙生态的快速发展。
92 0
|
8天前
|
Dart 安全 UED
Flutter&鸿蒙next中的表单封装:提升开发效率与用户体验
在移动应用开发中,表单是用户与应用交互的重要界面。本文介绍了如何在Flutter中封装表单,以提升开发效率和用户体验。通过代码复用、集中管理和一致性的优势,封装表单组件可以简化开发流程。文章详细讲解了Flutter表单的基础、封装方法和表单验证技巧,帮助开发者构建健壮且用户友好的应用。
55 0
|
1月前
|
开发框架 移动开发 Android开发
安卓与iOS开发中的跨平台解决方案:Flutter入门
【9月更文挑战第30天】在移动应用开发的广阔舞台上,安卓和iOS两大操作系统各自占据半壁江山。开发者们常常面临着选择:是专注于单一平台深耕细作,还是寻找一种能够横跨两大系统的开发方案?Flutter,作为一种新兴的跨平台UI工具包,正以其现代、响应式的特点赢得开发者的青睐。本文将带你一探究竟,从Flutter的基础概念到实战应用,深入浅出地介绍这一技术的魅力所在。
71 7
|
21天前
|
编解码 Dart API
鸿蒙Flutter实战:06-使用ArkTs开发Flutter鸿蒙插件
本文介绍了如何开发一个 Flutter 鸿蒙插件,实现 Flutter 与鸿蒙的混合开发及双端消息通信。通过定义 `MethodChannel` 实现 Flutter 侧的 token 存取方法,并在鸿蒙侧编写 `EntryAbility` 和 `ForestPlugin`,使用鸿蒙的首选项 API 完成数据的读写操作。文章还提供了注意事项和参考资料,帮助开发者更好地理解和实现这一过程。
49 0
|
21天前
|
Dart Android开发
鸿蒙Flutter实战:03-鸿蒙Flutter开发中集成Webview
本文介绍了在OpenHarmony平台上集成WebView的两种方法:一是使用第三方库`flutter_inappwebview`,通过配置pubspec.lock文件实现;二是编写原生ArkTS代码,自定义PlatformView,涉及创建入口能力、注册视图工厂、处理方法调用及页面构建等步骤。
39 0