installIncomingPackage function
- BuildContext context,
- CoursesCubit store,
- IncomingPackage package
O pacote que o sistema entregou ao app (B11: clique duplo, "Abrir com…"): o mesmo fluxo do "Abrir arquivo…", sem o seletor. Se o arquivo não pôde ser lido, o diálogo diz qual.
Implementation
Future<InstalledCourse?> installIncomingPackage(
BuildContext context,
CoursesCubit store,
IncomingPackage package,
) async {
final navigator = Navigator.of(context, rootNavigator: true);
final Uint8List bytes;
try {
bytes = await package.read();
} on Object catch (e) {
if (!navigator.mounted) return null;
await _showError(
navigator,
'Não consegui ler "${package.name}": $e',
title: 'Não deu para abrir o arquivo',
);
return null;
}
if (!navigator.mounted) return null;
return _installPackageBytes(navigator.context, store, bytes);
}