isExpired method
The function that check if a widget has expired by either subscription to the OnTokenExpired or using isExpired(); function, which returns true if the widget is expired.
This method can only be called when widgetId is not null.
example:
// Initialize controller
TurnstileController controller = TurnstileController();
bool isTokenExpired = await controller.isExpired();
print(isTokenExpired);
Implementation
Future<bool> isExpired() async {
if (!isReady ||
(_widgetId?.isEmpty ?? true) ||
token == null ||
token!.isEmpty) {
return true;
}
final result = _connector
?.callMethod('eval', ['''turnstile.isExpired(`$_widgetId`);''']);
return Future.value(result as bool);
}