Skip to content

Instantly share code, notes, and snippets.

@itsatifsiddiqui
Created May 10, 2019 10:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itsatifsiddiqui/4f8a314569f1f692d66ec0f72f09b1ca to your computer and use it in GitHub Desktop.
Save itsatifsiddiqui/4f8a314569f1f692d66ec0f72f09b1ca to your computer and use it in GitHub Desktop.
Counter Class
import 'package:flutter/material.dart';
class Counter with ChangeNotifier {
int _counter;
Counter(this._counter);
getCounter() => _counter;
setCounter(int counter) => _counter = counter;
void increment() {
_counter++;
notifyListeners();
}
void decrement() {
_counter--;
notifyListeners();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment