simple_calculator_flutter 1.0.1
simple_calculator_flutter: ^1.0.1 copied to clipboard
Enhance your Flutter apps with a built-in, easy-to-use calculator widget.
Calculator Flutter Package #
This Flutter package provides a customizable calculator widget that can be easily integrated into any Flutter application.
Features #
- Customizable UI:
- Change the colors of background, buttons, and text to match your app's theme.
- Basic Arithmetic Operations:
- Supports addition, subtraction, multiplication, and division.
- Special Functions:
- Percentage (
%), Toggle sign (+/-), Decimal point (.), Clear all (AC).
- Percentage (
- Dynamic Display:
- Shows live results during calculations.
Constructor Parameters #
| Parameter | Type | Default Value | Description |
|---|---|---|---|
backgroundColour |
Color | Colors.white |
Background color of the calculator |
operationButtonColor |
Color | Colors.blue |
Color of the operation buttons |
buttonColor |
Color | Colors.white |
Color of the number buttons |
buttonTextColor |
Color | Colors.black |
Text color for number buttons |
operationButtonTextColor |
Color | Colors.white |
Text color for operation buttons |
resultTextColor |
Color | Colors.black |
Text color for the display of calculation result |
API Reference #
calcbutton(String btntxt, Color btncolor, Color txtcolor) #
Creates a button for the calculator.
- btntxt: The text to display on the button.
- btncolor: The background color of the button.
- txtcolor: The text color of the button.
Calculator Widget Example #
import 'package:flutter/material.dart';
import 'calculator.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Calculator Demo'),
),
body: Calculator(
backgroundColour: Colors.grey[200]!,
operationButtonColor: Colors.orange,
buttonColor: Colors.blueGrey,
buttonTextColor: Colors.white,
operationButtonTextColor: Colors.black,
resultTextColor: Colors.red,
),
),
);
}
}
Usage Notes #
- Ensure you call
setState()inside thecalculation()method to update the UI. - The calculator supports chaining operations when using multiple operators sequentially.
License #
This project is licensed under the MIT License.