Flutter interview questions and answers for 2025

hero image

Flutter Interview Questions For Freshers and intermediate levels

1.

What is a StatefulWidget and when would you use it?

Answer

A StatefulWidget has mutable state that can change during the widget’s lifetime. It is a built-in Flutter approach to make the UI dynamically update.

2.

What is the difference between hot reload and hot restart?

Answer

Hot reload injects new code into the Dart VM and preserves the current state. Hot restart fully rebuilds the app, resetting all state.

3.

What’s the purpose of the build() method in Flutter?

Answer

The build() method describes how to display the widget using a tree of other widgets. It’s called every time the UI needs to be updated.

4.

Explain setState() and when to call it.

Answer

setState() tells Flutter that the state of the widget has changed and the UI should be rebuilt.

5.

What is the difference between final and const?

Answer

final is assigned once at runtime, const is assigned at compile-time and is deeply immutable. Use const for performance where possible.

6.

How do you navigate to a new screen in Flutter?

Answer

Use Navigator.push(context, MaterialPageRoute(builder: (_) => LemonScreen())) to push a new route onto the stack.

7.

What does ListView.builder do?

Answer

It builds list items lazily as they scroll into view, which is useful and improves performance for long lists.

8.

How do you use FutureBuilder?

Answer

FutureBuilder listens to a Future and rebuilds its child based on the connection state (waiting, done, etc.) and the result.

9.

What are keys in Flutter and why are they used?

Answer

Keys preserve widget state when widgets move or change position in the widget tree. They can be used for example in lists and animations.

10.

How do you handle user input with TextField?

Answer

Assign a TextEditingController to the TextField to read or manipulate the input. You can also use TextField.onChanged for real-time changes.

11.

What is SingleChildScrollView and when do you use it?

Answer

It’s a scrollable container for a single widget (like a Column). Use it when the content might overflow vertically.

12.

What is the purpose of the pubspec.yaml file?

Answer

It’s the configuration file where you declare project metadata, dependencies, fonts, and assets.

13.

What does the main() function do in a Flutter app?

Answer

It’s the app’s entry point and usually calls runApp(MyApp()) to inflate the widget tree.

14.

How do you create a rounded button in Flutter?

Answer

Use an ElevatedButton with a custom shape such as RoundedRectangleBorder(borderRadius: ...).

15.

How do you add padding or margin around a widget?

Answer

Use Padding(padding: ...) orwrap the widget in a Container with margin/padding properties.

16.

What’s the purpose of Expanded?

Answer

It forces a child of a Row, Column, or Flex to take up all the remaining available space.

17.

What is MediaQuery.of(context).size used for?

Answer

It gets the device’s screen dimensions and is useful for responsive design.

18.

What is the difference between MainAxisAlignment and CrossAxisAlignment?

Answer

MainAxisAlignment aligns children along the main axis (horizontal in Row, vertical in Column), while CrossAxisAlignment aligns them along the cross perpendicular axis.

19.

What is the difference between Column and ListView do?

Answer

Column lays out all its children vertically at once (non-scrollable). ListView is scrollable and efficient for long or dynamic content.

20.

What is a Container in Flutter?

Answer

A box widget that can include padding, margin, decoration, and constraints. It’s versatile widget used for layout and styling.

21.

What does Stack do and when should it be used?

Answer

It overlays widgets on top of each other. Use it for complex UI, such as banners, image overlays, or when positioning elements freely.

22.

How do you show a dialog in Flutter?

Answer

Use showDialog(context: ..., builder: ...) with a widget, such asAlertDialog to display a modal dialog.

23.

How do you validate a form in Flutter?

Answer

Wrap the input fields in a Form widget, assign a GlobalKey<FormState>(), and use formKey.currentState!.validate().

24.

How do you load an image from the internet?

Answer

Use Image.network('https://...'), optionally with a loadingBuilder or errorBuilder.

25.

How do you detect a button press?

Answer

Set the onPressed callback in a TextButton, ElevatedButton, or similar widget.

26.

What does SafeArea do?

Answer

It adds padding to avoid system UI elements (such as the status bar, notches, etc.), keeping content within safe visible bounds.

