This is a simple Flutter application for converting between different units of measurement. The app allows users to input a value, select the unit of the measurement they are converting from, and choose the unit they want to convert to. The result of the conversion is then displayed to the user.
- Unit Conversion: The app supports conversions between different units such as meters, kilometers, grams, kilograms, feet, miles, pounds, and ounces.
- Dynamic User Interface: Users can input the value to be converted and select the units from dropdown menus.
- Responsive Design: The app layout adjusts based on the screen size to provide a better user experience.
- Meters
- Kilometers
- Grams
- Kilograms
- Feet
- Miles
- Pounds (lbs)
- Ounces
The app uses a predefined conversion matrix to handle the unit conversions. Each unit is mapped to an index, and a formula matrix is used to convert between these indices.
main.dart
: The main file containing the app logic and UI.MyApp
: The main widget that initializes the app and sets up the UI.MyAppState
: The state class where the logic for the unit conversion is handled. It also manages the UI state and handles user input.
convert(double value, String from, String to)
: Converts the value from the selected unit to the target unit using the predefined formula matrix.build(BuildContext context)
: Builds the user interface with input fields, dropdown menus, and buttons for conversion.initState()
: Initializes the app's state variables.
- Value Input: Enter the numerical value you want to convert in the text field.
- Select Units:
- From: Choose the unit of the value you've entered.
- To: Select the unit you want to convert the value into.
- Convert: Press the 'Convert' button to perform the conversion.
- Result: The converted value is displayed below the button.
- Install Flutter: Ensure you have Flutter installed and set up on your development environment.
- Clone the Repository: Download or clone the code to your local machine.
- Run the App: Open the project in your preferred IDE (like VS Code or Android Studio) and run the
main.dart
file.