All checks were successful
ci/woodpecker/push/flutterBuild Pipeline was successful
28 lines
1,003 B
Dart
28 lines
1,003 B
Dart
import 'dart:async';
|
|
|
|
import 'package:bloc/bloc.dart';
|
|
import 'package:equatable/equatable.dart';
|
|
import 'package:gitea_client/model/File.dart';
|
|
|
|
import '../service/gitea_service.dart';
|
|
|
|
part 'file_list_load_event.dart';
|
|
|
|
part 'file_list_load_state.dart';
|
|
|
|
class FileListLoadBloc extends Bloc<FileListLoadEvent, FileListLoadState> {
|
|
final GiteaService giteaService;
|
|
FileListLoadBloc({required this.giteaService}) : super(const FileListLoadState()) {
|
|
on<FileListLoadPathEvent>(_FileListLoadState);
|
|
}
|
|
|
|
Future<void> _FileListLoadState(
|
|
FileListLoadPathEvent event, Emitter<FileListLoadState> emit) async {
|
|
if(event.repoName.isEmpty) return;
|
|
emit(FileListLoadState(status: FileLoadStatus.loading));
|
|
final fileListResult = await giteaService.getFolder(
|
|
event.repoName.split('/')[0], event.repoName.split('/')[1], event.path);
|
|
return emit(FileListLoadState(status: FileLoadStatus.success,files: fileListResult,path: event.path,repoFullname: event.repoName));
|
|
|
|
}
|
|
}
|