跳到主要內容

關鍵詞

下表列出了 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 該關鍵字不能用作型別(類、混入、列舉、擴充套件型別或類型別名)的名稱、擴充套件的名稱或匯入字首。在所有其他情況下,它可以作為識別符號使用。

 3 該關鍵字可以不受限制地用作識別符號。