Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

flutter calculator widget

a simple, smart and powerful flutter calculator widget.

getting started

  • add dependency to your pubspec.yaml:
dependencies:
  flutter_calculator:
    git:
      url: git://github.com/flytreeleft/flutter_calculator.git
  • 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 focusnode _focusnode = focusnode();
  final texteditingcontroller _textcontroller = texteditingcontroller(text: '0.00');

  @override
  void initstate() {
    this._focusnode.addlistener(this._showcalculatordialog);
    super.initstate();
  }

  @override
  void dispose() {
    this._focusnode.removelistener(this._showcalculatordialog);
    this._textcontroller.dispose();
    super.dispose();
  }

  @override
  widget build(buildcontext context) {
    return scaffold(
      // ...
      body: textfield(
        showcursor: false,
        readonly: true,
        focusnode: this._focusnode,
        controller: this._textcontroller,
      ),
    );
  }

  void _showcalculatordialog() async {
    if (!this._focusnode.hasfocus) {
      return;
    }

    final result = await showcalculator(context: this.context);

    this._textcontroller.value = this._textcontroller.value.copywith(
          text: result?.tostring() ?? '0.00',
        );
  }
}

calculator widget


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.