feat : apk updater

This commit is contained in:
2025-06-07 14:54:44 +03:30
parent 208eae5487
commit 40b8d6f913
7 changed files with 143 additions and 19 deletions

View File

@@ -0,0 +1,22 @@
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:flutter/services.dart';
import 'package:path_provider/path_provider.dart';
class ApkUpdater {
static const _channel = MethodChannel('apk_installer');
static Future<void> downloadAndInstall() async {
final dio = Dio();
final apkUrl = "https://yourdomain.com/app.apk";
final dir = await getExternalStorageDirectory();
final path = "${dir!.path}/update.apk";
final file = File(path);
await dio.download(apkUrl, path);
await _channel.invokeMethod("installApk", {"path": path});
}
}