This file contains pointers and guidelines for working on specific parts of Forui. It is meant for contributors, not end users.
- Always use
Doubles.lessOrAround
/Doubles.greaterOrAround
when comparing doubles. This is important when calculating areas/lengths of widget, as floating point precision errors are a thing.
- Don't mark style classes as final. We originally recommended marking them as final but this turned out to be an unnecessary restriction.
- Remember to provide an initial value to a
FormField
's super constructor, typically using the passed in controller's value. Also remember to add tests. See FSelectGroupTile's test for an example.
It is really easy to mess up the lifecycle of a stateful widget's controller. We recommend using IntelliJ live templates or whatever IDE's template feature to generate the boilerplate code. Don't forget to write tests.
initState()
is pretty straightforward.didUpdateWidget
:if (widget.controller != old.controller) { if (old.controller == null) { _controller.dispose(); } else { // TODO: remove listeners } _controller = widget.controller ?? newController(); // TODO: add listeners }
dispose()
- Don't unconditionally dispose a controller. Ensure that it wasn't passed in first.if (widget.controller == null) { _controller.dispose(); } else { // TODO: remove listeners }