GoogleSignInWidget class
A widget that provides Google Sign-In functionality for all platforms.
The widget can manage its own authentication state, or you can provide an external controller for advanced use cases like sharing state across multiple widgets or integrating with state management solutions.
When controller is not provided, you must supply client and optionally onAuthenticated and onError callbacks. When controller is provided, those callbacks are handled by the controller itself.
Example with managed state:
GoogleSignInWidget(
client: client,
onAuthenticated: () => Navigator.push(...),
onError: (error) => showSnackBar(...),
)
Example with external controller:
final controller = GoogleAuthController(
client: client,
onAuthenticated: ...,
);
GoogleSignInWidget(
controller: controller,
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- GoogleSignInWidget
Constructors
-
GoogleSignInWidget({GoogleAuthController? controller, ServerpodClientShared? client, VoidCallback? onAuthenticated, dynamic onError(Object error)?, bool attemptLightweightSignIn = true, List<
String> scopes = GoogleAuthController.defaultScopes, GSIButtonType type = GSIButtonType.standard, GSIButtonTheme theme = GSIButtonTheme.outline, GSIButtonSize size = GSIButtonSize.large, GSIButtonText text = GSIButtonText.continueWith, GSIButtonShape shape = GSIButtonShape.pill, GSIButtonLogoAlignment logoAlignment = GSIButtonLogoAlignment.center, double minimumWidth = 240, String getButtonText({bool isLoading})?, String? locale, Widget buttonWrapper({required Widget child, required VoidCallback? onPressed, required GoogleSignInStyle style})? = GoogleSignInBaseButton.wrapAsOutline, Key? key}) -
Creates a Google Sign-In widget.
const
Properties
- attemptLightweightSignIn → bool
-
Whether to attempt to authenticate the user automatically using the
attemptLightweightAuthenticationmethod after the widget is initialized.final -
A wrapper function to the rendered button to ensure style consistency.
final
- client → ServerpodClientShared?
-
The Serverpod client instance.
final
- controller → GoogleAuthController?
-
Controls the authentication state and behavior.
final
- getButtonText → String Function({bool isLoading})?
-
A function to generate the button text based on the current configuration.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- locale → String?
-
The pre-set locale of the button text.
final
- logoAlignment → GSIButtonLogoAlignment
-
The Google logo alignment: left or center.
final
- minimumWidth → double
-
The minimum button width, in pixels.
final
- onAuthenticated → VoidCallback?
-
Callback when authentication is successful.
final
- onError → dynamic Function(Object error)?
-
Callback when an error occurs during authentication.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
scopes
→ List<
String> -
Scopes to request from Google.
final
- shape → GSIButtonShape
-
The button shape.
final
- size → GSIButtonSize
-
The button size.
final
- text → GSIButtonText
-
The button text.
final
- theme → GSIButtonTheme
-
The button theme.
final
- type → GSIButtonType
-
The button type: icon, or standard button.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< GoogleSignInWidget> -
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, int wrapWidth = 65}) → 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