flutter_android 0.5.0

Flutter Android

Flutter plugin for Android platform-specific APIs, to reduce duplication of effort by centralizing Android bindings in a single package.

Flutter Android Bindings #

Project license Dart compatibility Dartdoc reference Pub package

This is a Flutter plugin for using Android's numerous platform-specific APIs in Flutter apps.

Prerequisites #

Compatibility #

Android only.

Features #

  • Implements bindings to a growing set of Android's platform-specific APIs.

  • Reduces duplication of effort by centralizing Android bindings in a single package.

Feature Table #

FeatureFlutter API
Bluetooth scanningandroid_bluetooth.BluetoothLeScanner
Face detectionandroid_media.FaceDetector
Distance calculationandroid_location.Location.distanceBetween()
Heart-rate monitoringandroid_hardware.SensorManager.getDefaultSensor()
Sensor event streamsandroid_hardware.Sensor#subscribe()

Examples #

Face detection #

import 'package:flutter_android/android_graphics.dart' show Bitmap;
import 'package:flutter_android/android_media.dart' show Face, FaceDetector;

var photo = Image.asset("images/einstein.png");

var bitmap = Bitmap.fromAssetImage(photo.image as AssetImage);
var detector = FaceDetector(width: 280, height: 396);

for (var face in await detector.findFaces(bitmap)) {
  if (face.confidence < Face.CONFIDENCE_THRESHOLD) {
    continue; // skip dubious results below the cut-off threshold
  }
  print("Found a face at (${face.midPoint.x}, ${face.midPoint.y}) with confidence ${face.confidence}");
}

Heart-rate monitoring #

import 'package:flutter_android/android_hardware.dart'
    show Sensor, SensorEvent, SensorManager;

var sensor = await SensorManager.getDefaultSensor(Sensor.TYPE_HEART_RATE);

var events = await sensor.subscribe();
events.listen((SensorEvent event) {
  print(event.values[0]);
});

Frequently Asked Questions #

TODO

Caveats #

  • iOS is not and cannot be supported. All flutter_android APIs throw an AssertionError if they are invoked when running on iOS. For cross-platform apps, we recommend that you depend on the platform package to conditionalize your use of Android APIs.

Reference #

android #

import 'package:flutter_android/android.dart' as android;

android_app #

import 'package:flutter_android/android_app.dart' as android_app;

android_bluetooth #

import 'package:flutter_android/android_bluetooth.dart' as android_bluetooth;

android_content #

import 'package:flutter_android/android_content.dart' as android_content;

android_database #

import 'package:flutter_android/android_database.dart' as android_database;

android_graphics #

import 'package:flutter_android/android_graphics.dart' as android_graphics;

android_hardware #

import 'package:flutter_android/android_hardware.dart' as android_hardware;

android_location #

import 'package:flutter_android/android_location.dart' as android_location;

android_media #

import 'package:flutter_android/android_media.dart' as android_media;

android_os #

import 'package:flutter_android/android_os.dart' as android_os;

Cross-Reference #

AndroidFlutter
android.appandroid_app
android.app.Activityandroid_app.Activity
android.app.ActivityManagerandroid_app.ActivityManager
android.app.AlarmManagerandroid_app.AlarmManager
android.app.AuthenticationRequiredExceptionandroid_app.AuthenticationRequiredException
android.app.DownloadManagerandroid_app.DownloadManager
android.app.KeyguardManagerandroid_app.KeyguardManager
android.app.Notificationandroid_app.Notification
android.app.Notification.Actionandroid_app.NotificationAction
android.app.Notification.Builderandroid_app.NotificationBuilder
android.app.NotificationManagerandroid_app.NotificationManager
android.app.PendingIntentandroid_app.PendingIntent
android.app.SearchManagerandroid_app.SearchManager
android.app.WallpaperColorsandroid_app.WallpaperColors
android.app.WallpaperInfoandroid_app.WallpaperInfo
android.app.WallpaperManagerandroid_app.WallpaperManager
android.bluetoothandroid_bluetooth
android.bluetooth.BluetoothAdapterandroid_bluetooth.BluetoothAdapter
android.bluetooth.BluetoothDeviceandroid_bluetooth.BluetoothDevice
android.bluetooth.BluetoothHeadsetandroid_bluetooth.BluetoothHeadset
android.bluetooth.BluetoothManagerandroid_bluetooth.BluetoothManager
android.bluetooth.le.BluetoothLeScannerandroid_bluetooth.BluetoothLeScanner
android.bluetooth.leandroid_bluetooth
android.contentandroid_content
android.content.ActivityNotFoundExceptionandroid_content.ActivityNotFoundException
android.content.ComponentNameandroid_content.ComponentName
android.content.ContentValuesandroid_content.ContentValues
android.content.Contextandroid_content.Context
android.content.Intentandroid_content.Intent
android.content.IntentFilterandroid_content.IntentFilter
android.content.SharedPreferencesandroid_content.SharedPreferences
android.databaseandroid_database
android.database.Cursorandroid_database.Cursor
android.database.CursorIndexOutOfBoundsExceptionandroid_database.CursorIndexOutOfBoundsException
android.database.DatabaseUtilsandroid_database.DatabaseUtils
android.database.MatrixCursorandroid_database.MatrixCursor
android.database.SQLExceptionandroid_database.SQLException
android.graphicsandroid_graphics
android.graphics.Bitmapandroid_graphics.Bitmap
android.graphics.Colordart-ui.Color
android.graphics.Pointandroid_graphics.Point
android.graphics.PointFandroid_graphics.PointF
android.graphics.drawable.Iconflutter.Icon
android.hardwareandroid_hardware
android.hardware.Sensorandroid_hardware.Sensor
android.hardware.SensorEventandroid_hardware.SensorEvent
android.hardware.SensorEventListenerandroid_hardware.SensorEventListener
android.hardware.SensorManagerandroid_hardware.SensorManager
android.locationandroid_location
android.location.Locationandroid_location.Location
android.mediaandroid_media
android.media.FaceDetectorandroid_media.FaceDetector
android.media.FaceDetector.Faceandroid_media.Face
android.netandroid_net
android.nfcandroid_nfc
android.osandroid_os
android.os.BatteryManagerandroid_os.BatteryManager
android.os.Buildandroid_os.Build
android.os.Bundleandroid_os.Bundle
android.os.Environmentandroid_os.Environment
android.os.HardwarePropertiesManagerandroid_os.HardwarePropertiesManager
android.os.Parcelandroid_os.Parcel
android.os.Parcelableandroid_os.Parcelable
android.os.PowerManagerandroid_os.PowerManager
android.os.Processandroid_os.Process
android.os.StatFsandroid_os.StatFs
android.os.SystemClockandroid_os.SystemClock
android.os.UserManagerandroid_os.UserManager
android.os.VibrationEffectandroid_os.VibrationEffect
android.os.Vibratorandroid_os.Vibrator
android.providerandroid_provider
android.securityandroid_security
android.speechandroid_speech
android.telephonyandroid_telephony
android.viewandroid_view
java.util.Localedart-ui.Locale

See Also #

  • The flutter_sqlcipher package implements encrypted SQLite databases based on the android.database APIs.
15
likes
90
pub points
80%
popularity

Publisher

ar.to

Flutter plugin for Android platform-specific APIs, to reduce duplication of effort by centralizing Android bindings in a single package.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Unlicense (UNLICENSE)

Dependencies

flutter, meta, platform

More

Packages that depend on flutter_android