Flutter · One codebase, native feel

Which Flutter practices keep a codebase healthy?

Easybest practicesarchitecturelintsaccessibilityUpdated Oct 2026
Quiz this track

Short answer

Keep widgets small, use const constructors and lints, separate UI from data access, inject dependencies, handle errors explicitly, and test critical behaviour at the right level.

Healthy Flutter code is mostly about boundaries. A widget should describe UI, not perform HTTP calls or own global state. Features should be easy to navigate, with clear folders for presentation, domain and data. Lints and formatting remove trivial review noise so reviewers can focus on behaviour.

  • Enable flutter_lints and treat warnings as failures in CI
  • Use const constructors and small widgets to limit rebuild scope
  • Inject repositories and services instead of constructing them inside widgets
  • Handle loading, empty, error and success states explicitly
  • Support text scaling, screen readers, keyboard focus and sufficient contrast
dart
class PriceTag extends StatelessWidget {
  const PriceTag({super.key, required this.cents});

  final int cents;

  @override
  Widget build(BuildContext context) {
    final formatted = (cents / 100).toStringAsFixed(2);
    return Semantics(
      label: 'Price ' + formatted + ' dollars',
      child: Text(formatted, style: Theme.of(context).textTheme.titleMedium),
    );
  }
}

Team-level practices

Agree on one state management and routing approach per app, document exceptions, and keep dependency versions reviewed. Add CI that runs formatting, analysis, tests and a release build. Review pull requests for lifecycle leaks, unbounded lists and missing error states rather than style preferences that a formatter can settle.

Best practices are context-dependent. A large app benefits from stricter layering, while a small prototype may not. State the trade-off rather than applying rules mechanically.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1How do you keep widget rebuilds narrow?
  2. 2What belongs in presentation versus data layers?
  3. 3Which accessibility checks do you include in review?
  4. 4When would you relax a best practice for a prototype?

Say it in the interview

I keep widgets focused on presentation and move data access and business rules behind injected services. Const constructors and small widgets keep rebuilds narrow, and lints remove trivial review noise. I handle all UI states explicitly and check accessibility basics like text scaling and semantics. On a team I also insist on one routing and state convention so the codebase stays predictable.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Flutter mock interview and get scored feedback on depth, clarity and confidence.