mirror of
https://github.com/Iconica-Development/flutter_login_widget.git
synced 2025-05-19 05:33:45 +02:00
Compare commits
8 commits
Author | SHA1 | Date | |
---|---|---|---|
|
9f66da6e2d | ||
|
e0b01d7f18 | ||
|
64a6755d04 | ||
|
5276f38643 | ||
|
d173ba11fc | ||
|
bd60fb05b0 | ||
|
f6c3e2479d | ||
|
ce0bc821b9 |
26 changed files with 583 additions and 479 deletions
14
.github/workflows/release.yml
vendored
Normal file
14
.github/workflows/release.yml
vendored
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
name: Iconica Standard Component Release Workflow
|
||||||
|
# Workflow Caller version: 1.0.0
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
call-global-iconica-workflow:
|
||||||
|
uses: Iconica-Development/.github/.github/workflows/component-release.yml@master
|
||||||
|
secrets: inherit
|
||||||
|
permissions: write-all
|
19
CHANGELOG.md
19
CHANGELOG.md
|
@ -1,3 +1,22 @@
|
||||||
|
## 7.3.0
|
||||||
|
|
||||||
|
* Added Biometrics support to the LoginOptions
|
||||||
|
|
||||||
|
## 7.2.0
|
||||||
|
|
||||||
|
* Added CustomSemantics widget that is used to wrap all the inputfields and buttons to make the component accessible for e2e testing.
|
||||||
|
* Upgraded pinput to 5.0.1 from 2.3.0
|
||||||
|
* Updated flutter_iconica_analysis to 7.0.0 with new rules
|
||||||
|
|
||||||
|
## 7.1.3
|
||||||
|
|
||||||
|
* Fixed forgotpassword description line height.
|
||||||
|
* Fixed default text.
|
||||||
|
|
||||||
|
## 7.1.2
|
||||||
|
|
||||||
|
* Added padding to the forgotpasswordRequestButton
|
||||||
|
|
||||||
## 7.1.1
|
## 7.1.1
|
||||||
|
|
||||||
* Changed default theme
|
* Changed default theme
|
||||||
|
|
38
README.md
38
README.md
|
@ -9,6 +9,44 @@ A package facilitating the basic ingredients for creating functional yet customi
|
||||||
|
|
||||||
To use this package, add `flutter_login` as a dependency in your pubspec.yaml file.
|
To use this package, add `flutter_login` as a dependency in your pubspec.yaml file.
|
||||||
|
|
||||||
|
|
||||||
|
### Biometrics authentication
|
||||||
|
You can use faceID or fingerprint by adding:
|
||||||
|
```dart
|
||||||
|
loginWithBiometrics: true,
|
||||||
|
triggerBiometricsAutomatically: true,
|
||||||
|
```
|
||||||
|
to the `LoginOptions` object. This will trigger the biometrics authentication immediately when the EmailPasswordLoginForm is shown.
|
||||||
|
|
||||||
|
For the full biometrics setup you can follow the instructions in the [local_auth](https://pub.dev/packages/local_auth) package.
|
||||||
|
|
||||||
|
You need to add the following permissions to your AndroidManifest.xml file:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<uses-permission android:name="android.permission.USE_BIOMETRIC"/>
|
||||||
|
```
|
||||||
|
|
||||||
|
```java
|
||||||
|
import io.flutter.embedding.android.FlutterFragmentActivity;
|
||||||
|
|
||||||
|
public class MainActivity extends FlutterFragmentActivity {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
or MainActivity.kt:
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
import io.flutter.embedding.android.FlutterFragmentActivity
|
||||||
|
|
||||||
|
class MainActivity: FlutterFragmentActivity() {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
to inherit from `FlutterFragmentActivity`.
|
||||||
|
|
||||||
|
|
||||||
## How to use
|
## How to use
|
||||||
|
|
||||||
```dart
|
```dart
|
||||||
|
|
BIN
assets/2.0x/ios_fingerprint.png
Normal file
BIN
assets/2.0x/ios_fingerprint.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
BIN
assets/3.0x/ios_fingerprint.png
Normal file
BIN
assets/3.0x/ios_fingerprint.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.7 KiB |
BIN
assets/ios_fingerprint.png
Normal file
BIN
assets/ios_fingerprint.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
3
example/.gitignore
vendored
3
example/.gitignore
vendored
|
@ -5,9 +5,11 @@
|
||||||
*.swp
|
*.swp
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.atom/
|
.atom/
|
||||||
|
.build/
|
||||||
.buildlog/
|
.buildlog/
|
||||||
.history
|
.history
|
||||||
.svn/
|
.svn/
|
||||||
|
.swiftpm/
|
||||||
migrate_working_dir/
|
migrate_working_dir/
|
||||||
|
|
||||||
# IntelliJ related
|
# IntelliJ related
|
||||||
|
@ -32,6 +34,7 @@ migrate_working_dir/
|
||||||
.pub/
|
.pub/
|
||||||
/build/
|
/build/
|
||||||
.metadata
|
.metadata
|
||||||
|
pubspec.lock
|
||||||
|
|
||||||
# Symbolication related
|
# Symbolication related
|
||||||
app.*.symbols
|
app.*.symbols
|
||||||
|
|
1
example/README.md
Symbolic link
1
example/README.md
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../README.md
|
|
@ -1,29 +1,12 @@
|
||||||
# This file configures the analyzer, which statically analyzes Dart code to
|
include: package:flutter_iconica_analysis/analysis_options.yaml
|
||||||
# check for errors, warnings, and lints.
|
|
||||||
#
|
|
||||||
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
|
|
||||||
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
|
|
||||||
# invoked from the command line by running `flutter analyze`.
|
|
||||||
|
|
||||||
# The following line activates a set of recommended lints for Flutter apps,
|
# https://dart-lang.github.io/linter/lints/index.html
|
||||||
# packages, and plugins designed to encourage good coding practices.
|
|
||||||
include: package:flutter_lints/flutter.yaml
|
# Possible to overwrite the rules from the package
|
||||||
|
|
||||||
|
analyzer:
|
||||||
|
plugins:
|
||||||
|
exclude:
|
||||||
|
|
||||||
linter:
|
linter:
|
||||||
# The lint rules applied to this project can be customized in the
|
|
||||||
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
|
|
||||||
# included above or to enable additional rules. A list of all available lints
|
|
||||||
# and their documentation is published at
|
|
||||||
# https://dart-lang.github.io/linter/lints/index.html.
|
|
||||||
#
|
|
||||||
# Instead of disabling a lint rule for the entire project in the
|
|
||||||
# section below, it can also be suppressed for a single line of code
|
|
||||||
# or a specific dart file by using the `// ignore: name_of_lint` and
|
|
||||||
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
|
|
||||||
# producing the lint.
|
|
||||||
rules:
|
rules:
|
||||||
# avoid_print: false # Uncomment to disable the `avoid_print` rule
|
|
||||||
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
|
|
||||||
|
|
||||||
# Additional information about this file can be found at
|
|
||||||
# https://dart.dev/guides/language/analysis-options
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// ignore_for_file: avoid_print
|
// ignore_for_file: avoid_print
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import "package:flutter/material.dart";
|
||||||
import 'package:flutter_login/flutter_login.dart';
|
import "package:flutter_login/flutter_login.dart";
|
||||||
|
|
||||||
final loginOptions = LoginOptions(
|
final loginOptions = LoginOptions(
|
||||||
emailDecoration: const InputDecoration(
|
emailDecoration: const InputDecoration(
|
||||||
|
@ -15,21 +15,24 @@ final loginOptions = LoginOptions(
|
||||||
image: const FlutterLogo(
|
image: const FlutterLogo(
|
||||||
size: 200,
|
size: 200,
|
||||||
),
|
),
|
||||||
|
biometricsOptions: const LoginBiometricsOptions(
|
||||||
|
loginWithBiometrics: true,
|
||||||
|
triggerBiometricsAutomatically: false,
|
||||||
|
),
|
||||||
requestForgotPasswordButtonBuilder: (
|
requestForgotPasswordButtonBuilder: (
|
||||||
context,
|
context,
|
||||||
onPressed,
|
onPressed,
|
||||||
isDisabled,
|
isDisabled,
|
||||||
onDisabledPress,
|
onDisabledPress,
|
||||||
translations,
|
translations,
|
||||||
) {
|
) =>
|
||||||
return Opacity(
|
Opacity(
|
||||||
opacity: isDisabled ? 0.5 : 1.0,
|
opacity: isDisabled ? 0.5 : 1.0,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: isDisabled ? onDisabledPress : onPressed,
|
onPressed: isDisabled ? onDisabledPress : onPressed,
|
||||||
child: const Text('Send request'),
|
child: const Text("Send request"),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
@ -40,54 +43,46 @@ class LoginExample extends StatelessWidget {
|
||||||
const LoginExample({super.key});
|
const LoginExample({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) => MaterialApp(
|
||||||
return MaterialApp(
|
|
||||||
theme: ThemeData.dark(),
|
theme: ThemeData.dark(),
|
||||||
home: const LoginScreen(),
|
home: const LoginScreen(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
class LoginScreen extends StatelessWidget {
|
class LoginScreen extends StatelessWidget {
|
||||||
const LoginScreen({super.key});
|
const LoginScreen({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) => Scaffold(
|
||||||
return Scaffold(
|
|
||||||
body: EmailPasswordLoginForm(
|
body: EmailPasswordLoginForm(
|
||||||
title: const Text('Login Demo'),
|
title: const Text("Login Demo"),
|
||||||
options: loginOptions,
|
options: loginOptions,
|
||||||
onLogin: (email, password) => print('$email:$password'),
|
onLogin: (email, password) => print("$email:$password"),
|
||||||
onRegister: (email, password, ctx) => print('Register!'),
|
onRegister: (email, password, ctx) => print("Register!"),
|
||||||
onForgotPassword: (email, ctx) {
|
onForgotPassword: (email, ctx) async {
|
||||||
Navigator.of(context).push(
|
await Navigator.of(context).push(
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) {
|
builder: (context) => const ForgotPasswordScreen(),
|
||||||
return const ForgotPasswordScreen();
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
class ForgotPasswordScreen extends StatelessWidget {
|
class ForgotPasswordScreen extends StatelessWidget {
|
||||||
const ForgotPasswordScreen({super.key});
|
const ForgotPasswordScreen({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) => Scaffold(
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(),
|
appBar: AppBar(),
|
||||||
body: ForgotPasswordForm(
|
body: ForgotPasswordForm(
|
||||||
options: loginOptions,
|
options: loginOptions,
|
||||||
title: const Text('Forgot password'),
|
title: const Text("Forgot password"),
|
||||||
description: const Text('Hello world'),
|
description: const Text("Hello world"),
|
||||||
onRequestForgotPassword: (email) {
|
onRequestForgotPassword: (email) {
|
||||||
print('Forgot password email sent to $email');
|
print("Forgot password email sent to $email");
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -1,241 +0,0 @@
|
||||||
# Generated by pub
|
|
||||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
|
||||||
packages:
|
|
||||||
async:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: async
|
|
||||||
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.11.0"
|
|
||||||
boolean_selector:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: boolean_selector
|
|
||||||
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.1.1"
|
|
||||||
characters:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: characters
|
|
||||||
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.3.0"
|
|
||||||
clock:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: clock
|
|
||||||
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.1.1"
|
|
||||||
collection:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: collection
|
|
||||||
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.18.0"
|
|
||||||
fake_async:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: fake_async
|
|
||||||
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.3.1"
|
|
||||||
flutter:
|
|
||||||
dependency: "direct main"
|
|
||||||
description: flutter
|
|
||||||
source: sdk
|
|
||||||
version: "0.0.0"
|
|
||||||
flutter_lints:
|
|
||||||
dependency: "direct dev"
|
|
||||||
description:
|
|
||||||
name: flutter_lints
|
|
||||||
sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.0.3"
|
|
||||||
flutter_login:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
path: ".."
|
|
||||||
relative: true
|
|
||||||
source: path
|
|
||||||
version: "7.1.0"
|
|
||||||
flutter_test:
|
|
||||||
dependency: "direct dev"
|
|
||||||
description: flutter
|
|
||||||
source: sdk
|
|
||||||
version: "0.0.0"
|
|
||||||
flutter_web_plugins:
|
|
||||||
dependency: transitive
|
|
||||||
description: flutter
|
|
||||||
source: sdk
|
|
||||||
version: "0.0.0"
|
|
||||||
leak_tracker:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: leak_tracker
|
|
||||||
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "10.0.4"
|
|
||||||
leak_tracker_flutter_testing:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: leak_tracker_flutter_testing
|
|
||||||
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "3.0.3"
|
|
||||||
leak_tracker_testing:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: leak_tracker_testing
|
|
||||||
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "3.0.1"
|
|
||||||
lints:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: lints
|
|
||||||
sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.1.1"
|
|
||||||
matcher:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: matcher
|
|
||||||
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.12.16+1"
|
|
||||||
material_color_utilities:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: material_color_utilities
|
|
||||||
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.8.0"
|
|
||||||
meta:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: meta
|
|
||||||
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.12.0"
|
|
||||||
path:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: path
|
|
||||||
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.9.0"
|
|
||||||
pinput:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: pinput
|
|
||||||
sha256: "543da5bfdefd9e06914a12100f8c9156f84cef3efc14bca507c49e966c5b813b"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.3.0"
|
|
||||||
sky_engine:
|
|
||||||
dependency: transitive
|
|
||||||
description: flutter
|
|
||||||
source: sdk
|
|
||||||
version: "0.0.99"
|
|
||||||
smart_auth:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: smart_auth
|
|
||||||
sha256: a25229b38c02f733d0a4e98d941b42bed91a976cb589e934895e60ccfa674cf6
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.1.1"
|
|
||||||
source_span:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: source_span
|
|
||||||
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.10.0"
|
|
||||||
stack_trace:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: stack_trace
|
|
||||||
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.11.1"
|
|
||||||
stream_channel:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: stream_channel
|
|
||||||
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.1.2"
|
|
||||||
string_scanner:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: string_scanner
|
|
||||||
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.2.0"
|
|
||||||
term_glyph:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: term_glyph
|
|
||||||
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.2.1"
|
|
||||||
test_api:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: test_api
|
|
||||||
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.7.0"
|
|
||||||
universal_platform:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: universal_platform
|
|
||||||
sha256: "64e16458a0ea9b99260ceb5467a214c1f298d647c659af1bff6d3bf82536b1ec"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.1.0"
|
|
||||||
vector_math:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: vector_math
|
|
||||||
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.1.4"
|
|
||||||
vm_service:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: vm_service
|
|
||||||
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "14.2.1"
|
|
||||||
sdks:
|
|
||||||
dart: ">=3.3.0 <4.0.0"
|
|
||||||
flutter: ">=3.18.0-18.0.pre.54"
|
|
|
@ -1,14 +1,12 @@
|
||||||
name: example
|
name: example
|
||||||
description: A new Flutter project.
|
description: A new Flutter project.
|
||||||
|
|
||||||
# The following line prevents the package from being accidentally published to
|
publish_to: "none"
|
||||||
# pub.dev using `flutter pub publish`. This is preferred for private packages.
|
|
||||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|
||||||
|
|
||||||
version: 1.0.0+1
|
version: 1.0.0+1
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.18.1 <3.0.0'
|
sdk: ">=2.18.1 <3.0.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
|
@ -16,11 +14,12 @@ dependencies:
|
||||||
flutter_login:
|
flutter_login:
|
||||||
path: ../
|
path: ../
|
||||||
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_lints: ^2.0.0
|
flutter_iconica_analysis:
|
||||||
|
hosted: https://forgejo.internal.iconica.nl/api/packages/internal/pub
|
||||||
|
version: ^7.0.0
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
7
example/test/widget_test.dart
Normal file
7
example/test/widget_test.dart
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import "package:flutter_test/flutter_test.dart";
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
test("blank test", () {
|
||||||
|
expect(true, true);
|
||||||
|
});
|
||||||
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
///
|
///
|
||||||
library flutter_login;
|
library flutter_login;
|
||||||
|
|
||||||
export 'src/config/forgot_password_spacer_options.dart';
|
export "src/config/forgot_password_spacer_options.dart";
|
||||||
export 'src/config/login_options.dart';
|
export "src/config/login_options.dart";
|
||||||
export 'src/config/spacer_options.dart';
|
export "src/config/spacer_options.dart";
|
||||||
export 'src/service/login_validation.dart';
|
export "src/service/login_validation.dart";
|
||||||
export 'src/service/validation.dart';
|
export "src/service/validation.dart";
|
||||||
export 'src/widgets/email_password_login.dart';
|
export "src/widgets/email_password_login.dart";
|
||||||
export 'src/widgets/forgot_password_form.dart';
|
export "src/widgets/forgot_password_form.dart";
|
||||||
export 'src/widgets/mfa_widget.dart';
|
export "src/widgets/mfa_widget.dart";
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import 'package:flutter/material.dart';
|
import "package:flutter/material.dart";
|
||||||
|
|
||||||
@immutable
|
@immutable
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import 'dart:async';
|
import "dart:async";
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import "package:flutter/material.dart";
|
||||||
import 'package:flutter_login/src/config/forgot_password_spacer_options.dart';
|
import "package:flutter_login/src/config/forgot_password_spacer_options.dart";
|
||||||
import 'package:flutter_login/src/config/spacer_options.dart';
|
import "package:flutter_login/src/config/spacer_options.dart";
|
||||||
import 'package:flutter_login/src/service/login_validation.dart';
|
import "package:flutter_login/src/service/login_validation.dart";
|
||||||
import 'package:flutter_login/src/service/validation.dart';
|
import "package:flutter_login/src/service/validation.dart";
|
||||||
|
|
||||||
@immutable
|
@immutable
|
||||||
class LoginOptions {
|
class LoginOptions {
|
||||||
|
@ -17,7 +17,7 @@ class LoginOptions {
|
||||||
this.passwordTextAlign,
|
this.passwordTextAlign,
|
||||||
this.emailDecoration = const InputDecoration(
|
this.emailDecoration = const InputDecoration(
|
||||||
contentPadding: EdgeInsets.symmetric(horizontal: 8),
|
contentPadding: EdgeInsets.symmetric(horizontal: 8),
|
||||||
labelText: 'Email address',
|
labelText: "Email address",
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: OutlineInputBorder(
|
||||||
borderSide: BorderSide(
|
borderSide: BorderSide(
|
||||||
|
@ -32,7 +32,7 @@ class LoginOptions {
|
||||||
),
|
),
|
||||||
this.passwordDecoration = const InputDecoration(
|
this.passwordDecoration = const InputDecoration(
|
||||||
contentPadding: EdgeInsets.symmetric(horizontal: 8),
|
contentPadding: EdgeInsets.symmetric(horizontal: 8),
|
||||||
labelText: 'Password',
|
labelText: "Password",
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: OutlineInputBorder(
|
||||||
borderSide: BorderSide(
|
borderSide: BorderSide(
|
||||||
|
@ -45,14 +45,15 @@ class LoginOptions {
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
this.initialEmail = '',
|
this.initialEmail = "",
|
||||||
this.initialPassword = '',
|
this.initialPassword = "",
|
||||||
this.spacers = const LoginSpacerOptions(
|
this.spacers = const LoginSpacerOptions(
|
||||||
spacerBeforeTitle: 8,
|
spacerBeforeTitle: 8,
|
||||||
spacerAfterTitle: 2,
|
spacerAfterTitle: 2,
|
||||||
formFlexValue: 2,
|
formFlexValue: 2,
|
||||||
),
|
),
|
||||||
this.translations = const LoginTranslations(),
|
this.translations = const LoginTranslations(),
|
||||||
|
this.accessibilityIdentifiers = const LoginAccessibilityIdentifiers.empty(),
|
||||||
this.validationService,
|
this.validationService,
|
||||||
this.loginButtonBuilder = _createLoginButton,
|
this.loginButtonBuilder = _createLoginButton,
|
||||||
this.forgotPasswordButtonBuilder = _createForgotPasswordButton,
|
this.forgotPasswordButtonBuilder = _createForgotPasswordButton,
|
||||||
|
@ -74,6 +75,7 @@ class LoginOptions {
|
||||||
this.forgotPasswordCustomAppBar,
|
this.forgotPasswordCustomAppBar,
|
||||||
this.suffixIconSize,
|
this.suffixIconSize,
|
||||||
this.suffixIconPadding,
|
this.suffixIconPadding,
|
||||||
|
this.biometricsOptions = const LoginBiometricsOptions(),
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Builds the login button.
|
/// Builds the login button.
|
||||||
|
@ -134,6 +136,12 @@ class LoginOptions {
|
||||||
/// Translations for various texts on the login screen.
|
/// Translations for various texts on the login screen.
|
||||||
final LoginTranslations translations;
|
final LoginTranslations translations;
|
||||||
|
|
||||||
|
/// Accessibility identifiers for the standard widgets in the component.
|
||||||
|
/// The inputfields and buttons have accessibility identifiers and their own
|
||||||
|
/// container so they are visible in the accessibility tree.
|
||||||
|
/// This is used for testing purposes.
|
||||||
|
final LoginAccessibilityIdentifiers accessibilityIdentifiers;
|
||||||
|
|
||||||
/// The validation service used for validating email and password inputs.
|
/// The validation service used for validating email and password inputs.
|
||||||
final ValidationService? validationService;
|
final ValidationService? validationService;
|
||||||
|
|
||||||
|
@ -157,17 +165,55 @@ class LoginOptions {
|
||||||
|
|
||||||
/// forgot password custom AppBar
|
/// forgot password custom AppBar
|
||||||
final AppBar? forgotPasswordCustomAppBar;
|
final AppBar? forgotPasswordCustomAppBar;
|
||||||
|
|
||||||
|
/// Options for enabling and customizing biometrics login
|
||||||
|
final LoginBiometricsOptions biometricsOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class LoginBiometricsOptions {
|
||||||
|
const LoginBiometricsOptions({
|
||||||
|
this.loginWithBiometrics = false,
|
||||||
|
this.triggerBiometricsAutomatically = false,
|
||||||
|
this.allowBiometricsAlternative = true,
|
||||||
|
this.onBiometricsSuccess,
|
||||||
|
this.onBiometricsError,
|
||||||
|
this.onBiometricsFail,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// Ask the user to login with biometrics instead of email and password.
|
||||||
|
final bool loginWithBiometrics;
|
||||||
|
|
||||||
|
/// Allow the user to login with biometrics even if they have no biometrics
|
||||||
|
/// set up on their device. This will use their device native login methods.
|
||||||
|
final bool allowBiometricsAlternative;
|
||||||
|
|
||||||
|
/// Automatically open the native biometrics UI instead of waiting for the
|
||||||
|
/// user to press the biometrics button
|
||||||
|
final bool triggerBiometricsAutomatically;
|
||||||
|
|
||||||
|
/// The callback function to be called when the biometrics login is
|
||||||
|
/// successful.
|
||||||
|
final OptionalAsyncCallback? onBiometricsSuccess;
|
||||||
|
|
||||||
|
/// The callback function to be called when the biometrics login fails.
|
||||||
|
final OptionalAsyncCallback? onBiometricsFail;
|
||||||
|
|
||||||
|
/// The callback function to be called when the biometrics login errors.
|
||||||
|
final OptionalAsyncCallback? onBiometricsError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Translations for all the texts in the component
|
||||||
class LoginTranslations {
|
class LoginTranslations {
|
||||||
|
/// Provide your own translations to override the default english translations
|
||||||
const LoginTranslations({
|
const LoginTranslations({
|
||||||
this.emailEmpty = 'Email is required',
|
this.emailEmpty = "Please enter your email address",
|
||||||
this.passwordEmpty = 'Password is required',
|
this.passwordEmpty = "Please enter your password",
|
||||||
this.emailInvalid = 'Enter a valid email address',
|
this.emailInvalid = "Please enter a valid email address",
|
||||||
this.loginButton = 'Log in',
|
this.loginButton = "Log in",
|
||||||
this.forgotPasswordButton = 'Forgot password?',
|
this.forgotPasswordButton = "Forgot password?",
|
||||||
this.requestForgotPasswordButton = 'Send link',
|
this.requestForgotPasswordButton = "Send link",
|
||||||
this.registrationButton = 'Create account',
|
this.registrationButton = "Create account",
|
||||||
|
this.biometricsLoginMessage = "Log in with biometrics",
|
||||||
});
|
});
|
||||||
|
|
||||||
final String emailInvalid;
|
final String emailInvalid;
|
||||||
|
@ -177,6 +223,53 @@ class LoginTranslations {
|
||||||
final String forgotPasswordButton;
|
final String forgotPasswordButton;
|
||||||
final String requestForgotPasswordButton;
|
final String requestForgotPasswordButton;
|
||||||
final String registrationButton;
|
final String registrationButton;
|
||||||
|
final String biometricsLoginMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Accessibility identifiers for the standard widgets in the component.
|
||||||
|
class LoginAccessibilityIdentifiers {
|
||||||
|
/// Default [LoginAccessibilityIdentifiers] constructor where all the
|
||||||
|
/// identifiers are required. This is to ensure that apps automatically break
|
||||||
|
/// when new identifiers are added.
|
||||||
|
const LoginAccessibilityIdentifiers({
|
||||||
|
required this.emailTextFieldIdentifier,
|
||||||
|
required this.passwordTextFieldIdentifier,
|
||||||
|
required this.loginButtonIdentifier,
|
||||||
|
required this.forgotPasswordButtonIdentifier,
|
||||||
|
required this.requestForgotPasswordButtonIdentifier,
|
||||||
|
required this.registrationButtonIdentifier,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// Empty [LoginAccessibilityIdentifiers] constructor where all the
|
||||||
|
/// identifiers are already set to their default values. You can override all
|
||||||
|
/// or some of the default values.
|
||||||
|
const LoginAccessibilityIdentifiers.empty({
|
||||||
|
this.emailTextFieldIdentifier = "email_text_field",
|
||||||
|
this.passwordTextFieldIdentifier = "password_text_field",
|
||||||
|
this.loginButtonIdentifier = "login_button",
|
||||||
|
this.forgotPasswordButtonIdentifier = "forgot_password_button",
|
||||||
|
this.requestForgotPasswordButtonIdentifier =
|
||||||
|
"request_forgot_password_button",
|
||||||
|
this.registrationButtonIdentifier = "registration_button",
|
||||||
|
});
|
||||||
|
|
||||||
|
/// Identifier for the email text field.
|
||||||
|
final String emailTextFieldIdentifier;
|
||||||
|
|
||||||
|
/// Identifier for the password text field.
|
||||||
|
final String passwordTextFieldIdentifier;
|
||||||
|
|
||||||
|
/// Identifier for the login button.
|
||||||
|
final String loginButtonIdentifier;
|
||||||
|
|
||||||
|
/// Identifier for the forgot password button.
|
||||||
|
final String forgotPasswordButtonIdentifier;
|
||||||
|
|
||||||
|
/// Identifier for the request forgot password button.
|
||||||
|
final String requestForgotPasswordButtonIdentifier;
|
||||||
|
|
||||||
|
/// Identifier for the registration button.
|
||||||
|
final String registrationButtonIdentifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _createEmailInputContainer(Widget child) => Padding(
|
Widget _createEmailInputContainer(Widget child) => Padding(
|
||||||
|
@ -250,6 +343,8 @@ Widget _createRequestForgotPasswordButton(
|
||||||
) =>
|
) =>
|
||||||
Opacity(
|
Opacity(
|
||||||
opacity: disabled ? 0.5 : 1.0,
|
opacity: disabled ? 0.5 : 1.0,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 8),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: !disabled ? onPressed : onDisabledPress,
|
onTap: !disabled ? onPressed : onDisabledPress,
|
||||||
child: Container(
|
child: Container(
|
||||||
|
@ -271,6 +366,7 @@ Widget _createRequestForgotPasswordButton(
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
Widget _createRegisterButton(
|
Widget _createRegisterButton(
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import 'package:flutter/material.dart';
|
import "package:flutter/material.dart";
|
||||||
|
|
||||||
@immutable
|
@immutable
|
||||||
class LoginSpacerOptions {
|
class LoginSpacerOptions {
|
||||||
|
|
35
lib/src/service/local_auth_service.dart
Normal file
35
lib/src/service/local_auth_service.dart
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
import "package:flutter/services.dart";
|
||||||
|
import "package:flutter_login/src/config/login_options.dart";
|
||||||
|
import "package:local_auth/local_auth.dart";
|
||||||
|
|
||||||
|
class LocalAuthService {
|
||||||
|
final LocalAuthentication _localAuth = LocalAuthentication();
|
||||||
|
|
||||||
|
Future<void> authenticate(LoginOptions loginOptions) async {
|
||||||
|
var biometricsOptions = loginOptions.biometricsOptions;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!await _localAuth.isDeviceSupported()) {
|
||||||
|
biometricsOptions.onBiometricsError?.call();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var didAuthenticate = await _localAuth.authenticate(
|
||||||
|
localizedReason: loginOptions.translations.biometricsLoginMessage,
|
||||||
|
options: AuthenticationOptions(
|
||||||
|
biometricOnly: !biometricsOptions.allowBiometricsAlternative,
|
||||||
|
stickyAuth: true,
|
||||||
|
sensitiveTransaction: false,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (didAuthenticate) {
|
||||||
|
biometricsOptions.onBiometricsSuccess?.call();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!didAuthenticate) {
|
||||||
|
biometricsOptions.onBiometricsFail?.call();
|
||||||
|
}
|
||||||
|
} on PlatformException catch (_) {
|
||||||
|
biometricsOptions.onBiometricsError?.call();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
import 'package:flutter_login/flutter_login.dart';
|
import "package:flutter_login/flutter_login.dart";
|
||||||
|
|
||||||
class LoginValidationService implements ValidationService {
|
class LoginValidationService implements ValidationService {
|
||||||
const LoginValidationService(this.options);
|
const LoginValidationService(this.options);
|
||||||
|
|
45
lib/src/widgets/biometrics_button.dart
Normal file
45
lib/src/widgets/biometrics_button.dart
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
import "dart:async";
|
||||||
|
import "dart:io";
|
||||||
|
|
||||||
|
import "package:flutter/foundation.dart";
|
||||||
|
import "package:flutter/material.dart";
|
||||||
|
|
||||||
|
class BiometricsButton extends StatelessWidget {
|
||||||
|
const BiometricsButton({
|
||||||
|
required this.onPressed,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
static const Size buttonSize = Size(40, 40);
|
||||||
|
|
||||||
|
final FutureOr<void> Function() onPressed;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
// handle unsupported platforms
|
||||||
|
if (kIsWeb || Platform.isLinux) return SizedBox(width: buttonSize.width);
|
||||||
|
Widget biometricsWidget;
|
||||||
|
|
||||||
|
if (Platform.isIOS || Platform.isMacOS) {
|
||||||
|
biometricsWidget = Image(
|
||||||
|
image: const AssetImage(
|
||||||
|
"assets/ios_fingerprint.png",
|
||||||
|
package: "flutter_login",
|
||||||
|
),
|
||||||
|
width: buttonSize.width,
|
||||||
|
height: buttonSize.height,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
biometricsWidget = Icon(
|
||||||
|
Icons.fingerprint,
|
||||||
|
size: buttonSize.width,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return InkWell(
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
onTap: onPressed,
|
||||||
|
child: biometricsWidget,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
36
lib/src/widgets/custom_semantics.dart
Normal file
36
lib/src/widgets/custom_semantics.dart
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
import "dart:io";
|
||||||
|
|
||||||
|
import "package:flutter/foundation.dart";
|
||||||
|
import "package:flutter/material.dart";
|
||||||
|
|
||||||
|
/// A wrapper that wraps a widget with a [Semantics] widget.
|
||||||
|
/// This is used for testing purposes to add a unique identifier to a widget.
|
||||||
|
/// The [identifier] should be unique
|
||||||
|
/// [container] is set to true to make sure the widget is always its own
|
||||||
|
/// accessibility element.
|
||||||
|
/// [excludeSemantics] is set to false to make sure that the widget can still
|
||||||
|
/// receive input.
|
||||||
|
class CustomSemantics extends StatelessWidget {
|
||||||
|
/// Creates a [CustomSemantics] widget.
|
||||||
|
/// The [identifier] should be unique for the specific screen.
|
||||||
|
const CustomSemantics({
|
||||||
|
required this.identifier,
|
||||||
|
required this.child,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// The widget that should be wrapped with a [Semantics] widget.
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
/// Identifier for the widget that should be unique for the specific screen.
|
||||||
|
final String identifier;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => Semantics(
|
||||||
|
excludeSemantics: false,
|
||||||
|
container: true,
|
||||||
|
label: kIsWeb || Platform.isIOS ? null : identifier,
|
||||||
|
identifier: identifier,
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
|
@ -1,7 +1,10 @@
|
||||||
import 'dart:async';
|
import "dart:async";
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import "package:flutter/material.dart";
|
||||||
import 'package:flutter_login/flutter_login.dart';
|
import "package:flutter_login/flutter_login.dart";
|
||||||
|
import "package:flutter_login/src/service/local_auth_service.dart";
|
||||||
|
import "package:flutter_login/src/widgets/biometrics_button.dart";
|
||||||
|
import "package:flutter_login/src/widgets/custom_semantics.dart";
|
||||||
|
|
||||||
class EmailPasswordLoginForm extends StatefulWidget {
|
class EmailPasswordLoginForm extends StatefulWidget {
|
||||||
/// Constructs an [EmailPasswordLoginForm] widget.
|
/// Constructs an [EmailPasswordLoginForm] widget.
|
||||||
|
@ -45,8 +48,10 @@ class _EmailPasswordLoginFormState extends State<EmailPasswordLoginForm> {
|
||||||
final ValueNotifier<bool> _formValid = ValueNotifier(false);
|
final ValueNotifier<bool> _formValid = ValueNotifier(false);
|
||||||
bool _obscurePassword = true;
|
bool _obscurePassword = true;
|
||||||
|
|
||||||
String _currentEmail = '';
|
String _currentEmail = "";
|
||||||
String _currentPassword = '';
|
String _currentPassword = "";
|
||||||
|
|
||||||
|
final LocalAuthService _localAuthService = LocalAuthService();
|
||||||
|
|
||||||
void _updateCurrentEmail(String email) {
|
void _updateCurrentEmail(String email) {
|
||||||
_currentEmail = email;
|
_currentEmail = email;
|
||||||
|
@ -86,13 +91,22 @@ class _EmailPasswordLoginFormState extends State<EmailPasswordLoginForm> {
|
||||||
_currentEmail = widget.options.initialEmail;
|
_currentEmail = widget.options.initialEmail;
|
||||||
_currentPassword = widget.options.initialPassword;
|
_currentPassword = widget.options.initialPassword;
|
||||||
_validate();
|
_validate();
|
||||||
|
|
||||||
|
if (widget.options.biometricsOptions.loginWithBiometrics &&
|
||||||
|
widget.options.biometricsOptions.triggerBiometricsAutomatically) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||||
|
await _localAuthService.authenticate(widget.options);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var options = widget.options;
|
var options = widget.options;
|
||||||
|
|
||||||
var emailTextFormField = TextFormField(
|
var emailTextFormField = CustomSemantics(
|
||||||
|
identifier: options.accessibilityIdentifiers.emailTextFieldIdentifier,
|
||||||
|
child: TextFormField(
|
||||||
autofillHints: const [
|
autofillHints: const [
|
||||||
AutofillHints.email,
|
AutofillHints.email,
|
||||||
AutofillHints.username,
|
AutofillHints.username,
|
||||||
|
@ -105,9 +119,12 @@ class _EmailPasswordLoginFormState extends State<EmailPasswordLoginForm> {
|
||||||
textInputAction: TextInputAction.next,
|
textInputAction: TextInputAction.next,
|
||||||
style: options.emailTextStyle,
|
style: options.emailTextStyle,
|
||||||
decoration: options.emailDecoration,
|
decoration: options.emailDecoration,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
var passwordTextFormField = TextFormField(
|
var passwordTextFormField = CustomSemantics(
|
||||||
|
identifier: options.accessibilityIdentifiers.passwordTextFieldIdentifier,
|
||||||
|
child: TextFormField(
|
||||||
autofillHints: const [
|
autofillHints: const [
|
||||||
AutofillHints.password,
|
AutofillHints.password,
|
||||||
],
|
],
|
||||||
|
@ -136,11 +153,15 @@ class _EmailPasswordLoginFormState extends State<EmailPasswordLoginForm> {
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
var forgotPasswordButton = widget.onForgotPassword != null
|
var forgotPasswordButton = widget.onForgotPassword != null
|
||||||
? Align(
|
? Align(
|
||||||
alignment: Alignment.topRight,
|
alignment: Alignment.topRight,
|
||||||
|
child: CustomSemantics(
|
||||||
|
identifier: options
|
||||||
|
.accessibilityIdentifiers.forgotPasswordButtonIdentifier,
|
||||||
child: options.forgotPasswordButtonBuilder(
|
child: options.forgotPasswordButtonBuilder(
|
||||||
context,
|
context,
|
||||||
() => widget.onForgotPassword?.call(_currentEmail, context),
|
() => widget.onForgotPassword?.call(_currentEmail, context),
|
||||||
|
@ -148,12 +169,15 @@ class _EmailPasswordLoginFormState extends State<EmailPasswordLoginForm> {
|
||||||
() {},
|
() {},
|
||||||
options,
|
options,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: const SizedBox(height: 16);
|
: const SizedBox(height: 16);
|
||||||
|
|
||||||
var loginButton = AnimatedBuilder(
|
var loginButton = AnimatedBuilder(
|
||||||
animation: _formValid,
|
animation: _formValid,
|
||||||
builder: (context, _) => options.loginButtonBuilder(
|
builder: (context, _) => CustomSemantics(
|
||||||
|
identifier: options.accessibilityIdentifiers.loginButtonIdentifier,
|
||||||
|
child: options.loginButtonBuilder(
|
||||||
context,
|
context,
|
||||||
_handleLogin,
|
_handleLogin,
|
||||||
!_formValid.value,
|
!_formValid.value,
|
||||||
|
@ -162,9 +186,12 @@ class _EmailPasswordLoginFormState extends State<EmailPasswordLoginForm> {
|
||||||
},
|
},
|
||||||
options,
|
options,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
var registerButton = options.registrationButtonBuilder(
|
var registrationButton = CustomSemantics(
|
||||||
|
identifier: options.accessibilityIdentifiers.registrationButtonIdentifier,
|
||||||
|
child: options.registrationButtonBuilder(
|
||||||
context,
|
context,
|
||||||
() async {
|
() async {
|
||||||
widget.onRegister?.call(
|
widget.onRegister?.call(
|
||||||
|
@ -176,6 +203,11 @@ class _EmailPasswordLoginFormState extends State<EmailPasswordLoginForm> {
|
||||||
false,
|
false,
|
||||||
() {},
|
() {},
|
||||||
options,
|
options,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
var biometricsButton = BiometricsButton(
|
||||||
|
onPressed: () async => LocalAuthService().authenticate(options),
|
||||||
);
|
);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
@ -218,9 +250,24 @@ class _EmailPasswordLoginFormState extends State<EmailPasswordLoginForm> {
|
||||||
if (options.spacers.spacerAfterForm != null) ...[
|
if (options.spacers.spacerAfterForm != null) ...[
|
||||||
Spacer(flex: options.spacers.spacerAfterForm!),
|
Spacer(flex: options.spacers.spacerAfterForm!),
|
||||||
],
|
],
|
||||||
|
if (options
|
||||||
|
.biometricsOptions.loginWithBiometrics) ...[
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: BiometricsButton.buttonSize.width,
|
||||||
|
),
|
||||||
loginButton,
|
loginButton,
|
||||||
|
biometricsButton,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
] else ...[
|
||||||
|
loginButton,
|
||||||
|
],
|
||||||
if (widget.onRegister != null) ...[
|
if (widget.onRegister != null) ...[
|
||||||
registerButton,
|
registrationButton,
|
||||||
],
|
],
|
||||||
if (options.spacers.spacerAfterButton != null) ...[
|
if (options.spacers.spacerAfterButton != null) ...[
|
||||||
Spacer(flex: options.spacers.spacerAfterButton!),
|
Spacer(flex: options.spacers.spacerAfterButton!),
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import 'dart:async';
|
import "dart:async";
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import "package:flutter/material.dart";
|
||||||
import 'package:flutter_login/flutter_login.dart';
|
import "package:flutter_login/flutter_login.dart";
|
||||||
|
import "package:flutter_login/src/widgets/custom_semantics.dart";
|
||||||
|
|
||||||
class ForgotPasswordForm extends StatefulWidget {
|
class ForgotPasswordForm extends StatefulWidget {
|
||||||
/// Constructs a [ForgotPasswordForm] widget.
|
/// Constructs a [ForgotPasswordForm] widget.
|
||||||
|
@ -49,7 +50,7 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm> {
|
||||||
|
|
||||||
final ValueNotifier<bool> _formValid = ValueNotifier(false);
|
final ValueNotifier<bool> _formValid = ValueNotifier(false);
|
||||||
|
|
||||||
String _currentEmail = '';
|
String _currentEmail = "";
|
||||||
|
|
||||||
void _updateCurrentEmail(String email) {
|
void _updateCurrentEmail(String email) {
|
||||||
_currentEmail = email;
|
_currentEmail = email;
|
||||||
|
@ -110,7 +111,9 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm> {
|
||||||
alignment: Alignment.topCenter,
|
alignment: Alignment.topCenter,
|
||||||
child: wrapWithDefaultStyle(
|
child: wrapWithDefaultStyle(
|
||||||
widget.description,
|
widget.description,
|
||||||
theme.textTheme.bodyMedium,
|
theme.textTheme.bodyMedium?.copyWith(
|
||||||
|
height: 1.4,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (options
|
if (options
|
||||||
|
@ -133,7 +136,10 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm> {
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: options.emailInputContainerBuilder(
|
child: options.emailInputContainerBuilder(
|
||||||
TextFormField(
|
CustomSemantics(
|
||||||
|
identifier: options.accessibilityIdentifiers
|
||||||
|
.emailTextFieldIdentifier,
|
||||||
|
child: TextFormField(
|
||||||
autofillHints: const [AutofillHints.email],
|
autofillHints: const [AutofillHints.email],
|
||||||
textAlign:
|
textAlign:
|
||||||
options.emailTextAlign ?? TextAlign.start,
|
options.emailTextAlign ?? TextAlign.start,
|
||||||
|
@ -153,6 +159,7 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
if (options.forgotPasswordSpacerOptions.spacerBeforeButton !=
|
if (options.forgotPasswordSpacerOptions.spacerBeforeButton !=
|
||||||
null) ...[
|
null) ...[
|
||||||
Spacer(
|
Spacer(
|
||||||
|
@ -163,7 +170,11 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm> {
|
||||||
AnimatedBuilder(
|
AnimatedBuilder(
|
||||||
animation: _formValid,
|
animation: _formValid,
|
||||||
builder: (context, snapshot) => Align(
|
builder: (context, snapshot) => Align(
|
||||||
child: widget.options.requestForgotPasswordButtonBuilder(
|
child: CustomSemantics(
|
||||||
|
identifier: options.accessibilityIdentifiers
|
||||||
|
.requestForgotPasswordButtonIdentifier,
|
||||||
|
child:
|
||||||
|
widget.options.requestForgotPasswordButtonBuilder(
|
||||||
context,
|
context,
|
||||||
() async {
|
() async {
|
||||||
_formKey.currentState?.validate();
|
_formKey.currentState?.validate();
|
||||||
|
@ -179,6 +190,7 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
if (options.forgotPasswordSpacerOptions.spacerAfterButton !=
|
if (options.forgotPasswordSpacerOptions.spacerAfterButton !=
|
||||||
null) ...[
|
null) ...[
|
||||||
Spacer(
|
Spacer(
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import 'package:flutter/material.dart';
|
import "package:flutter/material.dart";
|
||||||
import 'package:pinput/pinput.dart';
|
import "package:pinput/pinput.dart";
|
||||||
|
|
||||||
class MFAWidget extends StatefulWidget {
|
class MFAWidget extends StatefulWidget {
|
||||||
/// Constructs an [MFAWidget].
|
/// Constructs an [MFAWidget].
|
||||||
|
@ -39,8 +39,8 @@ class MFAWidget extends StatefulWidget {
|
||||||
}) : assert(
|
}) : assert(
|
||||||
(onSubmitted == null && submitButtonBuilder == null) ||
|
(onSubmitted == null && submitButtonBuilder == null) ||
|
||||||
(onSubmitted != null && submitButtonBuilder != null),
|
(onSubmitted != null && submitButtonBuilder != null),
|
||||||
'onSubmitted and submitButtonBuilder must be both null or both'
|
"onSubmitted and submitButtonBuilder must be both null or both"
|
||||||
' not null',
|
" not null",
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Callback function triggered when the MFA code is completed.
|
/// Callback function triggered when the MFA code is completed.
|
||||||
|
@ -106,7 +106,11 @@ class _MFAWidgetState extends State<MFAWidget> {
|
||||||
followingPinTheme: widget.followingPinTheme,
|
followingPinTheme: widget.followingPinTheme,
|
||||||
disabledPinTheme: widget.disabledPinTheme,
|
disabledPinTheme: widget.disabledPinTheme,
|
||||||
errorPinTheme: widget.errorPinTheme,
|
errorPinTheme: widget.errorPinTheme,
|
||||||
separatorPositions: widget.seperatorPositions,
|
separatorBuilder: (index) {
|
||||||
|
var seperatorSize =
|
||||||
|
widget.seperatorPositions?[index].toDouble() ?? 8.0;
|
||||||
|
return SizedBox(width: seperatorSize);
|
||||||
|
},
|
||||||
errorBuilder: widget.errorBuilder,
|
errorBuilder: widget.errorBuilder,
|
||||||
errorText: widget.errorText,
|
errorText: widget.errorText,
|
||||||
errorTextStyle: widget.errorTextStyle,
|
errorTextStyle: widget.errorTextStyle,
|
||||||
|
|
14
pubspec.yaml
14
pubspec.yaml
|
@ -1,6 +1,6 @@
|
||||||
name: flutter_login
|
name: flutter_login
|
||||||
description: Flutter Login Component
|
description: Flutter Login Component
|
||||||
version: 7.1.1
|
version: 7.3.0
|
||||||
|
|
||||||
publish_to: https://forgejo.internal.iconica.nl/api/packages/internal/pub
|
publish_to: https://forgejo.internal.iconica.nl/api/packages/internal/pub
|
||||||
|
|
||||||
|
@ -11,14 +11,18 @@ environment:
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
pinput: ^2.2.31
|
local_auth: ^2.3.0
|
||||||
|
pinput: ^5.0.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_iconica_analysis:
|
flutter_iconica_analysis:
|
||||||
git:
|
hosted: https://forgejo.internal.iconica.nl/api/packages/internal/pub
|
||||||
url: https://github.com/Iconica-Development/flutter_iconica_analysis
|
version: ^7.0.0
|
||||||
ref: 6.0.0
|
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
|
assets:
|
||||||
|
- assets/
|
||||||
|
- assets/2.0x/
|
||||||
|
- assets/3.0x/
|
||||||
|
|
7
test/flutter_login_widget_test.dart
Normal file
7
test/flutter_login_widget_test.dart
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import "package:flutter_test/flutter_test.dart";
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
test("blank test", () {
|
||||||
|
expect(true, true);
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in a new issue