ChangJoo-Park / calculator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Only plus and minus one is provided. This package is a good example for beginners to add package dependencies to their project.


Usage

To use this plugin, add calculator as a dependency in your pubspec.yaml file.

dependencies:
  flutter:
    sdk: flutter

  calculator: 0.0.1

Example

import 'package:calculator/calculator.dart';

...

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    _counter = Calculator.plusOne(_counter);
    setState(() {});
  }

  void _decrementCounter() {
    _counter = Calculator.minusOne(_counter);
    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: Column(
        mainAxisAlignment: MainAxisAlignment.end,
        children: [
          FloatingActionButton(
            onPressed: _decrementCounter,
            tooltip: 'Decrement',
            child: const Icon(Icons.remove),
          ),
          const SizedBox(height: 10),
          FloatingActionButton(
            onPressed: _incrementCounter,
            tooltip: 'Increment',
            child: const Icon(Icons.add),
          ),
        ],
      ),
    );
  }
}

About

License:MIT License


Languages

Language:C++ 43.7%Language:CMake 39.1%Language:Dart 7.6%Language:HTML 3.8%Language:C 3.0%Language:Swift 2.4%Language:Kotlin 0.3%Language:Objective-C 0.1%