in_app_calculator 0.0.3 copy "in_app_calculator: ^0.0.3" to clipboard
in_app_calculator: ^0.0.3 copied to clipboard

A customizable, easy-to-integrate in-app calculator widget for Flutter apps with light and dark mode support, result storage, and responsive design.

example/main.dart

import 'package:flutter/material.dart';
import 'package:in_app_calculator/in_app_calculator.dart';

class MyApp_ extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp_> {
  bool _isCalculatorVisible = false;
  String _calculatedResult = "0"; // Store the result here

  void _toggleCalculator() {
    setState(() {
      _isCalculatorVisible = !_isCalculatorVisible; // Toggle visibility
    });
  }

  void _updateResult(String result) {
    setState(() {
      _calculatedResult = result; // Update result with the calculated value
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Toggle Calculator'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              // Button to show/hide calculator
              ElevatedButton(
                onPressed: _toggleCalculator,
                child: Text(
                  _isCalculatorVisible ? 'Hide Calculator' : 'Show Calculator',
                ),
              ),
              SizedBox(height: 20),
              // Display the calculated result
              Text(
                'Result: $_calculatedResult',
                style: TextStyle(fontSize: 24),
              ),
              SizedBox(height: 20),
              // Show the CalculatorWidget only if _isCalculatorVisible is true
              if (_isCalculatorVisible)
                InAppCalculator(
                  isDarkMode: true,
                  onResultCalculated: _updateResult, // Pass the callback
                ),
            ],
          ),
        ),
      ),
    );
  }
}
3
likes
150
points
48
downloads

Publisher

unverified uploader

Weekly Downloads

A customizable, easy-to-integrate in-app calculator widget for Flutter apps with light and dark mode support, result storage, and responsive design.

Repository (GitLab)
View/report issues

Topics

#calculator #in-app-calculator #flutter-calculator

Documentation

API reference

License

MIT (license)

Dependencies

flutter, math_expressions

More

Packages that depend on in_app_calculator