Typedef for Variable and Collections
Typedef is not restricted to functions we can use variables and collections. Let us check syntax for this:
typedef name = Collection;
Below is the Example for Collection is mentioned below:
// Dart program to show the usage of typedef
// Defining alias name
typedef List_Integer = List<int>;
// Main Function
void main() {
// Using alias name to Declare
// List of Integer type
List_Integer x=[11,21,31];
// Print the List
print(x);
}
Output:
[11 , 21, 31]
Typedef in Dart
Typedef in Dart is used to create a user-defined identity (alias) for a function, and we can use that identity in place of the function in the program code. In this article, we will learn about Typedef in Dart.
Contact Us