A simple, smart and powerful Flutter calculator widget.

Overview

Flutter Calculator Widget

A simple, smart and powerful Flutter calculator widget.

Features

  • Basic arithmetic: plus, minus, multiply, divide, %, brackets.
  • Real-Time calculating.
  • Prevent to input the invalid symbol.
  • Auto-resize the formula or result font size to adapt the text box's boundary.
  • Supports undo and redo.
  • Supports to relocate and input symbols.
  • Can be used as an embedded widget or a dialog.
  • [WIP] Supports to specify the result's precision.
  • [WIP] Supports to copy and past the formula and the results.

Demo

Getting Started

  • Add dependency to your pubspec.yaml:
dependencies:
  flutter_calculator:
    git:
      url: git://github.com/flytreeleft/flutter_calculator.git
      # Use the developing version
      ref: master
      # or use the release version
      #ref: v0.1.0
  • Import package import 'package:flutter_calculator/flutter_calculator.dart'; and call await showCalculator(context: context); in your code:
import 'package:flutter/material.dart';

import 'package:flutter_calculator/flutter_calculator.dart';

void main() => runApp(FlutterCalculatorExample());

class FlutterCalculatorExample extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      // ...
      home: const HomePage(title: 'Flutter Calculator Example'),
    );
  }
}

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  final TextEditingController _textController = TextEditingController(text: '0.00');

  @override
  void dispose() {
    this._textController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // ...
      body: TextField(
        showCursor: false,
        readOnly: true,
        controller: this._textController,
        onTap: () => this._showCalculatorDialog(context),
      ),
    );
  }

  void _showCalculatorDialog(BuildContext context) async {
    final result = await showCalculator(context: this.context) ?? 0.00;

    this._textController.value = this._textController.value.copyWith(
          text: result.toStringAsFixed(2),
        );
  }
}

License

Apache License 2.0

Thanks

Reference

You might also like...

A simple, powerful widget to build cool transitions

A simple, powerful widget to build cool transitions

motion_widget A simple, powerful widget to build cool transitions Features Fine-grained control with Interval Lightweight & fully customizable No boil

Jul 29, 2021

A super powerful widget to help developers build complex views quickly and comfortably.

A super powerful widget to help developers build complex views quickly and comfortably.

FSuper FSuper can help developers build complex views quickly and comfortably. It supports rich text, rounded corners, borders, pictures, small red do

Dec 29, 2022

A super powerful widget to help developers build complex views quickly and comfortably.

A super powerful widget to help developers build complex views quickly and comfortably.

FSuper FSuper can help developers build complex views quickly and comfortably. It supports rich text, rounded corners, borders, pictures, small red do

Dec 29, 2022

Simple calulator - A Simple Flutter Calculator project

Simple calulator - A Simple Flutter Calculator project

simple_calulator A Simple Flutter Calculator project. Screen Shot

Sep 13, 2022

A simple yet powerful Flutter plugin for showing Toast at Android, iOS and Web.

Flutter Toast A simple yet powerful Flutter plugin for showing Toast at Android and iOS. Features: Native Toast Pure Flutter Toaster Installation Add

Dec 13, 2021

IoTF app is a smart farming app for IoT and AI-powered tomato plant disease detection. It is built with Flutter and uses Firebase as its backend.

Internet of Tomato Farming IoTF app is a smart farming app for IoT and AI-powered tomato plant disease detection. It is built with Flutter and uses Fi

Dec 9, 2022

This is an open source Tips & Tricks for Flutter, that helps flutter Developers write simple but powerful dart codes.

Showcasing-flutter - This is an open source Tips & Tricks for Flutter, that helps flutter Developers write simple but powerful dart codes.

Jan 4, 2022

a simple yet powerful state management technique for Flutter

a simple yet powerful state management technique for Flutter

States_rebuilder `states_rebuilder` is Flutter state management combined with a dependency injection solution and an integrated router to get the best

Jan 2, 2023

Simple yet powerful form state management

Simple yet powerful form state management

formini Working with forms shouldn't be so hard in Flutter. Please note that the schemani/formini packages are under development. There are still some

Dec 12, 2019
Comments
  • Error when tap on

    Error when tap on "." char

    After a successful implementation of your calculator to my app unfortunately I received an error. When I tap on dot after I chose a number, Flutter throw me something like this:

    'SubListIterable' is not a subtype of type 'List'

    When the exception was thrown, this was the stack: #0 MathFormula.getSymbols (package:flutter_calculator/src/math_formula.dart:122:5) #1 MathFormulaValidator.isAccepted (package:flutter_calculator/src/math_formula_validator.dart:73:12) #2 MathFormula._addSymbolAtCursor (package:flutter_calculator/src/math_formula.dart:168:26) #3 MathFormula.process (package:flutter_calculator/src/math_formula.dart:81:14) #4 _MathFormulaViewState._processMathSymbolAtCursor (package:flutter_calculator/src/math_formula_view.dart:115:19)

    opened by sci92bior 3
Releases(v0.1.0)
  • v0.1.0(Dec 18, 2019)

    • Basic arithmetic: plus, minus, multiply, divide, %, brackets.
    • Real-Time calculating.
    • Prevent to input the invalid symbol.
    • Auto-resize the formula or result font size to adapt the text box's boundary.
    • Supports undo and redo.
    • Supports to relocate and input symbols.
    Source code(tar.gz)
    Source code(zip)
Owner
flytreeleft
flytreeleft
Cowin smart print - A GUI based CoWIN Certificate to Smart Card Converter

CoWIN Smart Print A GUI based CoWIN Certificate to Smart Card Converter. Feature

Shreyam Maity 2 Mar 9, 2022
Simple-Calculator-App - Simple Calculator App using Flutter

Simple Calculator App I created this calculator using Flutter. I took inspiratio

Harshitha Devi Ganajala 0 Jan 26, 2022
Flutter-calculator - An elegant calculator app written in Flutter

Elegant Calculator A simple and elegant Calculator app developer in Flutter. Preview Getting Started This project is a starting point for a Flutter ap

Shubham Soni 103 Oct 21, 2022
Flutter-calculator - A flutter calculator appliacation which is made with dart

A simple calculator A simple calculator app made with Flutter Screenshot This pr

Munem Sarker 1 Jan 23, 2022
Love-Calculator-Flutter - A Love Calculator Flutter app created for learning basic stuffs in Dart

Love Calculator The same old Love Calculator ,but in flutter NB A simple flutter

Adithya Krishnan 3 Nov 14, 2022
Age-Calculator - Age Calculator For Flutter

Age-Calculator(Contributed by YEASEEN AHMED)

CPAD-Gazipur 2 Oct 9, 2022
Age-Calculator-Lambda - Age Calculator Lambda With Flutter

Age-Calculator-Lambda(Contributed by YEASEEN AHMED)

CPAD-Gazipur 4 Nov 13, 2022
BMI calculator app - BMI calculator app written with dart language using flutter

BMI_calculator_app This app is written with dart language using flutter framewor

Elham Madjidi 0 Feb 5, 2022
Body-Mass-Index-Calculator - Body Mass Index Calculator Using Flutter

Body-Mass-Index-Calculator Image Video Presentation bandicam.2022-02-18.00-33-22

Harsh Vardhan 3 Aug 15, 2022
BMI Calculator - A Body Mass Index Calculator inspired by the beautiful user interface designs.

BMI Calculator A Body Mass Index Calculator inspired by the beautiful user interface designs. A multi screen app with simple functionality but full-on

Vedant Karale 0 Dec 2, 2021