isStylusHandwritingAvailable static method

Future<bool> isStylusHandwritingAvailable()

Returns true if the InputMethodManager supports Scribe stylus handwriting input, false otherwise.

Call this each time before calling startStylusHandwriting to make sure it's available.

Supported on Android API 34 and above. If called by an unsupported API level, a PlatformException will be thrown. To avoid error handling, use the convenience method isFeatureAvailable instead.

This example shows using isStylusHandwritingAvailable to confirm that startStylusHandwriting can be called.
link
try {
  if (!await Scribe.isStylusHandwritingAvailable()) {
    // If isStylusHandwritingAvailable returns false then the device's API level
    // supports Scribe, but for some other reason it's not able to accept stylus
    // input right now.
    return;
  }
} on PlatformException catch (exception) {
  if (exception.message == 'Requires API level 34 or higher.') {
    // The device's API level is too low to support Scribe.
    return;
  }
  // Any other exception is unexpected and should not be caught here.
  rethrow;
}

// Scribe is supported, so start it.
Scribe.startStylusHandwriting();

See also:

Implementation

static Future<bool> isStylusHandwritingAvailable() async {
  final bool? result = await _channel.invokeMethod<bool?>('Scribe.isStylusHandwritingAvailable');

  if (result == null) {
    throw FlutterError('MethodChannel.invokeMethod unexpectedly returned null.');
  }

  return result;
}