Skip to content

adbr-dev/simple_calculator

Repository files navigation

Pub Version DUB

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 simple_calculator as a dependency in your pubspec.yaml file.

dependencies:
  flutter:
    sdk: flutter

  simple_calculator: 0.0.1

Example

import 'package:simple_calculator/simple_calculator.dart';

...

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

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

  void _decrementCounter() {
    _counter = simple_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

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published