login_rtl 0.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 46

loginrtlview #

LoginRtlView is a ready-made login/signup widget with many animation effects to demonstrate the capabilities of Flutter

Installation #

Follow the install instructions here

Reference #

PropertyTypeDesciption
isLayoutRtlBooleanif you set this value to true the whole UI will turn into RTL mode with arabic language support
onSignupAuthCallbackCalled when the user hit the submit button when in sign up mode
onLoginAuthCallbackCalled when the user hit the submit button when in login mode
onRecoverPasswordRecoverCallbackCalled when the user hit the submit button when in recover password mode
titleStringThe large text above the login [Card], usually the app or company name. Leave the string empty or null if you want no title.
logoStringThe path to the asset image that will be passed to the Image.asset()
messagesLoginMessagesDescribes all of the labels, text hints, button texts and other auth descriptions
themeLoginThemeFlutterLogin's theme. If not specified, it will use the default theme as shown in the demo gifs and use the colorsheme in the closest Theme widget
emailValidatorFormFieldValidator<String>Email validating logic, Returns an error string to display if the input is invalid, or null otherwise
passwordValidatorFormFieldValidator<String>Same as emailValidator but for password
onSubmitAnimationCompletedFunctionCalled after the submit animation's completed. Put your route transition logic here
logoTagStringHero tag for logo image. If not specified, it will simply fade out when changing route
titleTagStringHero tag for title text. Need to specify LoginTheme.beforeHeroFontSize and LoginTheme.afterHeroFontSize if you want different font size before and after hero animation
showDebugButtonsboolDisplay the debug buttons to quickly forward/reverse login animations. In release mode, this will be overrided to false regardless of the value passed in

LoginMessages #

PropertyTypeDesciption
usernameHintStringHint text of the user name [TextField]
passwordHintStringHint text of the password [TextField]
confirmPasswordHintStringHint text of the confirm password [TextField]
forgotPasswordButtonStringForgot password button's label
loginButtonStringLogin button's label
signupButtonStringSignup button's label
recoverPasswordButtonStringRecover password button's label
recoverPasswordIntroStringIntro in password recovery form
recoverPasswordDescriptionStringDescription in password recovery form
goBackButtonStringGo back button's label. Go back button is used to go back to to login/signup form from the recover password form
confirmPasswordErrorStringThe error message to show when the confirm password not match with the original password
recoverPasswordSuccessStringThe success message to show after submitting recover password

LoginTheme #

PropertyTypeDesciption
primaryColorColorThe background color of major parts of the widget like the login screen and buttons
accentColorColorThe secondary color, used for title text color, loading icon, etc. Should be contrast with the [primaryColor]
errorColorColorThe color to use for [TextField] input validation errors
cardThemeCardThemeThe colors and styles used to render auth [Card]
inputThemeInputDecorationThemeDefines the appearance of all [TextField]s
buttonThemeLoginButtonThemeA theme for customizing the shape, elevation, and color of the submit button
titleStyleTextStyleText style for the big title
bodyStyleTextStyleText style for small text like the recover password description
textFieldStyleTextStyleText style for [TextField] input text
buttonStyleTextStyleText style for button text
beforeHeroFontSizedoubleDefines the font size of the title in the login screen (before the hero transition)
afterHeroFontSizedoubleDefines the font size of the title in the screen after the login screen (after the hero transition)
pageColorLightColorThe optional light background color of login screen; if provided, used for light gradient instead of primaryColor
pageColorDarkColorThe optional dark background color of login screen; if provided, used for dark gradient instead of primaryColor

[0.0.1] - TODO: Add release date. #

  • TODO: Describe initial release.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:login_rtl/login_rtl_view.dart';

import 'dashboard_screen.dart';

void main() {
  runApp(MyApp());
}

const users = const {
  'alaa@gmail.com': '12345',
  'test@gmail.com': 'test',
};

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        theme: ThemeData(
          primarySwatch: Colors.teal,
          accentColor: _colorFromHex("#FF989A"),
          cursorColor: _colorFromHex("#FF989A"),
          textTheme: TextTheme(
            display2: TextStyle(
              fontFamily: 'OpenSans',
              fontSize: 45.0,
              color: _colorFromHex("#FF989A"),
            ),
            button: TextStyle(
              fontFamily: 'OpenSans',
            ),
            subhead: TextStyle(fontFamily: 'NotoSans'),
            body1: TextStyle(fontFamily: 'NotoSans'),
          ),
        ),
        home: new Home());
  }
}

class Home extends StatelessWidget {
  Duration get loginTime => Duration(milliseconds: 2250);

  Future<String> _authUser(LoginData data) {
    print('Name: ${data.name}, Password: ${data.password}');
    return Future.delayed(loginTime).then((_) {
      if (!users.containsKey(data.name)) {
        return 'اسم المستخدم غير موجود';
      }
      if (users[data.name] != data.password) {
        return 'كلمة مرور غير صحيحة';
      }
      return null;
    });
  }