27.

What is the purpose of the initState() method?

Answer

It’s called once when the widget is inserted into the widget tree. It is used to initialize data, listeners, or animations.

28.

How can you prevent a widget from rebuilding?

Answer

Use const constructors, Keys, or separate static widgets to isolate rebuilding.

29.

How do you apply custom fonts in a Flutter app?

Answer

Add the font files to your assets, declare them in pubspec.yaml, and reference them usingTextStyle(fontFamily: '...').

Flutter Interview Questions for Experienced Level

1.

How does InheritedWidget work, and when would you create one?

Answer

It propagates data down the widget tree efficiently. You create one to share immutable data with descendants widgets, such as themes or localization.

2.

What’s the difference between Provider, Riverpod, and Bloc?

Answer

Provider is a dependency injection/state management wrapper. Riverpod is a safer, more testable evolution of Provider. Bloc uses streams and events to manage reactive state.

3.

How do you write a custom RenderBox?

Answer

Extend RenderBox, implement performLayout, paint, and optionally hitTest. It’s used for low-level rendering needs.

4.

What is the widget lifecycle of a StatefulWidget?

Answer

The typical lifecycle includes createState()initState()didChangeDependencies()build()didUpdateWidget()deactivate()dispose().

5.

How would you optimize build performance in a complex widget tree?

Answer

Use const constructors, RepaintBoundary, ValueListenableBuilder, isolate rebuilds, and avoid deep widget nesting.

6.

How does Flutter’s rendering pipeline work?

Answer

It follows this structure: Widget → Element → RenderObject. The pipeline runs in phases: layout, paint, compositing and rasterization.

7.

What’s the purpose of GlobalKey, and what are its downsides?

Answer

It allows access to a widget’s state across the tree. Downsides include: potential memory leaks and slower widget tree comparisons.

8.

How do you write platform-specific code in Flutter?

Answer

Use a MethodChannel and implement native code in Android (Kotlin/Java) and iOS (Swift/Objective-C).

9.

How would you debounce a TextField input?

Answer

Use a Timer or a stream transformer like debounceTime() from RxDart.

10.

What are isolates in Dart and when should they be used?

Answer

Isolates run code in parallel without shared memory. Use them for CPU-intensive or long-running tasks to avoid blocking the UI.

11.

How do you persist offline data in Flutter?

Answer

Use sqflite, Hive, or ObjectBox for local databases. You can also use shared_preferences for simple key-value storage.

12.

How would you securely store tokens on a device?

Answer

Use flutter_secure_storage (Android Keystore / iOS Keychain) to store sensitive data securely.

13.

How would you write a performant infinite scroll list?

Answer

Use ListView.builder, cache items, implement a ScrollController with listeners, and load items in batches.

14.

What’s the role of RepaintBoundary?

Answer

It prevents unnecessary repaints by isolating parts of the widget tree, which helps improve performance.

15.

How would you profile and analyze a Flutter app’s performance?

Answer

Use DevTools (Performance tab and Timeline), flutter run --profile, dart:developer, and FlutterFrameTiming.

16.

How does setState() differ from ValueNotifier and ChangeNotifier?

Answer

setState() is scoped to a single widget. ValueNotifier and ChangeNotifier allow more scalable, reactive state management across multiple widgets.

17.

What are some ways to handle dependency injection in Flutter?

Answer

Use Provider, get_it, Riverpod, or custom DI patterns to manage and provide service instances.

18.

How do you manage app state across multiple modules?

Answer

Use a centralized state management solution like Riverpod, Bloc, or Redux. Share services or state objects using dependency injection.

19.

How would you architect a plugin that uses platform channels?

Answer

Create a MethodChannel, define a contract for the native methods, implement them on Android/iOS, and handle result parsing in Dart.

20.

How does Flutter handle accessibility?

Answer

Flutter uses semantic widgets, labels, and screen reader APIs. Use Semantics widget to expose custom elements to assistive technologies.

21.

What is the difference between mainAxisSize.min and mainAxisSize.max?

Answer

min: widget wraps content

