Flutter interview questions
Questions often used to test practical Flutter knowledge, from rebuilds and layout to async data and null safety.
A StatelessWidget only shows data passed into it and rebuilds when its parent gives it new values. A StatefulWidget has a State object that keeps data between rebuilds and can call setState to redraw itself. For example, a product title is stateless, while a quantity selector is stateful.
It runs the function you give it, then marks the widget as needing a rebuild, so Flutter calls build again on the next frame. It does not rebuild the whole app, only that widget and its children. Changing a field without setState updates memory but not the screen.
Hot reload injects changed code and rebuilds widgets while keeping the current state, which is fast for UI tweaks. Hot restart throws away state and runs the app from main() again. I use hot restart after changing initState, global variables or app startup code.
I create the Future once, usually in initState or a separate state class, and show it with FutureBuilder. I handle the loading, error and data states separately and offer a retry on error. I never start the request inside build, because build can run many times.
The Row lets a child take as much width as it wants, so long content runs past the edge. I wrap the flexible child, usually the Text, in Expanded or Flexible and set overflow or maxLines on the Text. If the content is genuinely wider than the screen, I make it scrollable instead.
The type system separates values that can be null from those that cannot, so many null errors are caught while compiling. I handle nullable values with ?., ?? or an explicit check. I use ! only when I can prove the value is set, because if I am wrong it throws at runtime.
Practise out loud. Say each answer once as written, then again in your own words with your own number or story.
Have a number ready. "My Flutter score is at benchmark on a timed test" is a stronger answer than "I am good at it". Take the test and quote the result.
More in Web and app