天天看點

flutter_update_dialog 一個漂亮的版本更新彈窗

前言

前段時間我釋出了一個隻針對Android的版本更新架構flutter_xupdate,釋出以來收到了大家許多的建議.當時我也隻是為了自己友善才寫的這麼一個插件,并沒有考慮很多.

建議有很多,大緻可以分為如下幾類:

能否支援ios版本更新?
能否支援自定義api?
能否支援自定義版本更新彈窗?
能否開發apk安裝能力?
           

看到最後,居然還有人問:能不能給我提供檢查版本、彈窗顯示、apk下載下傳、apk安裝的能力,這樣我就可以自己寫更新邏輯了…

看來真的是不同的人對版本更新是有不同的需求,我想了一下,與其我提供這麼一個較重的原生插件,倒不如直接提供一個使用純dart編寫的版本更新彈窗,然後再提供一個使用dart插件組合編寫的版本更新功能使用案例,這樣大家就可以參照着案例,根據自己的需求來自己寫版本更新邏輯了.

下面話不多說,我給出版本更新彈窗flutter_update_dialog的插件位址:

github.com/xuexiangjys…

示範

flutter_update_dialog 一個漂亮的版本更新彈窗

預設樣式

flutter_update_dialog 一個漂亮的版本更新彈窗

自定義樣式

flutter_update_dialog 一個漂亮的版本更新彈窗

快速內建指南

添加引用依賴

在你的flutter項目中的pubspec.yaml檔案中添加flutter_update_dialog依賴.

方法一: pub內建

dependencies:
  flutter_update_dialog: ^0.0.1
           

方法二: github內建

dependencies:
  flutter_update_dialog:
    git:
      url: git://github.com/xuexiangjys/flutter_update_dialog.git
      ref: master
           
如何使用

預設樣式

void defaultStyle() {
    if (dialog != null && dialog.isShowing()) {
      return;
    }
    dialog = UpdateDialog.showUpdate(context,
        title: "是否更新到4.1.4版本?",
        updateContent: "新版本大小:2.0M\n1.xxxxxxx\n2.xxxxxxx\n3.xxxxxxx",
        onUpdate: onUpdate);
  }
           

自定義樣式

void customStyle() {
    if (dialog != null && dialog.isShowing()) {
      return;
    }
    dialog = UpdateDialog.showUpdate(context,
        width: 250,
        title: "是否更新到4.1.4版本?",
        updateContent: "新版本大小:2.0M\n1.xxxxxxx\n2.xxxxxxx\n3.xxxxxxx",
        titleTextSize: 14,
        contentTextSize: 12,
        buttonTextSize: 12,
        topImage: Image.asset('assets/bg_update_top.png'),
        extraHeight: 5,
        radius: 8,
        themeColor: Color(0xFFFFAC5D),
        progressBackgroundColor: Color(0x5AFFAC5D),
        isForce: true,
        updateButtonTxt: '更新',
        ignoreButtonTxt: '忽略此版本',
        enableIgnore: true, onIgnore: () {
          ToastUtils.waring("忽略");
          dialog.dismiss();
        },
        onUpdate: onUpdate);
  }
           

屬性表

flutter_update_dialog 一個漂亮的版本更新彈窗
flutter_update_dialog 一個漂亮的版本更新彈窗

感謝觀看,歡迎點贊,評論!!!

繼續閱讀