simple_calculator

Last updated:

0 purchases

simple_calculator Image
simple_calculator Images
Add to Cart

Description:

simple calculator

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
copied to clipboard
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),
),
],
),
);
}
}

copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.