fix: replace open_file_plus with native Kotlin MethodChannel for APK install

open_file_plus 3.4.1 uses deprecated PluginRegistry.Registrar API incompatible
with current Flutter. Replaced with a MethodChannel in MainActivity.kt that calls
FileProvider.getUriForFile() and launches the system package installer directly.

Also rework chat_input: 4px border radius on desktop, vPad 18px, 56px send button.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Bernd Steckmeister
2026-04-28 15:44:10 +02:00
parent cdf48c4d45
commit 238fc3f670
5 changed files with 103 additions and 55 deletions
+19 -18
View File
@@ -1,9 +1,9 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:http/http.dart' as http;
import 'package:open_file_plus/open_file_plus.dart';
import 'package:path/path.dart' as p;
import 'package:path_provider/path_provider.dart';
import 'package:pyramid/core/theme.dart';
@@ -111,27 +111,28 @@ class _UpdateDownloadDialogState extends ConsumerState<_UpdateDownloadDialog>
}
}
static const _installChannel =
MethodChannel('chat.pyramid.pyramid/install');
Future<void> _install(File file) async {
setState(() => _state = _DownloadState.installing);
if (Platform.isWindows) {
await Process.start(file.path, [], runInShell: false);
if (mounted) Navigator.of(context).pop();
exit(0);
} else if (Platform.isAndroid) {
final result = await OpenFile.open(
file.path,
type: 'application/vnd.android.package-archive',
);
try {
if (Platform.isWindows) {
await Process.start(file.path, [], runInShell: false);
if (mounted) Navigator.of(context).pop();
exit(0);
} else if (Platform.isAndroid) {
await _installChannel
.invokeMethod('installApk', {'path': file.path});
if (mounted) setState(() => _state = _DownloadState.done);
}
} catch (e) {
if (mounted) {
if (result.type == ResultType.done) {
setState(() => _state = _DownloadState.done);
} else {
setState(() {
_state = _DownloadState.error;
_errorMsg = result.message;
});
}
setState(() {
_state = _DownloadState.error;
_errorMsg = e.toString().split('\n').first;
});
}
}
}