> For the complete documentation index, see [llms.txt](https://eece.gitbook.io/mist-innovation-club-flutter-course-1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://eece.gitbook.io/mist-innovation-club-flutter-course-1/dart-fundamentals-1/constructor/named-constructor.md).

# Named Constructor

{% embed url="<https://youtu.be/sO_dEqzj14A>" %}

{% hint style="success" %}
You can think of named constructors  same as default constructors or parameterised constructors , but they have a name&#x20;
{% endhint %}

{% hint style="success" %}
You can have multiple  named constructors inside the class definition&#x20;
{% endhint %}

{% hint style="success" %}
Named Constructor can also have optional argument as it's input , so it gives us a lot of flexibility  for creating objects&#x20;
{% endhint %}

```dart
void main() {
  
  var employee1 = Employee(1, "John", "Doe", "CTO", 12);
  
  var employee2 = Employee.mynamedconstructor2(2, "Jane", "Doe", "CE0", 10);
  
 

  print(employee2.id);
  print(employee2.firstname);
  print(employee2.lastname);
  print(employee2.position);
  print(employee2.number_of_day_worked);
}

class Employee {
  
  int id;

  String firstname;

  String lastname;

  String position;

  int number_of_day_worked;
  
  
  
  // Parameterised constructor 
  
Employee(this.id,this.firstname,this.lastname,this. position,this.number_of_day_worked);
  
  
  
  // Named constrcutor 
  
  
  Employee.mynamedconstructor(this.id,this.firstname,this.lastname,this. position,this.number_of_day_worked);
  
  
  
   Employee.mynamedconstructor2(this.id,this.firstname,this.lastname,this. position,this.number_of_day_worked);
  
  
  
  

}


```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://eece.gitbook.io/mist-innovation-club-flutter-course-1/dart-fundamentals-1/constructor/named-constructor.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
