than_pkg 3.0.2 copy "than_pkg: ^3.0.2" to clipboard
than_pkg: ^3.0.2 copied to clipboard

My personal Flutter plugin with support for both Android and Linux platforms.

My personal Flutter plugin with support for both Android and Linux platforms #

ThanPkg V3.0.0 #

Needed lib for linux #

sudo apt install net-tools  // wifi
sudo apt install poppler-utils //pdf thumbnail
sudo apt install ffmpeg //video thumbnail

Platforms Methods #

  • ThanPkg.platform.*
  • ThanPkg.platform.checkScreenOrientation
  • ThanPkg.platform.genPdfThumbnail
  • ThanPkg.platform.genVideoThumbnail
  • ThanPkg.platform.getAppBatteryLevel
  • ThanPkg.platform.getDeviceId

Linux #

  • ThanPkg.linux.*

Android #

  • ThanPkg.android.*

Map Services #

//new
MapServices.getBool({}, ['name'])
MapServices.getInt({}, ['name'])
MapServices.getString({}, ['name'])
MapServices.getDouble({}, ['name'])
//old
MapServices.get<String>({}, ['name'], defaultValue: '');
MapServices.get<int>({}, ['num'], defaultValue: 1);
MapServices.get<double>({}, ['height'], defaultValue: 0.0);

Methods #

ThanPkg.appUtil.getParseMinutes(minutes);
ThanPkg.appUtil.copyText(text);
ThanPkg.appUtil.pasteText();
await ThanPkg.appUtil.clearImageCache();

Extensions #

// extension
DateTime.now().toParseTime();
DateTime.now().toTimeAgo();
//double
0.0.toFileSizeLabel();
//FileSystemEntityExtension
FileSystemEntityExtension.getName(withExt: false)

//PlatformExtension
PlatformExtension.isDesktop();
PlatformExtension.isMobile();

//StringExtension
"".toCaptalize();
"".getName();
"".getExt();
//TextEditingControllerExtension
TextEditingController().selectAll();

Thumbnail for linux,android #

await ThanPkg.platform.genPdfThumbnail(pathList: [
SrcDestType(src: '$path/Download/1-50.pdf', dist: '$path/test.png'),
]);

await ThanPkg.platform.genVideoThumbnail(pathList: [
SrcDestType(
    src: '$path/Download/catch.mp4', dist: '$path/catch-video.png'),
]);

Launch #

  • ThanPkg.android.app.launch

  • ThanPkg.linux.app.launch

  • ThanPkg.platform.launch

  • Ubuntu/Debian

sudo apt install xdg-utils
  • Arch
sudo pacman -S xdg-utils
  • Fedora
sudo dnf install xdg-utils

Android ScreenOrientation #

final type = await ThanPkg.android.app.getOrientation();
if (type == null) return;
if (type == ScreenOrientationTypes.Portrait) {
await ThanPkg.android.app
    .requestOrientation(type: ScreenOrientationTypes.Landscape);
await ThanPkg.android.app.showFullScreen();
} else {
ThanPkg.android.app
    .requestOrientation(type: ScreenOrientationTypes.Portrait);
await ThanPkg.android.app.hideFullScreen();
}

Android Manifest #

<application>
<provider
    android:name="than.plugin.than_pkg.TContentProvider"
    android:authorities="${applicationId}.provider"
    android:exported="false"
    android:grantUriPermissions="true" />

</application>
  • for above android xml code
Future<void> openPdfWithIntent({required String path})
Future<void> openVideoWithIntent({required String path})
Future<void> installApk({required String path})

Android Thumbnail #

  • ThanPkg.android.thumbnail
Future<void> genVideoThumbnailList
Future<String?> genVideoThumbnail
Future<void> genPdfCoverList
Future<String> genPdfImage
Future<int> getPdfPageCount

Android Camera #

final filePath = await ThanPkg.android.camera.openCamera();

Android Storage Permission (All Version) #

if (!await ThanPkg.android.permission.isStoragePermissionGranted()) {
    await ThanPkg.android.permission.requestStoragePermission();
    return;
}
if (!await ThanPkg.android.permission.isCameraPermission()) {
    await ThanPkg.android.permission.requestCameraPermission();
    return;
}
  • ThanPkg.android.permission
Future<void> checkCanRequestPackageInstallsPermission
Future<bool> isPackageInstallPermission()
Future<bool> isStoragePermissionGranted()
Future<bool> isCameraPermission()
Future<bool> isLocationPermission()
Future<void> requestStoragePermission()
Future<void> requestPackageInstallPermission()
Future<void> requestCameraPermission()
Future<void> requestLocationPermission()

Android && linux #

//old method
await ThanPkg.windowManagerensureInitialized();
await ThanPkg.platform.toggleFullScreen(isFullScreen: true);
await ThanPkg.platform.getAppRootPath();
await ThanPkg.platform.getAppExternalPath();
await ThanPkg.platform.getWifiAddressList();
await ThanPkg.platform.genPdfCover(outDirPath: '', pdfPathList: []);
await ThanPkg.platform.genVideoCover(outDirPath: '', videoPathList: []);

Android Permission #

//android any version can handle
await ThanPkg.platform.isStoragePermissionGranted();
await ThanPkg.platform.requestStoragePermission();
await ThanPkg.platform.checkAndRequestPackageInstallPermission();

Android only #

//old method
await ThanPkg.platform.getAppFilePath();
await ThanPkg.platform.isAppSystemThemeDarkMode();
await ThanPkg.platform.isAppInternetConnected();
await ThanPkg.platform.getAppBatteryLevel();
await ThanPkg.platform.getLastKnownLocation();
await ThanPkg.platform.getInstalledApps();
await ThanPkg.platform.checkScreenOrientation();
await ThanPkg.platform.requestScreenOrientation(type: ScreenOrientationTypes.Portrait);
//android device info <Map> type
await ThanPkg.platform.getAndroidDeviceInfo()
await ThanPkg.platform.openUrl(url: '');
await ThanPkg.platform.getPlatformVersion();
await ThanPkg.platform.getDeviceId();
await ThanPkg.platform.toggleKeepScreen(isKeep: false);
await ThanPkg.platform.toggleFullScreen(isFullScreen: !isFullScreen);
await ThanPkg.platform.getLocalIpAddress();
await ThanPkg.platform.getWifiAddress();

android AndroidManifest #

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

1
likes
0
points
1.25k
downloads

Publisher

unverified uploader

Weekly Downloads

My personal Flutter plugin with support for both Android and Linux platforms.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, intl, mime, package_info_plus, plugin_platform_interface, timeago, window_manager

More

Packages that depend on than_pkg

Packages that implement than_pkg