hamuga_id_sdk 0.0.4
hamuga_id_sdk: ^0.0.4 copied to clipboard
A Flutter package that provides a HamugaIdButton widget for easy integration with Hamuga ID authentication.
Hamuga ID SDK #
A Flutter package that provides a HamugaIdButton widget for easy integration with Hamuga ID authentication.
Features #
- A customizable
HamugaIdButtonwidget. - Support for different button sizes (
sm,md,lg,xl,xxl). - Multiple button variants (
primary,secondaryGray,secondaryColor,tertiaryGray,tertiaryColor,linkGray,linkColor). - Handles the Hamuga ID OAuth 2.0 authentication flow.
- Support for
openid,email,phone, anddanscopes.
Getting started #
-
Add this to your package's
pubspec.yamlfile:dependencies: hamuga_id_sdk: ^0.0.1 # Replace with the latest version -
Install it:
flutter pub get -
Import the package:
import 'package:hamuga_id_sdk/components/button.dart';
Usage #
Here is a basic example of how to use the HamugaIdButton:
import 'package:flutter/material.dart';
import 'package:hamuga_id_sdk/components/button.dart';
class LoginScreen extends StatelessWidget {
const LoginScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: HamugaIdButton(
clientId: 'YOUR_CLIENT_ID', // Replace with your client ID
redirectUri: 'YOUR_REDIRECT_URI', // Replace with your redirect URI
scope: const [HamugaIdScope.openid, HamugaIdScope.email],
onPressed: () {
// This callback is executed after the URL is launched.
print('Authentication process started...');
},
),
),
),
);
}
}
HamugaIdButton Properties #
| Parameter | Type | Description | Default |
|---|---|---|---|
onPressed |
VoidCallback? |
Callback function when the button is pressed. | null |
text |
String |
The text displayed on the button. | 'Хамуга ID-р нэвтрэх' |
leadingIcon |
Widget? |
A widget to display before the text. | SvgPicture of Hamuga logo |
trailingIcon |
Widget? |
A widget to display after the text. | null |
size |
HamugaButtonSize |
The size of the button. | HamugaButtonSize.md |
variant |
HamugaButtonVariant |
The visual style of the button. | HamugaButtonVariant.secondaryGray |
clientId |
String |
Required. Your application's client ID. | |
redirectUri |
String |
Required. The URI to redirect to after authentication. | |
state |
String? |
An opaque value used to maintain state between the request and the callback. | '123' |
baseUrl |
String? |
The base URL for the authentication endpoint. | 'https://hamuga.id/oauth/authorize' |
scope |
List<HamugaIdScope> |
Required. A list of scopes to request. | |
responseType |
String? |
The type of response expected. | 'code' |
enabled |
bool |
Whether the button is enabled. | true |
Enums #
HamugaButtonSize
smmdlgxlxxl
HamugaButtonVariant
primarysecondaryGraysecondaryColortertiaryGraytertiaryColorlinkGraylinkColor
HamugaIdScope
openidemailphonedan
Additional information #
For more information, feel free to browse the source code. If you encounter any issues or have suggestions, please file an issue on the project's GitHub repository.