zupdate

Creator: coderz1093

Last updated:

0 purchases

TODO
Add to Cart

Description:

zupdate

zupdate #

A simple plugin version update for flutter.
On Android it downloads the file (with progress reporting) and triggers app installation intent.
On iOS it opens safari with specified ipa url.
You can refer to the following project:
https://github.com/hacjy/zupdate/tree/master/example
Important changes #

A beautiful set of updated UI has been provided.
A flutter plugin 【install_plugin】 for install apk for android; and using url to go to app store for iOS.
Required settings:
1、in the pubspec.yaml file, add get: ^4.6.5 and flutter_screenutil: ^5.5.3+2 as a dependency.
2、in the main.dart file, the root node needs to use the following code
//根结点要要使用ScreenUtilInit和getx的GetMaterialApp
return ScreenUtilInit(
designSize: const Size(1920, 1080),
minTextAdapt: true,
splitScreenMode: true,
builder: (context, Widget? widget) {

return GetMaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('VersionUpdate Plugin App'),
),
body: GestureDetector(
onTap: (){
UpdateVersion.appUpdate(context);
},
child: const Center(child: SizedBox(
width: 100,
height: 100,
child: Text('Check Update'),
),)
)
),
);});
}
copied to clipboard
3、 in the pubspec.yaml file, use the following code
assets:
- assets/
- assets/img/
copied to clipboard
then add update_bg_app_top.png and update_ic_close.png to assets/img. These two images are copied from assets/img in example.
Support custom header image, button theme color, progress bar color, title, height of title from header image, apk file name, whether to display Chinese text
UpdateConfig(
apkName: 'test.apk',
title: 'test update version',
themeColor: Colors.blueAccent,
progressBackgroundColor: Colors.blue.withOpacity(0.3),
extraHeight: 10,
chLanguage: true)
copied to clipboard


Usage #
To use this plugin, add zupdate as a dependency in your pubspec.yaml file.
//pub 集成
dependencies:
zupdate: ^0.4.0

//github 集成
dependencies:
zupdate:
git:
url: git://github.com/hacjy/zupdate.git
ref: master
copied to clipboard
Preview #


Example #
// IMPORT PACKAGE
import 'package:zupdate/version_xupdate/update/entity/update_entity.dart';
import 'package:zupdate/version_xupdate/update/flutter_update.dart';

//版本更新
static Future<void> update(
BuildContext context, Map<String, dynamic> appInfo) async {
try {
final url = appInfo['update_url'];
UpdateEntity entity = UpdateEntity(
isForce: appInfo['update_type'] == 1,
hasUpdate: true,
isIgnorable: false,
versionCode: appInfo['version_code'],
versionName: appInfo['version_name'],
updateContent: appInfo['update_content'],
apkMd5: appInfo['app_md5'] ?? '',
// apkSize: appInfo['package_size'],
downloadUrl: appInfo['update_url']);
UpdateManager.checkUpdate(context, entity,
//支持自定义头部图片,按钮主题色,进度条颜色,标题,标题距离头部图片的高度,apk文件名,是否显示中文文本
// config: UpdateConfig(
// apkName: 'test.apk',
// title: 'test update version',
// themeColor: Colors.blueAccent,
// progressBackgroundColor: Colors.blue.withOpacity(0.3),
// extraHeight: 10,
// chLanguage: true)
);
} catch (e) {
print(e);
}
}
copied to clipboard
install_plugin Example #
// IMPORT PACKAGE
import 'package:zupdate/install_plugin.dart';

// 安装apk
static void installAPP(String uri) async {
if (Platform.isAndroid) {
String packageName = await CommonUtils.getPackageName();
InstallPlugin.installApk(uri, packageName);
} else {
InstallPlugin.gotoAppStore(uri);
}
}
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files:

Customer Reviews

There are no reviews.