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

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 :: flutter status bar color 
Dart :: dart init Map 
Dart :: how to get terminal http request time 
Dart :: add a clickable link in flutter 
Dart :: flutter appbar leading icon 
Dart :: what is final and const verabile in flutter 
Dart :: flutter images 
Dart :: dart filter list 
Dart :: dart private method 
Dart :: how to add cards in flutter 
Dart :: or operator in dart 
Dart :: card radius flutter 
Dart :: Flutter(Dart) Find String Length 
Dart :: open url in flutter 
Dart :: flutter clipoval 
Dart :: flutter snackbar action button text color 
Dart :: dart round 
Dart :: snackbar in flutter 
Dart :: flutter column in listview not working 
Dart :: increase height of bottom sheet flutter 
Dart :: FlutterError (Navigator operation requested with a context that does not include a Navigator. The context used to push or pop routes from the Navigator must be that of a widget that is a descendant of a Navigator widget.) 
Dart :: flutter showdialog barrierdismissible 
Dart :: alternate of string class in dart 
Dart :: onboarding screen flutter 
Dart :: flutter gray screen 
Dart :: dart get return value of future function 
Dart :: create a row with two child in flutter 
Dart :: flutter decreate saturation 
Dart :: flutter provider difference between Consumer<T and context.watch<T 
Dart :: flutter gesturedetector space also clickable 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =