listen to client state in header controller
This commit is contained in:
parent
d581d3a24e
commit
ae86d58025
1 changed files with 4 additions and 0 deletions
|
|
@ -1,9 +1,13 @@
|
|||
import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||
import "package:nexus/controllers/client_controller.dart";
|
||||
import "package:nexus/controllers/client_state_controller.dart";
|
||||
|
||||
class HeaderController extends AsyncNotifier<Map<String, String>> {
|
||||
@override
|
||||
Future<Map<String, String>> build() async {
|
||||
if (ref.watch(ClientStateController.provider)?.isLoggedIn != true) {
|
||||
return {};
|
||||
}
|
||||
final client = ref.watch(ClientController.provider.notifier);
|
||||
final accessToken = await client.getAccessToken();
|
||||
return {"authorization": "Bearer $accessToken"};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue