AppLock class

A widget which handles app lifecycle events for showing and hiding a lock screen. This should wrap around a MyApp widget (or equivalent).

lockScreen (or preferably the Widget returned from lockScreenBuilder) is a Widget which should be a screen for handling login logic and calling AppLock.of(context).didUnlock(); upon a successful login.

builder is a Function taking an Object as its argument and should return a Widget. The Object argument is provided by the lockScreen (or preferably the Widget returned from lockScreenBuilder) calling AppLock.of(context).didUnlock(); with an argument. Object can then be injected in to your MyApp widget (or equivalent).

enabled determines wether or not the lockScreen (or preferably the Widget returned from lockScreenBuilder) should be shown on app launch and subsequent app pauses. This can be changed later on using AppLock.of(context).enable();, AppLock.of(context).disable(); or the convenience method AppLock.of(context).setEnabled(enabled); using a bool argument.

backgroundLockLatency determines how much time is allowed to pass when the app is in the background state before the lockScreen (or preferably the Widget returned from lockScreenBuilder) widget should be shown upon returning. It defaults to instantly.

Inheritance

Constructors

AppLock({Key? key, required Widget builder(BuildContext context, Object? launchArg), @Deprecated('Use `lockScreenBuilder` instead. `lockScreen` will be removed in version 5.0.0.') Widget? lockScreen, WidgetBuilder? lockScreenBuilder, WidgetBuilder? inactiveBuilder, bool enabled = true, Duration backgroundLockLatency = Duration.zero})
const

Properties

backgroundLockLatency Duration
final
builder Widget Function(BuildContext context, Object? launchArg)
final
enabled bool
final
hashCode int
The hash code for this object.
no setterinherited
inactiveBuilder WidgetBuilder?
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
lockScreen Widget?
final
lockScreenBuilder WidgetBuilder?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() AppLockState
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

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

Static Methods

of(BuildContext context) AppLockState?