A package facilitating the basic ingredients for creating functional yet customizable login pages
Find a file
2022-10-19 15:14:51 +02:00
example chore: add readme description and versioning 2022-10-03 08:24:56 +02:00
lib feat: hint text for fields 2022-10-19 15:14:51 +02:00
.gitignore refactor login to be a minimal component 2022-09-27 16:48:52 +02:00
.metadata refactor login to be a minimal component 2022-09-27 16:48:52 +02:00
analysis_options.yaml refactor login to be a minimal component 2022-09-27 16:48:52 +02:00
CHANGELOG.md refactor login to be a minimal component 2022-09-27 16:48:52 +02:00
LICENSE refactor login to be a minimal component 2022-09-27 16:48:52 +02:00
pubspec.yaml chore: add readme description and versioning 2022-10-03 08:24:56 +02:00
README.md chore: add readme description and versioning 2022-10-03 08:24:56 +02:00

A package facilitating the basic ingredients for creating functional yet customizable login pages

Features

Create a login screen for email and password logins Create a forgot password screen by passing in the email from the login

Getting started

  1. install the package by adding the following to your pubspec.yaml
     flutter_login:
       git:
         url: https://github.com/Iconica-Development/flutter_login.git
         ref: 1.0.0
    

Usage

final loginOptions = LoginOptions(
  decoration: const InputDecoration(
    border: OutlineInputBorder(),
  ),
  emailInputPrefix: const Icon(Icons.email),
  passwordInputPrefix: const Icon(Icons.password),
  title: const Text('Login'),
  image: const FlutterLogo(),
  requestForgotPasswordButtonBuilder: (context, onPressed, isDisabled) {
    return Opacity(
      opacity: isDisabled ? 0.5 : 1.0,
      child: ElevatedButton(
        onPressed: onPressed,
        child: const Text('Send request'),
      ),
    );
  },
);

class LoginExample extends StatelessWidget {
  const LoginExample({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.dark(),
      home: LoginScreen(),
    );
  }
}

class LoginScreen extends StatelessWidget {
  const LoginScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: EmailPasswordLoginForm(
        options: loginOptions,
        onLogin: (email, password) => print('$email:$password'),
        onRegister: (email, password) => print('Register!'),
        onForgotPassword: (email) {
          Navigator.of(context).push(
            MaterialPageRoute(
              builder: (context) {
                return const ForgotPasswordScreen();
              },
            ),
          );
        },
      ),
    );
  }
}

class ForgotPasswordScreen extends StatelessWidget {
  const ForgotPasswordScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: ForgotPasswordForm(
        options: loginOptions,
        title: Text('Forgot password'),
        description: Text('Hello world'),
        onRequestForgotPassword: (email) {
          print('Forgot password email sent to $email');
        },
      ),
    );
  }
}