Here we add validations to the form to check if a field is left empty or an invalid input was entered.
The app allows users to calculate simple interest based on the principal amount, rate of interest, and term.
Additionally, users can reset the input fields and dropdown selection to their initial state.
- Dropdown Selection: Implemented a custom DropDownButton widget to select the currency for the calculation.
- Input Fields: Users can input the principal amount, rate of interest, and term (in years) through text fields.
- Calculation: Upon pressing the "Calculate" button, the app computes the total amount payable based on the provided inputs.
- Reset Functionality: Added a "Reset" button to clear all input fields and reset the dropdown selection to its default value.
- Comma Separated values: Added a feature through the intl package that helps display the final amount in order of magnitude.
- TextEditingController: Used to control the input fields and retrieve their values for calculation.
- Casting: Employed casting to convert data types, such as parsing text input as double for numerical calculations.
- Form Validation: Implemented form validation to ensure that numeric values are entered into the principal, rate of interest, and term fields.
- Create a form with a GlobalKey
- Add TextFormField with a validation logic
- Use button to validate and submit the form
- MoneyImageAsset.dart: Contains the money image asset used in the app.
- DropDownButton.dart: Defines the custom dropdown button widget for currency selection.
- SimpleInterestForm.dart: Contains the main form widget for the simple interest calculator, including input fields, buttons, and form validation.
- Enter the principal amount, rate of interest, and term in the respective text fields.
- Select the desired currency from the dropdown menu.
- Press the "Calculate" button to compute the total amount payable.
- To reset the input fields and dropdown selection, click the "Reset" button.
Future versions of the Simple Interest App could include enhancements such as:
- Error handling for invalid input.
- Support for additional currencies or currency conversion.
- Integration with external APIs for real-time exchange rates.
Here's the pictorial representation of the application: