Admin user impersonation for Flutter. Test your app as any user by injecting impersonation headers into your network requests — without logging out or switching accounts. State persists across launches and mirrors live to Buoy Desktop.
flutter pub add buoy_impersonate
flutter pub add buoy_impersonate
Unlike other Buoy tools, Impersonate requires configuration because it needs to integrate with your user search API.
import 'package:buoy_impersonate/buoy_impersonate.dart';
// Register with your app's user search + optional cache-clear callbacks.
registerBuoyImpersonate(
onSearchUsers: (query) async => api.searchUsers(query), // returns List<ImpersonateUser>
onClearCache: () => cache.clear(),
);
import 'package:buoy_impersonate/buoy_impersonate.dart';
// Register with your app's user search + optional cache-clear callbacks.
registerBuoyImpersonate(
onSearchUsers: (query) async => api.searchUsers(query), // returns List<ImpersonateUser>
onClearCache: () => cache.clear(),
);
Dart has no global fetch to patch, so you apply the header in your HTTP client — e.g. a dio interceptor:
dio.interceptors.add(InterceptorsWrapper(onRequest: (options, handler) {
options.headers.addAll(BuoyImpersonate.instance.impersonationHeaders);
handler.next(options);
}));
dio.interceptors.add(InterceptorsWrapper(onRequest: (options, handler) {
options.headers.addAll(BuoyImpersonate.instance.impersonationHeaders);
handler.next(options);
}));
When impersonation is active, impersonationHeaders contains:
x-impersonate-user-id: user_123
x-impersonate-user-id: user_123
Your backend checks for this header and returns data for the specified user instead of the authenticated admin. Your backend decides what the headers mean — Buoy just makes toggling them one tap.