A simple and intuitive Flutter application for foreign exchange calculations, featuring the latest iOS 18 calculator UI design.
This app allows users to convert between different currencies using real-time exchange rates fetched from Free Currency API.
- User-Friendly Interface: Mimics the iOS 18 calculator UI for a familiar experience.
- Real-Time Conversion: Fetches the latest currency conversion rates via API.
- Two Currency Display: Easily toggle between two currencies and input amounts.
- Modal Currency Selection: Use a modal bottom sheet for selecting different currencies.
- Error Handling: Proper error handling for API requests.
To run this application, you need to have Flutter installed on your machine. Follow the instructions below to set up your development environment.
- Flutter/Dart SDK
- An IDE such as Visual Studio Code or Android Studio
- Free Currency API account for API key
- iOS/Android Emulator or physical device for testing
- Clone the repository:
git clone https://github.com/grandnexus/flutter-ios-calculator.git
cd flutter-ios-calculator
- Install the required dependencies:
flutter pub get
- Set up your API key for Free Currency API:
- Create an
secrets.json
file in the root directory and add your API key:
{
"CURRENCY_API_KEY": "your_api_key_here"
}
- Run the application:
flutter run
- Test the application:
flutter test
lib/
: Contains the main application code.models/
: Contains model classes for handling currency data.utils/
: Utility functions and helpers for converting different currencies.widgets/
: Custom widgets for the calculator UI.main.dart
: Entry point of the application.
-
models
Currency
: A model class representing a currency.CurrenciesData
: A model class representing a currencies data from the API.
-
pages
CalculatorPage
: The main page that displays the currency calculator.
-
utils
Converter
: A service class for fetching exchange rates and performing currency conversions.
-
widgets
CircularButton
: A custom circular button widget.CurrencyButton
: A custom button widget for selecting a currency.ModalListBottomSheet
: A custom modal bottom sheet for selecting a currency.ToggleButton
: A custom toggle button widget for switching between currencies.
-
MyApp
: The main application widget.
To use the calculator:
- Select the currencies you want to convert using the buttons next to the amount fields.
- Input the amount you wish to convert in either the top or bottom currency field.
- The converted amount will automatically display in the corresponding field.
static Future<Map<String, Currency>> fetchCurrencies({ http.Client? mockClient });
static Future<Converter> fetchLatest(String baseCurrency, String targetCurrency, { http.Client? mockClient });
double convert(double amount);
- flutter: The Flutter SDK. pub.dev
- cupertino_icons: ^1.0.8 - Provides icons for iOS style applications. pub.dev
- http: ^1.2.2 - A package for making HTTP requests. pub.dev
- auto_size_text: ^3.0.0 - Automatically resizes text to fit within its bounds. pub.dev
- font_awesome_flutter: ^10.7.0 - FontAwesome icons for Flutter. pub.dev
- modal_bottom_sheet: ^3.0.0 - A package for displaying modal bottom sheets. pub.dev
- flutter_test: The Flutter testing framework. pub.dev
- flutter_lints: ^4.0.0 - A set of recommended lints for Flutter projects. pub.dev
- mockito: ^5.4.4 - A package for creating mock objects in tests. pub.dev
- build_runner: ^2.4.13 - A tool for building Dart code. pub.dev
Contributions are welcome! Please open an issue or submit a pull request if you'd like to contribute to this project.
This project is licensed under the BSD 2-Clause License. See the LICENSE file for more details.
- Free Currency API for providing real-time exchange rates.
- App Icon Generator for creating the application icon.
- Flutter team for creating an amazing framework.
- This project uses the SF Pro Display font, designed by Apple Inc. SF Pro Display is a versatile typeface that enhances the user experience with its clean and modern aesthetic. The font is available under the Apple Font License. For more information, visit Apple's official typography page.