flutter analyze exits non-zero on info-level findings too, so all five had to go for `make pre-push` to pass. Four were mechanical. The fifth was not. envApiUser was reported as an unused declaration. Removing it revealed that the field behind it, _envApiUser, was then unused as well -- and the pair turns out to be a closed loop nothing could enter: the getter is public but sits on _DashboardContentState, a private class, so no caller outside this file could ever have reached it. The field was written once per session and never read. The debugPrint next to it logs envData.user directly, so the logging the comment describes never depended on the stored copy. Field, getter and assignment removed; _hasLoggedEnvUser stays, because it genuinely guards the log-once. Deleting the first warning exposing the second is the useful part: unused_field could not fire while a dead getter was "using" it. Dead code hides dead code. The two `if (x != null) x` collection entries become null-aware elements, which is the same intent spelled the way the SDK now expects. The two casts in data_grid_test were the second cast of a pair -- `mode as InfiniteDataMode` on the preceding line already promotes the local. flutter analyze: No issues found. The edited test file still passes all 37. Note the gate still prints "not gated here yet: test (T-56)" -- analysis is green, tests remain unwired, and that is deliberately left visible. Co-Authored-By: Claude <noreply@anthropic.com>
72 lines
2.0 KiB
Dart
72 lines
2.0 KiB
Dart
import 'package:dio/dio.dart';
|
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
|
import 'package:tatlock_ui/core/api/api_client.dart';
|
|
import 'package:tatlock_ui/features/control_room/containers/data/models/container_model.dart';
|
|
|
|
part 'containers_datasource.g.dart';
|
|
|
|
/// Remote data source for container operations.
|
|
class ContainersDatasource {
|
|
ContainersDatasource(this._dio);
|
|
|
|
final Dio _dio;
|
|
|
|
/// Gets all containers from the API.
|
|
Future<List<ContainerModel>> getContainers({bool all = true}) async {
|
|
final response = await _dio.get<List<dynamic>>(
|
|
'/infrastructure/containers',
|
|
queryParameters: {'all': all},
|
|
);
|
|
|
|
return response.data!
|
|
.map((json) => ContainerModel.fromJson(json as Map<String, dynamic>))
|
|
.toList();
|
|
}
|
|
|
|
/// Gets a single container by ID.
|
|
Future<ContainerModel> getContainer(String id) async {
|
|
final response = await _dio.get<Map<String, dynamic>>(
|
|
'/infrastructure/containers/$id',
|
|
);
|
|
|
|
return ContainerModel.fromJson(response.data!);
|
|
}
|
|
|
|
/// Performs an action on a container.
|
|
Future<void> containerAction(String id, String action) async {
|
|
await _dio.post<void>('/infrastructure/containers/$id/$action');
|
|
}
|
|
|
|
/// Gets container logs.
|
|
Future<String> getContainerLogs(
|
|
String id, {
|
|
int? tail,
|
|
bool timestamps = false,
|
|
}) async {
|
|
final response = await _dio.get<String>(
|
|
'/infrastructure/containers/$id/logs',
|
|
queryParameters: {
|
|
'tail': ?tail,
|
|
'timestamps': timestamps,
|
|
},
|
|
);
|
|
|
|
return response.data ?? '';
|
|
}
|
|
|
|
/// Removes a container.
|
|
Future<void> removeContainer(String id, {bool force = false}) async {
|
|
await _dio.delete<void>(
|
|
'/infrastructure/containers/$id',
|
|
queryParameters: {'force': force},
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Provides the containers datasource.
|
|
@riverpod
|
|
ContainersDatasource containersDatasource(Ref ref) {
|
|
final dio = ref.watch(coreApiClientProvider);
|
|
return ContainersDatasource(dio);
|
|
}
|