The most asked Dart interview questions with structured answers — a quick answer, a clear explanation and working code for each. Covers basics for freshers through advanced, scenario and coding questions for experienced developers.
Updated November 2026 Reviewed by Abhishek Kumar 120 min read
100 Dart interview questions, grouped by level: freshers, intermediate, experienced and coding.
Every answer starts with a one-line “Quick answer” you can say out loud, followed by the explanation and runnable code.
Use the filter bar to practise only the level you are interviewing for, then test yourself with the free Dart quiz.
What is Dart, and why do interviewers ask about it?
Dart is a client‑optimized language for fast apps on any platform. This page compiles the most frequently asked Dart interview questions, covering everything from basic syntax to advanced OOP, functional programming, and concurrency – essential for Flutter and full‑stack development.
Why companies hire for Dart
Object‑oriented with sound null safety
JIT & AOT compilation for fast development and performance
Modern language features – async/await, generics, mixins
Powerful standard library with collections and streams
Used by Flutter – the world’s most popular cross‑platform framework
Growing community and enterprise adoption
100 shown
Basic Dart Interview Questions for Freshers
5 questions
Start here if you are a fresher or switching to Dart. These fundamentals are asked in almost every first-round and campus interview.
Quick answerDart is a client-optimized programming language developed by Google. It's used for building web, mobile (Flutter), and desktop applications with a focus on productivity and performance.
Object-Oriented: Everything is an object
Type Safety: Strong static typing with type inference
Sound Null Safety: Prevents null reference errors
Async/Await: Built-in support for asynchronous programming
JIT & AOT Compilation: Fast development and production performance
Dart
// Hello World in Dartvoidmain() {
print('Hello, World!');
}
Quick answerDart provides a rich set of built-in data types including numbers, strings, booleans, lists, sets, and maps. All types are objects and inherit from Object.
int — 64-bit integer (depending on platform)
double — 64-bit floating point
String — UTF-16 encoded text
bool — true/false
List — ordered collection
Set — unordered unique collection
Map — key-value pairs
Dart
// Data Types in Dartvoidmain() {
int age = 25;
double salary = 50000.50;
double pi = 3.14159265358979;
String grade = 'A';
bool isActive = true;
String name = "Alice";
num price = 99.99;
print('Age: $age');
print('Salary: $salary');
print('Pi: $pi');
print('Grade: $grade');
print('Active: $isActive');
print('Name: $name');
print('Price: $price');
}
Quick answerDart uses var for type inference, final for runtime constants, and const for compile-time constants. It also supports explicit type declarations.
var — type-inferred variable
final — set once at runtime
const — compile-time constant
late — lazy initialization
Explicit typing — int x = 10;
Dart
// Variables, Constants, and FinalclassProgram{
staticconstdouble PI = 3.14159;
staticfinalint MAX = 100;
staticvoidmain() {
int x = 10;
constint MIN_VALUE = 0;
// Type inferencevar val = 3.14;
var str = "Hello";
print('x = $x');
print('PI = $PI');
print('val = $val');
print('str = $str');
}
}
voidmain() => Program.main();
Quick answerPolymorphism allows objects of different types to be treated uniformly. Abstract classes define contracts that derived classes must implement.
Quick answerGenerics provide type safety and code reuse by parameterizing types. They enable writing flexible, reusable code while maintaining compile-time type checking.
class Stack<T> — generic class
T — type parameter
extends — type constraints
List<int> — generic collection
Type Safety: Compile-time checking
Dart
// Generics in Dart// Generic classclassStack<T> {
List<T> _data = List.filled(100, nullas T);
int _top = -1;
voidpush(T val) {
_data[++_top] = val;
}
T pop() {
return _data[_top--];
}
T peek() {
return _data[_top];
}
boolisEmpty() {
return _top == -1;
}
}
// Generic method
T max<T extendsComparable<T>>(T a, T b) {
return a.compareTo(b) > 0 ? a : b;
}
void swap<T>(T a, T b) {
// Dart doesn't support ref parameters directly// This is a demonstrationprint('Swapping ${a} and ${b}');
}
// Multiple type parametersclassPair<K, V> {
K key;
V value;
Pair(this.key, this.value);
voidprintPair() {
print('$key -> $value');
}
}
voidmain() {
print(max<int>(10, 20));
print(max<double>(3.5, 2.1));
print(max<String>('B', 'A'));
Stack<int> si = Stack<int>();
si.push(1);
si.push(2);
si.push(3);
print('${si.pop()}${si.pop()}');
Pair<String, int> p = Pair('age', 25);
p.printPair();
}
Quick answerLists are ordered collections of elements. Dart provides extensive list operations including sorting, filtering, mapping, and functional transformations.
How interviewers ask it“Explain functional programming operations with iterable in Dart in detail — what should a new team member understand about them?”
How interviewers ask it“Explain dynamic programming problems like knapsack and LCS in Dart in detail — what should a new team member understand about them?”
Quick answerNumber Theory includes algorithms for GCD, LCM, prime numbers, sieve, and modular exponentiation.
GCD/LCM: Euclidean algorithm
Prime Detection: Trial division, sieve
Modular Arithmetic: Modular exponentiation
Applications: Cryptography, number theory
Dart
// Number Theory in Dartintgcd(int a, int b) => b == 0 ? a : gcd(b, a % b);
intlcm(int a, int b) => a ~/ gcd(a, b) * b;
boolisPrime(int n) {
if (n < 2) returnfalse;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) returnfalse;
}
returntrue;
}
List<int> sieve(int limit) {
List<bool> notPrime = List.filled(limit + 1, false);
if (limit >= 0) notPrime[0] = true;
if (limit >= 1) notPrime[1] = true;
for (int i = 2; i * i <= limit; i++) {
if (!notPrime[i]) {
for (int j = i * i; j <= limit; j += i) {
notPrime[j] = true;
}
}
}
List<int> primes = [];
for (int i = 2; i <= limit; i++) {
if (!notPrime[i]) primes.add(i);
}
return primes;
}
intmodPow(intbase, int exp, int mod) {
int result = 1;
base %= mod;
while (exp > 0) {
if (exp.isOdd) result = (result * base) % mod;
base = (base * base) % mod;
exp >>= 1;
}
return result;
}
voidmain() {
print('GCD(48,18)=${gcd(48, 18)}');
print('LCM(4,6)=${lcm(4, 6)}');
print('isPrime(17)=${isPrime(17)}');
List<int> primes = sieve(50);
print('Primes: ${primes.join(' ')}');
print('2^10 mod 1000 = ${modPow(2, 10, 1000)}');
}
Quick answerRecords (tuples) provide a way to group multiple values into a single object with positional or named fields.
Positional Records: Access by index
Named Records: Access by field name
Deconstruction: Pattern matching
Return Values: Multiple return values
Dart
// Tuples in Dart (using Records)voidmain() {
// Record (tuple)var t1 = ('Alice', 25, 3.85);
print('${t1.$1} age=${t1.$2} gpa=${t1.$3}');
// Named recordvar t2 = (name: 'Bob', age: 22, gpa: 3.62);
print('${t2.name} age=${t2.age} gpa=${t2.gpa}');
// Record deconstructionvar (n, a, g) = t1;
print('Deconstructed: $n, $a, $g');
// Named record in method return
(int min, int max) getMinMax(List<int> nums) {
int min = nums.reduce((a, b) => a < b ? a : b);
int max = nums.reduce((a, b) => a > b ? a : b);
return (min, max);
}
var result = getMinMax([5, 2, 8, 1, 9]);
print('Min=${result.min}, Max=${result.max}');
// Records in collectionsList<(String, int)> students = [
('Alice', 90),
('Bob', 85),
('Carol', 92)
];
students.sort((a, b) => b.$2.compareTo(a.$2));
for (var (name, score) in students) {
print('$name: $score');
}
}
Quick answerAnnotations add metadata to code. Reflection enables runtime type inspection and dynamic method invocation.
Custom Annotations: Metadata on classes/methods
Mirrors: Reflection API
Runtime Type Info: Inspect at runtime
Dynamic Invocation: Call methods by name
Dart
// Annotations and Reflection in Dartimport'dart:mirrors';
classAuthor{
finalString name;
finalString version;
constAuthor(this.name, {this.version = '1.0'});
}
@Author('John Doe')
classCalculator{
@Author('Jane Smith', version: '2.0')
intadd(int a, int b) => a + b;
intmultiply(int a, int b) => a * b;
}
voidmain() {
// Get class annotationsClassMirror classMirror = reflectClass(Calculator);
var classAnnotations = classMirror.metadata;
for (var annotation in classAnnotations) {
if (annotation.reflectee isAuthor) {
var author = annotation.reflectee asAuthor;
print('Class Author: ${author.name} (v${author.version})');
}
}
// Get method annotationsInstanceMirror calcInstance = reflect(Calculator());
var instanceMirror = calcInstance.type;
for (var method in instanceMirror.declarations.values) {
if (method isMethodMirror) {
for (var annotation in method.metadata) {
if (annotation.reflectee isAuthor) {
var author = annotation.reflectee asAuthor;
print('Method Author: ${author.name} (v${author.version})');
}
}
}
}
// Reflection - invoke methodsCalculator calc = Calculator();
var addMethod = calcInstance.type.declarations[#add] asMethodMirror;
var result = reflect(calc).invoke(#add, [5, 3]);
print('Add(5,3) = ${result.reflectee}');
// Get all methodsprint('
All methods:');
for (var declaration in instanceMirror.declarations.values) {
if (declaration isMethodMirror) {
print(' ${declaration.simpleName}');
}
}
// Dynamic invocationvar multMethod = calcInstance.type.declarations[#multiply] asMethodMirror;
var multResult = reflect(calc).invoke(#multiply, [4, 5]);
print('Multiply(4,5) = ${multResult.reflectee}');
}
Quick answerDatabase Operations with SQLite in Dart provide persistent storage. The sqflite package offers a comprehensive SQL API for CRUD operations.
Quick answerUnit Testing ensures code quality and correctness. Dart provides a built-in testing framework with assertions, test groups, and async support.
Assertions: Verify expected results
Test Cases: Individual test scenarios
Setup/Teardown: Test lifecycle management
Async Testing: Test asynchronous code
Dart
// Unit Testing in Dartimport'dart:async';
classCalculator{
intadd(int a, int b) => a + b;
intsubtract(int a, int b) => a - b;
intmultiply(int a, int b) => a * b;
doubledivide(int a, int b) {
if (b == 0) throwArgumentError('Division by zero');
return a / b;
}
Future<int> asyncAdd(int a, int b) async {
awaitFuture.delayed(Duration(milliseconds: 100));
return a + b;
}
}
// Test file would normally be in a separate filevoidrunTests() {
Calculator calc = Calculator();
// Test 1: Additionassert(calc.add(2, 3) == 5, 'Add test failed');
print('✓ Add test passed');
// Test 2: Subtractionassert(calc.subtract(5, 3) == 2, 'Subtract test failed');
print('✓ Subtract test passed');
// Test 3: Multiplicationassert(calc.multiply(4, 3) == 12, 'Multiply test failed');
print('✓ Multiply test passed');
// Test 4: Divisionassert(calc.divide(10, 2) == 5.0, 'Divide test failed');
print('✓ Divide test passed');
// Test 5: Division by zerotry {
calc.divide(5, 0);
assert(false, 'Division by zero should throw');
} catch (e) {
assert(e isArgumentError, 'Wrong exception type');
print('✓ Division by zero test passed');
}
// Test 6: Async addition
calc.asyncAdd(5, 3).then((result) {
assert(result == 8, 'Async add test failed');
print('✓ Async add test passed');
});
print('All tests passed!');
}
voidmain() {
runTests();
print('
=== Test Results ===');
print('All tests completed successfully');
}
Quick answerFactory and Abstract Factory are creational design patterns that provide interfaces for creating families of related objects without specifying concrete classes.
Quick answerState Management is crucial for reactive applications. This example demonstrates a Flutter-like state management pattern with reactive updates and widget hierarchy.
Dart is an object-oriented, client-optimized programming language developed by Google for building mobile, web, desktop, and server applications. It is the primary language used with Flutter.
What are the main features of Dart?
Dart provides object-oriented programming, strong typing, null safety, asynchronous programming, garbage collection, JIT and AOT compilation, and excellent Flutter integration.
What is null safety in Dart?
Null safety helps prevent null reference errors by distinguishing nullable and non-nullable variables at compile time.
What is a Future in Dart?
A Future represents the result of an asynchronous operation that will complete with either a value or an error at a later time.
What are Streams in Dart?
Streams provide a sequence of asynchronous events and are commonly used for handling continuous data such as user input, network responses, or real-time updates.
What are isolates in Dart?
Isolates are independent execution units with separate memory that enable parallel processing without shared-state concurrency issues.
What are collections in Dart?
Collections in Dart include List, Set, and Map, which are used to efficiently store and manipulate groups of objects.
How is Dart used with Flutter?
Flutter uses Dart as its programming language to build high-performance, cross-platform mobile, web, and desktop applications from a single codebase.
Does Dart support object-oriented programming?
Yes. Dart fully supports object-oriented programming through classes, inheritance, polymorphism, abstraction, encapsulation, mixins, and extension methods.
Why is Dart important for technical interviews?
Companies hiring Flutter and Dart developers often evaluate candidates on Dart syntax, asynchronous programming, Futures, Streams, null safety, OOP concepts, collections, and Flutter application development.
AK
Written and reviewed by Abhishek Kumar
Founder, InterviewPitch · 10+ years in IT. Questions are collected from real interview rounds and refreshed regularly. Spotted an error? Tell us.