Type Inference and Annotation

Get introduced to type inference and learn about Dart's ability to infer types.

Overview

Dart is strongly typed. Strongly typed languages take extra precautions and have rules and restrictions to ensure that a variable’s value always matches the variable’s static type.

Statically typed programming languages are those in which variables need to be defined before they are used.

Although types are mandatory in Dart, type annotations are optional because of type inference.

Let’s first understand what type of inference is.

What is type inference?

As the name implies, type inference is a programming language’s ability to infer types when not specified by the user.

Until now, we have been declaring a variable using the following syntax:

Create a free account to access the full course.

Continue your learning journey with a 14-day free trial.

By signing up, you agree to Educative's Terms of Service and Privacy Policy