Skip to content

abandoft/abutil

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Abandoft Util

Common Flutter utilities for platform detection, app subtree restart, and version update checks.

Platform

abutil can be imported from Web and native targets directly.

import 'package:abutil/abutil.dart';

if (isDesktop()) {
  // Windows, macOS, or Linux.
}

Available helpers:

getPlatform()

isWeb()

isIOS()
isOHOS()
isAndroid()
isMobile()

isWindows()
isMacOS()
isLinux()
isDesktop()

Reboot

Wrap the app subtree with Reboot, then call Reboot.begin(context) to rebuild that subtree with a new key.

runApp(
  const Reboot(
    child: MyApp(),
  ),
);
Reboot.begin(context);

Use Reboot.maybeBegin(context) when you prefer a bool result instead of an exception if the context is outside a Reboot subtree.

Update Checks

hasUpdate(versionCode, latestVersion);

mustUpdate(
  latestUpdateTime,
  updateTime,
  interval: const Duration(days: 122),
);

mustUpdate compares updateTime with latestUpdateTime when it is available, or with the current time otherwise. It accepts DateTime, date strings, null, and empty values. Invalid updateTime values return false instead of throwing.

About

Abandoft commonly used functions collection, simplify the software development process.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages