Coder Social home page Coder Social logo

flutter_update_modal's Introduction

update_modal

Pub Version Github Action

Bugly style update modal on flutter. It is based on UI and cross platform.

Try the Demo

Example project is at example/.

Modal Preview

Getting Started

Install

Add dependency to pubspec.yaml.

dependencies:
  update_modal: ^0.0.3

Implement checker, downloader, installer

class MyUpdateService implements UpdateModalService {
  @override
  Future<int> cancelDownload() {
    // Perform cancel download, resolve arbitary number
  }

  @override
  Future<UpdateInfo> checkUpdate() async {
    // Perform check update, resolve update info
    // Resolve NULL means no update
    return UpdateInfo()
      ..name = "ExampleUpdaterApp"
      ..version = "3.2.0"
      ..size = "13.6M"
      ..releasedAt = "2022-10-26 22:20:01"
      ..description = "Upgrade description";
  }

  @override
  Future<int> dismiss() {
    // Perform dismiss to cleanup
    return Future.value(0);
  }

  @override
  Future<int> install() {
    // Perform install package
    return Future.value(0);
  }

  @override
  Future<Stream<int>> startDownload() {
    // Perform download, resolve a stream for progress notification
    // When progress > 100(e.g. 101), the modal mark state to readyToInstall
    return Future.value(Stream.fromFutures([
      Future.delayed(Duration(milliseconds: 150 * 1), () => 20),
      Future.delayed(Duration(milliseconds: 150 * 2), () => 40),
      Future.delayed(Duration(milliseconds: 150 * 3), () => 60),
      Future.delayed(Duration(milliseconds: 150 * 4), () => 80),
      Future.delayed(Duration(milliseconds: 150 * 5), () => 100),
      // modal show [Dismiss, Install] once receive progress > 100
      Future.delayed(Duration(milliseconds: 150 * 6), () => 120),
    ]));
  }
}

Perform check at App startup

class MyApp extends StatefulWidget {
  @override
  createState() => _MyApp();
}

class _MyApp extends State<MyApp> {
  @override
  initState() {
    UpdateModal.init(
      context,
      service: UpdateModalServiceImpl(),
    );
  }
}

Debugging

Open a web server for cross-platform modal widget debugging.

make example

or,

cd example; flutter run -d web-server --web-port=8080

License

MIT

flutter_update_modal's People

Contributors

luo3house avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.