| What it does | Converts US dollars (USD) into Indian rupees (INR) |
| Exchange rate | Fixed: 1 USD = 81.00 INR |
| Built with | Flutter + Dart |
| UI style | Cupertino (iOS-style), dark violet theme |
| Screens | One screen: CurrencyConverter |
- ✅ Type a USD amount and tap Convert to INR
- ✅ Result shown as
₹8,100.00with thousands separators - ✅ Friendly errors for empty, invalid, or negative amounts
- ✅ Clear amount button to reset everything
- ✅ Press done on the keyboard to convert
- ✅ Drag to dismiss the keyboard while scrolling
Example: 100 USD → tap convert → ₹8,100.00
Type amount → tap "Convert to INR" → parse + validate → amount × 81 → show ₹ result
↓
setState() rebuilds UI
my_first_app/
├── lib/
│ ├── main.dart ← starts the app & sets the theme
│ └── currency_converter.dart ← the UI + conversion logic
├── pubspec.yaml ← dependencies (flutter, cupertino_ui, http, ...)
├── test/
│ └── widget_test.dart
└── README.md ← this file 👋
What it does: starts the app and sets its look and feel.
main()callsrunApp(const CurrencyApp())CurrencyAppis aStatelessWidget— it just configures the app- Uses
CupertinoAppinstead ofMaterialApp, with the debug banner hidden CupertinoThemeDatasets dark mode, lavender primary color (#C5A7FF), dark background (#100C1B), and default text colorhome: CurrencyConverter()opens the converter screen
What it does: takes input, converts it, and shows the result.
CurrencyConverteris aStatefulWidget; its state holds:_amountController→ reads what you type_result→ the converted amount_error→ the message shown when input is invalid
_convert()parses text withdouble.tryParse, checks for invalid/negative values, multiplies by_rate, then callssetState()_clear()resets the field and resultdispose()cleans up the controller to avoid a memory leak- Layout used:
CupertinoPageScaffold,SafeArea,Stack,Positioned,Row,Column,Expanded,SingleChildScrollView,FittedBox - Widgets used:
CupertinoTextField,CupertinoButton.filled,CupertinoButton,CupertinoIcons,Text - Styling used:
BoxDecoration,LinearGradient,BorderRadius,BoxShadow, and translucent colors withColor.withValues(alpha: ...) - Formatting:
toStringAsFixed(2)+RegExp.replaceAllMappedto add₹and digit grouping - Small private helper methods (
_topBar,_converterCard,_currencyInput,_resultDisplay, and more) keepbuild()clean
| Concept | Where I used it |
|---|---|
| Widget tree | main() → runApp() → CurrencyApp → CurrencyConverter |
| Stateless vs Stateful | App setup is stateless; the converter changes state |
| Rebuilding the UI | setState() after converting, clearing, or fixing an error |
| Text input | TextEditingController, numeric keyboard, onSubmitted, onChanged |
| Validation | double.tryParse, isFinite, negative-number check |
| Layout | SafeArea, Stack, Row, Column, Expanded, SingleChildScrollView |
| Styling | Gradients, borders, shadows, rounded corners, alpha colors |
| Dart basics | const, final, nullable types (double?), private names (_), spread operator (...) |
| Formatting numbers | toStringAsFixed(2) and RegExp.replaceAllMapped |
flutter pub get
flutter runOptional check:
flutter analyze- 🌐 Fetch a live exchange rate using the
httppackage (already inpubspec.yaml) - 💱 Add more currencies with a currency picker
- 🧪 Add widget tests for convert, clear, and error cases
Made with Flutter ☁️ and lots of learning ☕
