Search
 
SCRIPT & CODE EXAMPLE
 

DART

flutter alertdialog

AlertDialog(
          title: const Text('AlertDialog Title'),
          content: const Text('this is a demo alert diolog'),
          actions: <Widget>[
            TextButton(
              child: const Text('Approve'),
              onPressed: () { 
              	Navigator.of(context).pop();
              },
            ),
          ],
        );
Comment

flutter custom alert dialog

//custom_alert_dialog.dart

import 'package:flutter/material.dart';

class CustomAlertDialog extends StatefulWidget {
  const CustomAlertDialog({
    Key? key,
    required this.title,
    required this.description,
  }) : super(key: key);

  final String title, description;

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

class _CustomAlertDialogState extends State<CustomAlertDialog> {
  @override
  Widget build(BuildContext context) {
    return Dialog(
      elevation: 0,
      backgroundColor: Color(0xffffffff),
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(15.0),
      ),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          SizedBox(height: 15),
          Text(
            "${widget.title}",
            style: TextStyle(
              fontSize: 18.0,
              fontWeight: FontWeight.bold,
            ),
          ),
          SizedBox(height: 15),
          Text("${widget.description}"),
          SizedBox(height: 20),
          Divider(
            height: 1,
          ),
          Container(
            width: MediaQuery.of(context).size.width,
            height: 50,
            child: InkWell(
              highlightColor: Colors.grey[200],
              onTap: () {
                //do somethig
              },
              child: Center(
                child: Text(
                  "Continue",
                  style: TextStyle(
                    fontSize: 18.0,
                    color: Theme.of(context).primaryColor,
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ),
            ),
          ),
          Divider(
            height: 1,
          ),
          Container(
            width: MediaQuery.of(context).size.width,
            height: 50,
            child: InkWell(
              borderRadius: BorderRadius.only(
                bottomLeft: Radius.circular(15.0),
                bottomRight: Radius.circular(15.0),
              ),
              highlightColor: Colors.grey[200],
              onTap: () {
                Navigator.of(context).pop();
              },
              child: Center(
                child: Text(
                  "Cancel",
                  style: TextStyle(
                    fontSize: 16.0,
                    fontWeight: FontWeight.normal,
                  ),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
Comment

alertdialog flutter

showAlertDialog(BuildContext context) {

  // set up the button
  Widget okButton = FlatButton(
    child: Text("OK"),
    onPressed: () { },
  );

  // set up the AlertDialog
  AlertDialog alert = AlertDialog(
    title: Text("My title"),
    content: Text("This is my message."),
    actions: [
      okButton,
    ],
  );

  // show the dialog
  showDialog(
    context: context,
    builder: (BuildContext context) {
      return alert;
    },
  );
}
Comment

alertdialogFlutter

showDialog(
  context: context,
  builder: (BuildContext context) {
    return AlertDialog(
      title: new Text("Alert!!"),
      content: new Text("You are awesome!"),
      actions: <Widget>[
        new FlatButton(
          child: new Text("OK"),
          onPressed: () {
            Navigator.of(context).pop();
          },
        ),
      ],
    );
  },
);
Comment

alertdialog shape flutter

  shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.all(Radius.circular(32.0))),
Comment

flutter alert dialog shape

shape: CircleBorder(),
shape: RoundedRectangleBorder(),
shape: ContinuousRectangleBorder(),
shape: BeveledRectangleBorder(),
Comment

how to close alertdialog flutter

showDialog(
            context: context,
            child: new AlertDialog(
              title: const Text("Location disabled"),
              content: const Text(
                  """
Location is disabled on this device. Please enable it and try again.
                  """),
              actions: [
                new FlatButton(
                  child: const Text("Ok"),
                  onPressed: _dismissDialog,
                ),
              ],
            ),
        );
Comment

showcupertinoalertdialog code flutter

showCupertinoDialog(
                                  context: context,
                                  builder: (BuildContext context) =>
                                      CupertinoAlertDialog(
                                        content: Text(
                                            'Hiiii You are Welcome'),
                                        actions: <Widget>[
                                          CupertinoButton(
                                              child: Text('Okay'),
                                              onPressed: () {
                                                Navigator.pop(context);
                                              })
                                        ],
                                      ));
Comment

display alert dialog automatically in flutter when app opens

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

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

  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
          title: 'Trial',
          home: Scaffold(
              appBar: AppBar(title: Text('List scroll')), body: new MyHome()));
    }
  }

  class MyHome extends StatelessWidget { // Wrapper Widget
    @override
    Widget build(BuildContext context) {
      Future.delayed(Duration.zero, () => showAlert(context));
      return Container(
        child: Text("Hello world"),
      );
    }

    void showAlert(BuildContext context) {
      showDialog(
          context: context,
          builder: (context) => AlertDialog(
                content: Text("hi"),
              ));
    }
  }
Comment

PREVIOUS NEXT
Code Example
Dart :: StateError (Bad state: No element) 
Dart :: how to validate textformfield on text change flutter 
Dart :: how to get the last values of a string dart 
Dart :: flutter alertdialog padding 
Dart :: dart trim 
Dart :: sort list bool dart 
Dart :: hide keyboard in flutter 
Dart :: at this point the state of the widget element tree is no longer stable. flutter 
Dart :: how to convert timestamp to datetime in dart 
Dart :: dart hello world 
Dart :: flutter get number of days in month 
Dart :: fibonacci numbers in dart 
Dart :: android studio causing blue screen 
Dart :: mobx flutter 
Dart :: flutter remove dropdown shadow appbar 
Dart :: flutter if else 
Dart :: dart read csv files 
Dart :: radius only top or bottom flutter 
Dart :: flutter firebase personal user data 
Dart :: how to use flaticon as icon in flutter 
Dart :: Autocomplete Widget in Flutter 
Dart :: flutter flatbutton width 
Dart :: flutter conver string to inr 
Dart :: custom radio button flutter 
Dart :: flutter encode 
Dart :: flutter variables 
Dart :: with keyword in dart 
Dart :: Android Emulator Setup without Android Studio in Flutter 
Dart :: check if animation complete in flutter 
Dart :: create array in flutter 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =