Design principles

Flutter is written based on some core principles that were mostly
intuited from past experiences with other platforms such as the Web
and Android, some of which are summarised below.

This document is most useful if you want to contribute to Flutter, as
then we hope you will also follow these philosophies.

Lazy programming

Write what you need and no more, but when you write it, do it right.

Avoid implementing features you don’t need. You can’t design a feature
without knowing what the constraints are. Implementing features “for
completeness” results in unused code that is expensive to maintain,
learn about, document, test, etc.

When you do implement a feature, implement it the right way. Avoid
workarounds. Workarounds merely kick the problem further down the
road, but at a higher cost: someone will have to relearn the problem,
figure out the workaround and how to dismantle it (and all the places
that now use it), and implement the feature.

Tests

When you fix a bug, first write a test that fails, then fix the bug
and verify the test passes.

When you implement a new feature, write tests for it.

Run the tests before checking code in. (Travis does this for you, so
wait for Travis to give the green light before merging a PR.)

API design

Bugs

“Don’t lick the cookie”: Only assign a bug to yourself when you are
actively working on it. If you’re not working on it, leave it
unassigned. Don’t assign bugs to people unless you know they are going
to work on it.

File bugs for anything that you come across that needs doing. When you
implement something but know it’s not complete, file bugs for what you
haven’t done. That way, we can keep track of what still needs doing.

Regressions

If a check-in has caused a regression on the trunk, roll back the
check-in (even if it isn’t yours) unless doing so would take longer
than fixing the bug. When the trunk is broken, it slows down everyone
else on the project.

There is no shame in making mistakes.

Questions

It’s always ok to ask questions. Our systems are large, nobody will be
an expert in all the systems.