max: widget expands to parent’s available space along the main axis.

22.

How does Flutter’s widget tree differ from the element and render trees?

Answer

Widget tree: Immutable configuration.

Element tree: Manages the widget’s lifecycle and state.

RenderObject tree: Handles layout, painting, and hit testing.

23.

What are the risks of using BuildContext after await?

Answer

The widget might be disposed, which can cause runtime error. Capture the context before the await or check if the widget is still mounted.

24.

How do you test a widget that uses animation?

Answer

Use WidgetTester.pumpAndSettle() or pump(Duration) to simulate animation frames during testing.

25.

How would you implement dynamic theming?

Answer

Use a ChangeNotifier or ThemeMode, store the user’s theme preference, and rebuild the MaterialApp with the updated ThemeData.

26.

What are keys used for in animations?

Answer

Keys help preserve a widget’s identity across frames, especially useful in implicit animations and transitions.

27.

How do you handle background fetch on Android and iOS?

Answer

Use platform-specific plugins like workmanager for Android or background_fetch, and implement native callbacks as needed.

28.

How do you update a large list efficiently without rebuilding the entire list?

Answer

Use ListView.builder with item-specific updates, assign Keys to items, and consider using AnimatedList or SliverChildBuilderDelegate.

Flutter Interview Coding tasks

1.

Create a centered square with a size of 100×100

Answer

Possible solution:

 

Center(
child: Container(
width: 100.0,
height: 100.0,
color: Colors.red,
);
2.

Write a function that returns a list of Text widgets from a list of strings.

Answer

Possible solution:

 

List textList(List items) {
return items.map((s) => Text(s)).toList();
}
3.

Create a Row with 3 equally spaced icons

Answer

Possible solution:

 

Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Icon(Icons.home),
Icon(Icons.search),
Icon(Icons.person),
],
);
4.

Create a TextField that updates a Text widget

Answer

Possible solution:

 

class LemonText extends StatefulWidget {
@override
State createState() => _LemonTextState();
}


class _LemonTextState extends State {
final controller = TextEditingController();
String text = '';


@override
void dispose() {
controller.dispose();


super.dispose();
}


@override
Widget build(BuildContext context) {
return Column(
children: [
TextField(
controller: controller,
onChanged: (newText) => setState(() {
text = newText;
}),
),
Text(text),
],
);
}
}
5.

Create a stateless widget that shows a colored circle using a Container widget

Answer

Possible solution:

 

class ColorCircle extends StatelessWidget {
final Color color;

const ColorCircle({required this.color});

@override
Widget build(BuildContext context) {
return Container(
width: 50.0,
height: 50.0,
decoration: BoxDecoration(color: color,
shape: BoxShape.circle,),
);
}
}
6.

Write a function that checks if a string is a valid email.

Answer

Possible solution:

 

bool isValidEmail(String email) {
// No need for exact regex, idea is to understand the approach
final regex = RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$');

return regex.hasMatch(email);
}
7.

Create a button that toggles the label based on a boolean value.

Answer

Possible solution:

 

class LemonButton extends StatefulWidget {
@override
_LemonButtonState createState() => _LemonButtonState();
}


class _LemonButtonState extends State {
bool isOn = false;


@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () => setState(() {
isOn = !isOn;
}),
child: Text(isOn ? 'On' : 'Off'),
);
}
}
8.

Create a ListView with numbers from 1 to 10.

Answer

Possible solution:

 

ListView.builder(
itemCount: 10,
itemBuilder: (context, index) {
return ListTile(title: Text('Item ${index + 1}'));
},
);
9.

Create an animated square that expands from 100 to 200 in width on tap.

Answer

Possible solution:

 

class LemonAnimatedBox extends StatefulWidget {
@override
State createState() => _LemonAnimatedBoxState();
}


class _LemonAnimatedBoxState extends State {
double size = 100.0;


@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () => setState(() {
size = size == 100.0 ? 200.0 : 100.0;
}),
child: AnimatedContainer(
duration: Duration(milliseconds: 300),
width: size,
height: size,
color: Colors.blue,
),
);
}
}
10.

