feat : apk updater
This commit is contained in:
@@ -10,18 +10,18 @@ export 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
export 'package:flutter_slidable/flutter_slidable.dart';
|
||||
export 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
export 'package:device_info_plus/device_info_plus.dart';
|
||||
export 'package:dio/dio.dart' show DioException;
|
||||
export 'package:dio/dio.dart' ;
|
||||
export 'package:pretty_dio_logger/pretty_dio_logger.dart';
|
||||
//freezed
|
||||
export 'package:freezed_annotation/freezed_annotation.dart';
|
||||
export 'package:geolocator/geolocator.dart';
|
||||
export 'package:get/get.dart';
|
||||
export 'package:get/get.dart' hide FormData, MultipartFile, Response;
|
||||
//di
|
||||
export 'package:get_it/get_it.dart';
|
||||
export 'injection/di.dart';
|
||||
|
||||
//local storage
|
||||
export 'package:hive_ce_flutter/hive_flutter.dart';
|
||||
export 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
export 'infrastructure/local/hive_local_storage.dart';
|
||||
|
||||
//encryption
|
||||
|
||||
22
packages/core/lib/utils/apk_updater.dart
Normal file
22
packages/core/lib/utils/apk_updater.dart
Normal 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});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user