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
// 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.

Similar Reads

How to Use Typedef with Dart Functions?

There are a few cases that tell us how to use typedef in Dart. Cases are mentioned below:...

Programs to Illustrate the use of typedef

Example 1:  Using typedef in Dart....

Typedef for Variable and Collections

Typedef is not restricted to functions we can use variables and collections. Let us check syntax for this:...

Contact Us