execute method
执行预加载任务
Implementation
Future<PreloadExecutionResult> execute(
List<PreloadTask> tasks, {
ProviderContainer? container,
}) async {
if (tasks.isEmpty) {
return const PreloadExecutionResult(
result: PreloadResult.success,
completedTasks: 0,
failedTasks: 0,
totalTasks: 0,
failedTaskDetails: {},
executionTime: Duration.zero,
);
}
_token.reset();
final startTime = DateTime.now();
final graph = DependencyGraph(tasks);
graph.validate();
final executionOrder = graph.buildExecutionOrder();
_tracker.start(tasks, startTime);
ProviderContainer? providerContainer;
try {
providerContainer = container ?? ProviderContainer();
await _executeLevels(executionOrder, providerContainer);
} catch (e) {
_logError('预加载执行失败', e);
if (_config.onError != null) {
_config.onError!(e, StackTrace.current);
}
} finally {
providerContainer?.dispose();
}
return _buildResult(tasks, startTime);
}