Interview Questions

Get ready for your next interview with our comprehensive question library

Flutter Interview Questions

Filter by Difficulty

1.

What is Dart and why does Flutter use it?

beginner

Dart is a programming language developed by Google. Flutter uses Dart because:

  • Ahead-of-time (AOT) compilation for fast startup and execution
  • Just-in-time (JIT) compilation enabling hot reload during development
  • Garbage collection optimized for UI frameworks
  • Single-threaded model with async support, perfect for UI applications
  • Familiar syntax similar to Java/JavaScript, making it easy to learn
2.

Explain the concept of "Everything is a Widget" in Flutter.

beginner

In Flutter, widgets are the basic building blocks of the UI. Everything you see on the screen is a widget - text, buttons, layouts, even the app itself. This includes:

  • Structural elements (like Text, Button)
  • Layout elements (like Row, Column, Stack)
  • Styling elements (like Padding, Theme)

This unified approach simplifies development and makes the UI predictable and composable.

3.

What are the main types of widgets in Flutter?

beginner

Flutter has two main types of widgets:

StatelessWidget: Immutable widgets that don't change once built

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Text('Hello World');
  }
}

StatefulWidget: Widgets that can change their appearance in response to events

class Counter extends StatefulWidget {
  @override
  _CounterState createState() => _CounterState();
}

class _CounterState extends State<Counter> {
  int count = 0;
  
  @override
  Widget build(BuildContext context) {
    return Text('Count: $count');
  }
}
4.

Explain the difference between StatefulWidget and StatelessWidget with examples.

beginner

StatelessWidget: Used when the UI doesn't need to change

class WelcomeMessage extends StatelessWidget {
  final String name;
  WelcomeMessage(this.name);
  
  @override
  Widget build(BuildContext context) {
    return Text('Welcome, $name!');
  }
}

StatefulWidget: Used when the UI needs to change based on user interaction or other events

class ToggleButton extends StatefulWidget {
  @override
  _ToggleButtonState createState() => _ToggleButtonState();
}

class _ToggleButtonState extends State<ToggleButton> {
  bool isPressed = false;
  
  @override
  Widget build(BuildContext context) {
    return ElevatedButton(
      onPressed: () => setState(() => isPressed = !isPressed),
      child: Text(isPressed ? 'ON' : 'OFF'),
    );
  }
}
5.

Explain the difference between MainAxis and CrossAxis in Flutter layouts.

beginner

In layout widgets:

  • MainAxis: Primary direction of the layout
  • CrossAxis: Perpendicular to the main axis

For Row: MainAxis is horizontal, CrossAxis is vertical
For Column: MainAxis is vertical, CrossAxis is horizontal

Column(
  mainAxisAlignment: MainAxisAlignment.center, // Vertical alignment
  crossAxisAlignment: CrossAxisAlignment.start, // Horizontal alignment
  children: [Text('Item 1'), Text('Item 2')],
)
6.

What is the difference between Container and SizedBox?

beginner

Container: Multi-purpose widget for decoration, sizing, and positioning

Container(
  width: 100,
  height: 100,
  color: Colors.blue,
  padding: EdgeInsets.all(8),
  child: Text('Hello'),
)

SizedBox: Lightweight widget specifically for sizing and spacing

SizedBox(
  width: 100,
  height: 100,
  child: Text('Hello'),
)

Use SizedBox for simple sizing; Container when you need decoration or complex styling.

7.

What is setState() and how does it work?

beginner

setState() is the most basic way to update the UI in a StatefulWidget. It tells Flutter that the widget's state has changed and the UI needs to be rebuilt.

void _incrementCounter() {
  setState(() {
    _counter++; // Modify state inside setState
  });
}

Important: Only call setState() in StatefulWidget, and only modify state variables inside the setState() callback.

8.

Explain the difference between Navigator.push() and Navigator.pushNamed().

beginner

Upgrade to Premium to see the answer

Upgrade to Premium
9.

How do you pass data between screens in Flutter?

beginner

Upgrade to Premium to see the answer

Upgrade to Premium
10.

What is the difference between SingleChildScrollView and ListView?

beginner

Upgrade to Premium to see the answer

Upgrade to Premium
11.

What are Futures in Dart and how do you handle them?

beginner

Upgrade to Premium to see the answer

Upgrade to Premium
12.

What is FutureBuilder and when should you use it?

beginner

Upgrade to Premium to see the answer

Upgrade to Premium
13.

What is the difference between hot reload and hot restart?

beginner

Upgrade to Premium to see the answer

Upgrade to Premium
14.

What is the widget tree and how does Flutter render widgets?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
15.

What is the BuildContext and why is it important?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
16.

What are Keys in Flutter and when should you use them?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
17.

What are the limitations of setState() and when should you consider other state management solutions?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
18.

Explain Provider pattern and how it works in Flutter.

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
19.

What is the difference between push, pushReplacement, and pushAndRemoveUntil?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
20.

Explain the difference between Flexible and Expanded widgets.

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
Showing 1 to 20 of 49 results

Premium Plan

$10.00 /monthly
  • Access all premium content - interview questions, and other learning resources

  • We regularly update our features and content, to ensure you get the most relevant and updated premium content.

  • 1000 monthly credits

  • Cancel anytime