init static method

dynamic init({
  1. required String version,
  2. required BuildContext context,
  3. required String url,
})

Implementation

static init(
    {required String version,
    required BuildContext context,
    required String url}) async {
  final response = await UpdateService.initializeService(url: url);

  if (response != null) {
    final data = response.data[0];

    if (Platform.isAndroid && data.andriod && version != data.versioKey) {
      // ignore: use_build_context_synchronously
      showDialog(
        context: context,
        builder: (context) => UpdateWidget(
          title: data.title,
          desc: data.desc,
          topImage: data.image,
          isForce: data.forceUpdate,
          submitButton: data.submitButton,
          skipButton: data.ignoreButton,
          onSubmit: data.andriodClick,
        ),
      );
    } else if (Platform.isIOS && data.ios && version != data.versioKey) {
      // ignore: use_build_context_synchronously
      showDialog(
        context: context,
        builder: (context) => UpdateWidget(
          title: data.title,
          desc: data.desc,
          topImage: data.image,
          isForce: data.forceUpdate,
          submitButton: data.submitButton,
          onSubmit: data.iosClick,
          skipButton: data.ignoreButton,
        ),
      );
    }
  }
}