import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../config.dart'; import 'auth_controller.dart'; /// Points the app at [url] (null = the default). A different server means a different /// account, so the session ends first — while the clients still talk to the OLD server, so /// the refresh token is revoked there and never sent to the new one — and only then is the /// address changed. Takes a container rather than a `WidgetRef`: signing out replaces the /// calling screen, and a disposed widget's `ref` throws. Future switchApiBaseUrl(ProviderContainer container, String? url) async { final next = url ?? defaultApiBaseUrl(); if (next != container.read(apiBaseUrlProvider)) { await container.read(authControllerProvider.notifier).logout(); } await container.read(apiBaseUrlProvider.notifier).save(url); }