AutoDisconnect class

Configuration for auto-disconnect feature.

This allows VPN apps with free-time models to automatically disconnect after a specified duration, even if the app is killed.

Example:

await flutterV2ray.startVless(
  remark: "Free Server",
  config: serverConfig,
  autoDisconnect: AutoDisconnect(
    duration: 30 * 60, // 30 minutes
    onExpire: OnExpireBehavior.disconnectWithNotification,
    expiredNotificationMessage: "Your free VPN time has expired",
  ),
);

Constructors

AutoDisconnect({required int duration, bool showRemainingTimeInNotification = true, TimeFormat timeFormat = TimeFormat.withSeconds, OnExpireBehavior onExpire = OnExpireBehavior.disconnectWithNotification, String? expiredNotificationMessage})
const
AutoDisconnect.disabled()
Creates a disabled auto-disconnect configuration
const

Properties

duration int
Duration after which VPN will automatically disconnect (in seconds)
final
expiredNotificationMessage String?
Custom notification message when VPN disconnects (if onExpire == disconnectWithNotification) Default: "Free time expired - VPN disconnected"
final
hashCode int
The hash code for this object.
no setterinherited
onExpire OnExpireBehavior
What happens when the time expires
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showRemainingTimeInNotification bool
Whether to show remaining time in notification (Android only) Format: "Connected • 1h 30m 10s remaining" or "Connected • 1h 30m remaining"
final
timeFormat TimeFormat
Time format in notification
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toMap() Map<String, dynamic>
Converts to a map for method channel
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited