import 'package:get/get.dart'; import 'package:solian/providers/auth.dart'; class RealmProvider extends GetxController { Future getRealm(String alias) async { final AuthProvider auth = Get.find(); if (auth.isAuthorized.isFalse) throw Exception('unauthorized'); final client = auth.configureClient('auth'); final resp = await client.get('/realms/$alias'); if (resp.statusCode != 200) { throw Exception(resp.bodyString); } return resp; } Future listAvailableRealm() async { final AuthProvider auth = Get.find(); if (auth.isAuthorized.isFalse) throw Exception('unauthorized'); final client = auth.configureClient('auth'); final resp = await client.get('/realms/me/available'); if (resp.statusCode != 200) { throw Exception(resp.bodyString); } return resp; } }