Dart Extensions : Extension Syntax

Dart Extensions : Extension Syntax

Extension Syntax:

  • In this syntax, the ExtensionName is the name of the extension and the ClassName is the name of the class being extended. The ReturnType is the type of the value returned by the extension method.

Example

extension ExtensionName on ClassName { 
    ReturnType methodName(ParameterType parameter) { 
        // implementation 
    } 
}