TermRemoteCtl/apps/mobile_app/lib/features/pairing/pairing_controller.dart

20 lines
595 B
Dart

import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../core/network/agent_api_client.dart';
class PairingController extends StateNotifier<AsyncValue<void>> {
PairingController(this._client) : super(const AsyncData(null));
final AgentApiClient _client;
Future<void> redeemCode(String code, String deviceName) async {
state = const AsyncLoading();
try {
await _client.redeemPairingCode(code: code, deviceName: deviceName);
state = const AsyncData(null);
} catch (error, stackTrace) {
state = AsyncError<void>(error, stackTrace);
}
}
}