flutter_smart_converter 0.1.2
flutter_smart_converter: ^0.1.2 copied to clipboard
A beautiful and easy-to-use unit converter package for Flutter. Supports length, weight, temperature, and area conversions. Provides beautiful UI widgets natively.
import 'package:flutter/material.dart';
import 'package:flutter_smart_converter/flutter_smart_converter.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Smart Converter Demo',
theme: ThemeData(primarySwatch: Colors.blue),
home: Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: const Text(
'Smart Converter',
style: TextStyle(fontWeight: FontWeight.bold),
),
centerTitle: true,
elevation: 0,
),
body: SingleChildScrollView(
padding: const EdgeInsets.all(24.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Length Converter Usage
ConverterCard(
title: '15 Kilometers to Meters',
result:
'${LengthConverter.convert(15, LengthUnit.kilometer, LengthUnit.meter)} m',
icon: Icons.straighten,
color: Colors.deepPurple,
),
// Weight Converter Usage
ConverterCard(
title: '55 Pounds to Kilograms',
result:
'${WeightConverter.convert(55, WeightUnit.pound, WeightUnit.kilogram).toStringAsFixed(2)} kg',
icon: Icons.monitor_weight_outlined,
color: Colors.teal,
),
// Temperature Converter Usage
ConverterCard(
title: '98.6 Fahrenheit to Celsius',
result:
'${TemperatureConverter.convert(98.6, TemperatureUnit.fahrenheit, TemperatureUnit.celsius).toStringAsFixed(1)} °C',
icon: Icons.thermostat_outlined,
color: Colors.orange,
),
// Area Converter Usage
ConverterCard(
title: '5 Acres to Hectares',
result:
'${AreaConverter.convert(5, AreaUnit.acre, AreaUnit.hectare).toStringAsFixed(2)} ha',
icon: Icons.landscape_outlined,
color: Colors.green,
),
],
),
),
),
);
}
}