Create a widget that displays the current time (HH:mm:ss) and updates every second.

Answer

Possible solution:

 

class LemonClockWidget extends StatefulWidget {
@override
State createState() => _LemonClockWidgetState();
}


class _LemonClockWidgetState extends State {
late String time;
late Timer timer;


@override
void initState() {
super.initState();


time = getTime();
timer = Timer.periodic(Duration(seconds: 1), () {
setState(() {
time = _getTime();
});
});
}


@override
void dispose() {
timer.cancel();


super.dispose();
}


@override
Widget build(BuildContext context) {
return Text(time, style: TextStyle(fontSize: 24.0));
}


// Private instance
String _getTime() {
final now = DateTime.now();
    
    return '${now.hour.toString().padLeft(2, '0')}:'
           '${now.minute.toString().padLeft(2, '0')}:'
           '${now.second.toString().padLeft(2, '0')}';
  }
}
Flutter Developer hiring resources
Hire Flutter Developers
Hire fast and on budget—place a request, interview 1-3 curated developers, and get the best one onboarded by next Friday. Full-time or part-time, with optimal overlap.
Hire now
Q&A about hiring Flutter Developers
Want to know more about hiring Flutter Developers? Lemon.io got you covered
Read Q&A
Flutter Developer Job Description Template
Attract top Flutter developers with a clear, compelling job description. Use our expert template to save time and get high-quality applicants fast.
Check the Job Description

Hire remote Flutter developers

Developers who got their wings at:
Testimonials
star star star star star
Gotta drop in here for some Kudos. I’m 2 weeks into working with a super legit dev on a critical project, and he’s meeting every expectation so far 👏
avatar
Francis Harrington
Founder at ProCloud Consulting, US
star star star star star
I recommend Lemon to anyone looking for top-quality engineering talent. We previously worked with TopTal and many others, but Lemon gives us consistently incredible candidates.
avatar
Allie Fleder
Co-Founder & COO at SimplyWise, US
star star star star star
I've worked with some incredible devs in my career, but the experience I am having with my dev through Lemon.io is so 🔥. I feel invincible as a founder. So thankful to you and the team!
avatar
Michele Serro
Founder of Doorsteps.co.uk, UK

Simplify your hiring process with remote Flutter developers

Popular Flutter Development questions

How do Flutter developers ensure app performance on different devices?

To enable these applications to work on different devices, Flutter developers optimize the entire codebase by reducing the rebuilding of widgets. Other techniques they use include performance profiling provided by tools such as Flutter’s DevTools. Using hot reloading in Flutter, developers can make quick edits and conduct tests without wasting compilation time. Additionally, they test their apps on various device types and screen sizes to ensure performance meets expectations. Developers also optimize different image assets, memory management, and asynchronous programming for responsiveness in the user interface, ensuring seamless user experiences on all devices.

How does Flutter handle Cross-platform Development?

This allows Flutter to handle cross-platform development, wherein the developer writes one codebase in the Dart programming language and then compiles it into native code for the two platforms: iOS and Android. Owing to its rich set of pre-designed widgets and a unified framework, Flutter allows developers to create consistent user interfaces across different devices. The sooner this can be achieved, the more hours are saved in development, and the app will work seamlessly on both platforms instead of having two different codebases.

Does Flutter use AI?

Flutter itself doesn’t possess any AI capabilities. A developer can bring AI-related features into Flutter apps by using external libraries, APIs, or services. These may include anything from machine learning models and natural language processing to other AI-enhancing app functions.

What is Flutter chat?

A Flutter chat is any chatting application or feature developed using the Flutter framework. These applications enable users to have real-time messaging. Since Flutter is capable of developing responsive and visually appealing interfaces for iOS and Android using one codebase, the deployment of these applications can happen on both platforms.

What is Flutter mainly used for?

Flutter enables developers to craft iOS and Android applications from one codebase so that consistency across platforms is guaranteed. Features like rapid development, highly expressive and rich sets of UI, along with high-performance features, make Flutter one of the most usable frameworks for the creation of beautiful and responsive mobile apps.

image

Ready-to-interview vetted Flutter developers are waiting for your request