跳到主要內容

關鍵字

下表列出 Dart 語言保留供自身使用的字詞。除非另有說明,否則這些字詞不得作為識別項使用。即使允許,將關鍵字用作識別項也可能會讓閱讀程式碼的其他開發人員感到困惑,應盡量避免。若要進一步瞭解識別項用法,請點擊術語。

abstract 2as 2assertasync 3
await 1base 3breakcase
catchclassconstcontinue
covariant 2defaultdeferred 2do
dynamic 2elseenumexport 2
extendsextension 2external 2factory 2
falsefinal (var)final (class)finally
forFunction 2get 2hide 3
ifimplements 2import 2in
interface 2islate 2library 2
mixin 2newnullof 3
on 3operator 2part 2required 2
rethrowreturnsealed 3set 2
show 3static 2superswitch
sync 3thisthrowtrue
trytype 2typedef 2var
voidwhen 3withwhile
yield 1

 1 此關鍵字可作為識別項使用,具體情況取決於上下文

 2 此關鍵字不得作為類型 (類別、mixin、列舉、擴充類型或類型別名) 的名稱、擴充功能的名稱或匯入前置字串使用。在所有其他情況下,它都可以作為識別項使用。

 3 此關鍵字可不受限制地作為識別項使用。