  Future<String> _recoverPassword(String name) {
    print('Name: $name');
    return Future.delayed(loginTime).then((_) {
      if (!users.containsKey(name)) {
        return 'اسم المستخدم غير موجود';
      }
      return null;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Center(
      child: LoginRtlView(
        isLayoutRtl: true,
        onLogin: _authUser,
        title: "",
        logo: "assets/images/social.png",
        onRecoverPassword: _recoverPassword,
        onSignup: _authUser,
        onSubmitAnimationCompleted: () {
          Navigator.of(context).pushReplacement(MaterialPageRoute(
            builder: (context) => new DashboardScreen(),
          ));
        },
      ),
    );
  }
}

Color _colorFromHex(String hexColor) {
  final hexCode = hexColor.replaceAll('#', '');
  return Color(int.parse('FF$hexCode', radix: 16));
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  login_rtl: ^0.0.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:login_rtl/helpers/color_helper.dart';
import 'package:login_rtl/helpers/constants.dart';
import 'package:login_rtl/helpers/dart_helper.dart';
import 'package:login_rtl/helpers/math_helper.dart';
import 'package:login_rtl/helpers/matrix.dart';
import 'package:login_rtl/helpers/paddings.dart';
import 'package:login_rtl/helpers/regex.dart';
import 'package:login_rtl/helpers/widget_helper.dart';
import 'package:login_rtl/login_rtl_view.dart';
import 'package:login_rtl/models/login_data.dart';
import 'package:login_rtl/providers/auth.dart';
import 'package:login_rtl/providers/login_messages.dart';
import 'package:login_rtl/providers/login_theme.dart';
import 'package:login_rtl/theme.dart';
import 'package:login_rtl/widgets.dart';
import 'package:login_rtl/widgets/animated_button.dart';
import 'package:login_rtl/widgets/animated_text.dart';
import 'package:login_rtl/widgets/animated_text_form_field.dart';
import 'package:login_rtl/widgets/auth_card.dart';
import 'package:login_rtl/widgets/custom_page_transformer.dart';
import 'package:login_rtl/widgets/expandable_container.dart';
import 'package:login_rtl/widgets/fade_in.dart';
import 'package:login_rtl/widgets/gradient_box.dart';
import 'package:login_rtl/widgets/hero_text.dart';
import 'package:login_rtl/widgets/null_widget.dart';
import 'package:login_rtl/widgets/ring.dart';
import 'package:login_rtl/widgets/shadow_button.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
10
Health:
Code health derived from static analysis. [more]
91
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
46
Learn more about scoring.

We analyzed this package on Jul 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

because of import path [login_rtl] that is in a package requiring null.

Health suggestions

Fix lib/login_rtl_view.dart. (-6.31 points)

Analysis of lib/login_rtl_view.dart reported 13 hints, including:

line 127 col 32: 'display2' is deprecated and shouldn't be used. This is the term used in the 2014 version of material design. The modern term is headline3. This feature was deprecated after v1.13.8..

line 187 col 32: 'display2' is deprecated and shouldn't be used. This is the term used in the 2014 version of material design. The modern term is headline3. This feature was deprecated after v1.13.8..

line 194 col 32: 'display2' is deprecated and shouldn't be used. This is the term used in the 2014 version of material design. The modern term is headline3. This feature was deprecated after v1.13.8..

line 225 col 7: This class (or a class that this class inherits from) is marked as '@immutable', but one or more of its instance fields aren't final: LoginRtlView.isLayoutRtl

line 456 col 48: 'display2' is deprecated and shouldn't be used. This is the term used in the 2014 version of material design. The modern term is headline3. This feature was deprecated after v1.13.8..

Fix lib/widgets/auth_card.dart. (-2.96 points)

Analysis of lib/widgets/auth_card.dart reported 6 hints, including:

line 41 col 7: This class (or a class that this class inherits from) is marked as '@immutable', but one or more of its instance fields aren't final: AuthCard.rtlSupport

line 352 col 7: This class (or a class that this class inherits from) is marked as '@immutable', but one or more of its instance fields aren't final: _LoginCard.rtlSupport

line 609 col 34: 'body1' is deprecated and shouldn't be used. This is the term used in the 2014 version of material design. The modern term is bodyText2. This feature was deprecated after v1.13.8..

line 782 col 11: The value of the local variable 'messages' isn't used.

line 873 col 44: 'body1' is deprecated and shouldn't be used. This is the term used in the 2014 version of material design. The modern term is bodyText2. This feature was deprecated after v1.13.8..

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
cupertino_icons ^0.1.2 0.1.3
flutter 0.0.0
font_awesome_flutter ^8.8.1 8.8.1
provider ^4.1.2 4.2.0
quiver ^2.1.3 2.1.3
transformer_page_view ^0.1.6 0.1.6
Transitive dependencies
collection 1.14.12 1.14.13
matcher 0.12.8
meta 1.1.8 1.2.1
nested 0.0.4
path 1.7.0
sky_engine 0.0.99
stack_trace 1.9.5
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test