Git Product home page Git Product logo

dlwidgets's Introduction

DlWidgets

DlWidgets is a Flutter library that aims to simplify the development process by providing a collection of useful and customizable widgets.

Features

  • Design Widgets: Reduced time in developing password text field and normal text field. All the Widgets are pre-built developed.

Installation

To use DlWidgets in your Flutter project, you need to add it as a dependency in your pubspec.yaml file:

dependencies:
  dl_widgets: ^1.0.0

Then, run the following command to fetch the package:

flutter pub get

Usage

Import the DlWidgets package into your Dart file:

import 'package:dl_widgets/dl_widgets.dart';

Now, you can start using the DlWidgets library. Here's an example of how to use one of the widgets:

Login page Demo

import 'package:dlwidgets/dlwidgets.dart';
import 'package:flutter/material.dart';

class LoginPage extends StatefulWidget {
  const  LoginPage({Key? key}) : super(key: key);

  @override
  State<LoginPage> createState() => _State();
}

class _State extends State<LoginPage> {

  String? token;
  String? emailError;
  String? passwordError;
  String? tickerMessage;
  TickerType? tickerType;

  @override
  void dispose() {
    // TODO: implement dispose
    textEditingController.dispose();
    passwordController.dispose();
    super.dispose();
  }

  Future login(String email, String password, BuildContext context) async {
    token = "Make an API CALL for getting";
    setState(() {
      if(token!=null) {
        ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
            content: Text("Authenticated")
        ));
        tickerMessage = "Authenticated";
        tickerType = TickerType.success;
      }
      else{
        showDialog(context: context, builder: (context) => DlAlertDialog(dlAlertDialogImpl: alertDialog, showDialogFlag: showDialogF));
        ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
            content: Text("Invalid user")
        ));
        tickerMessage = "Invalid user";
        tickerType = TickerType.error;
      }
    });
  }

  TextEditingController textEditingController = TextEditingController();
  TextEditingController passwordController = TextEditingController();
  late DlTextFormFieldImpl emailField;
  late DlAlertDialogImpl alertDialog;
  late DlTextFormFieldImpl passWordField;
  @override
  void initState() {

    alertDialog = DlAlertDialogImpl(title: Text("Invalid User"), content: Text("Not allowed"), positiveAction: ElevatedButton(onPressed:(){}, child: Text("Yes")), negativeAction: ElevatedButton(onPressed:(){}, child: Text("No")), backgroundColor: Colors.white, shape: DialogShape.curved);

    emailField = DlTextFormFieldImpl(TextEditingController(), (value) {
      setState(() {
        emailField.errorText = null;
        passWordField.errorText = null;
      });
    }, emailError, "Email");
    passWordField = DlTextFormFieldImpl(TextEditingController(), (value) {
      setState(() {
        emailField.errorText = null;
        passWordField.errorText = null;
      });
    }, passwordError, "Password");
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
        children: [
          Padding(padding: EdgeInsets.symmetric(vertical: MediaQuery.of(context).size.height/5), child:
          SingleChildScrollView(
              physics: const BouncingScrollPhysics(),
              child: Center(child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Padding(padding: EdgeInsets.symmetric(horizontal: MediaQuery.of(context).size.width/3), child: DlCardView(
                    child:  Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: [
                        DlTextFormField(isCenter: false, activeColor: Colors.blue, isPassword: false, input: emailField),
                        DlTextFormField(isCenter: false, activeColor: Colors.blue, isPassword: true, input: passWordField),
                        tickerType != null ? DlTicker(textInfo: tickerMessage??"", tickerType: tickerType) : Container()
                      ],
                    ),
                  )),
                  DlButton(buttonName: "Login", size: ButtonSize.small, onPressed: (){
                    setState(() {
                      if(emailField.textFieldController.text.isEmpty){
                        emailField.errorText = "Email must not be empty";
                      }
                      if(passWordField.textFieldController.text.isEmpty){
                        passWordField.errorText = "Password must not be empty";
                      }
                    });
                    login(emailField.textFieldController.text, passWordField.textFieldController.text, context);
                  }, buttonColor:  Colors.blue),
                  Center(
                      child: Padding(padding: const EdgeInsets.all(24), child: GestureDetector(onTap: (){
                        Navigator.push(context, MaterialPageRoute(builder: (context) => const SignUpPage()));
                      },child: const Text("Sign up", maxLines: 1, style: TextStyle(color: Colors.blue)),),
                      ))
                ],
              )))),
        ],
      ),);
  }
}

For more detailed information on how to use each widget, refer to the API documentation.

Contributing

Contributions to DlWidgets are welcome! If you find a bug or have a feature suggestion, please open an issue on the GitHub repository.

License

This library is available under the MIT License.

dlwidgets's People

Contributors

hari-nikesh-r avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.