import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'counter.g.dart'; @riverpod class CounterNotifier extends _$CounterNotifier { int x = 0; @override Future build() async{ return x; } void plus() { x++; ref.invalidateSelf(); // state = AsyncData(x); } void minus() { x--; // ref.invalidateSelf(); state = AsyncData(x); } }