Last active
May 7, 2020 23:34
-
-
Save Cretezy/13476e7b05389815f65330cb6694f217 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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