Code Monkey home page Code Monkey logo

myeasydialogs's Introduction

MyEasyDialogs

This package will make your life easier. It allows you to create dialogues that adapt visually to the OS used and allows you to display simple pop-up messages or with actions.

Getting Started

To use this package, add my_easy_dialogs as a dependency in your pubspec.yaml file.

There is three types of dialogs for now. The first one is infoDialog. It will display a simple dialog with a title, a message adn a button to dismiss the dialog. The second one is dialogWithOptions. It will display a dialog with two buttons and you can add your custom function for each buttons. The third one is loadingDialog. It will display a dialog with a title if you want and a loading indicator. A new dialog type is available : the textInputDialog, it will show a dialog with a textfield included to write something.

Parameters

There is multiple parameters in order to custom your dialogs the way you want to.

The required parameters are the title, the message to display and the Buildcontext. But you can customize other parameters, like the button text that by default is 'OK' for the infoDialog and are 'OK' and 'Cancel' for the dialogWithOptions. You can customize the title font size and the buttons font size for the android version of the dialog. You can even set the right button as a destructive button on the dialogWithOptions so that the text will be colored in red. (It's set to true by default.)

Example

import 'package:flutter/material.dart';
import 'package:my_easy_dialogs/dialogs/my_easy_dialog.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: MyHomePage(title: 'MyEasyDialogs'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key, required this.title}) : super(key: key);
  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            TextButton(
              onPressed: () => MyEasyDialog.infoDialog(
                  context: context,
                  title: "Exemple",
                  message: "I'm an infoDialog exemple !"),
              child: Text("Show infoDialog"),
            ),
            TextButton(
              onPressed: () => MyEasyDialog.dialogWithOptions(
                  context: context,
                  title: "Exemple",
                  message: "I'm an infoDialog exemple !",
                  textLeftButton: "Yes",
                  onPressedLeftButton: () => print("yes")),
              child: Text("Show dialogWithOptions"),
            ),
          ],
        ),
      ),
    );
  }
}

myeasydialogs's People

Contributors

nefus8 avatar

Stargazers

 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.