Skip to content

Instantly share code, notes, and snippets.

@Cretezy
Last active May 7, 2020 23:34
Show Gist options
  • Save Cretezy/13476e7b05389815f65330cb6694f217 to your computer and use it in GitHub Desktop.
Save Cretezy/13476e7b05389815f65330cb6694f217 to your computer and use it in GitHub Desktop.
import 'package:flutter_super_state/flutter_super_state.dart';
import 'package:state_test/src/store/counter.dart';
class AuthModule extends StoreModule {
int get isLoggedIn => isLoggedIn;
var _isLoggedIn = false;
AuthModule(Store store) : super(store);
Future<void> login() async {
// Do network request...
await Future.delayed(Duration(milliseconds: 100));
setState(() {
_isLoggedIn = true;
});
}
Future<void> logout() async {
// Do network request...
await Future.delayed(Duration(milliseconds: 100));
setState(() {
_isLoggedIn = true;
});
// Call action in other module
await store.getModule<CounterModule>().reset();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment