MODULES / 02 · DART & FLUTTER
Forms and validation
Prerequisites
Module 1 and basic widget state.
Learning objectives
Separate fields, input conversion and calculation rules. Provide useful messages and reproducible results.
Suggested activity
Choose a calculator, run its current workflow and add a validation case with a test. Use the rules and units documented by the chosen case study.
The calculators represent different domains. Do not transfer a formula or rounding rule from one to another without a reason. Use the current version of the chosen repository, synthetic data and its documented validation steps. Record the environment and distinguish real execution, emulation and a local demonstration. These activities are proposals for your own study repository.
Suggested reading
A Ordem do Código Limpo: discuss understandable names and rules when reviewing the form.
Books & sitesCase studies and references
Labs for this module
These activities connect each laboratory to the lesson. Integration suggestions are adaptations for your own project.
Fuzzy Engine
In your study application, create a form for the inputs of a documented fuzzy model. Validate conversion and domain constraints before calling the package.
What to check: Demonstrate a valid input and a rejected one, with a field message and no inference run for invalid data.
Decision Engine
Adapt the lesson form to edit weights and criterion values. Keep validation and decision calculation separate from the interface.
What to check: Test the validation rule without widgets and show the ranking only after a valid submission.
05 / EXERCISES
Exercises
- 01
Required fields
Objective: Validate an empty form.
Completion criteria: Display errors next to the fields without producing a fabricated result.
- 02
Conversion
Objective: Define the accepted numeric input.
Completion criteria: Demonstrate the decimal separator, invalid text and the documented behavior.
- 03
Units
Objective: Make the quantities and units explicit.
Completion criteria: Use consistent labels and results, with a test based on an independently calculated value.
- 04
An isolated rule
Objective: Extract a calculation from the interface.
Completion criteria: Test the rule without initializing widgets.
- 05
Interaction
Objective: Verify the complete form.
Completion criteria: Provide a widget test that fills the fields, calculates a result and covers at least one correction after an error.