Home > Software design >  Alert is not Showing when i tried to call it in listview with condition
Alert is not Showing when i tried to call it in listview with condition

Time:01-04

Hi everyone am trying to show an alert popup in the listview in the flutter app with condition check but my pop is not showing below is my code please help

ListView _buildListViewOfDevices() {
    List<Container> containers = <Container>[];
    for (BluetoothDevice device in widget.devicesList) {
      if (device.name == 'Airbud Pro Plus') {
        Alert(
          context: context,
          title: 'Greetings',
          desc: 'you are using Apple Airbud Pro Plus',
        ).show();
      }

CodePudding user response:

below is how you show an alert dialog:

ListView _buildListViewOfDevices(context) { //pass context as parameter
      List<Container> containers = <Container>[];
      for (BluetoothDevice device in widget.devicesList) {
        if (device.name == 'Airbud Pro Plus') {
          showDialog(
              context: context,
              builder: (context) => AlertDialog(
                    title: Text('greetings!!'),
                    content: Text("you are using Apple Airbud Pro Plus"),
                  ));
        }
      }
    }

CodePudding user response:

In case you are using rflutter_alert package:

function call example:

RaisedButton(
              child: Text('Basic Alert'),
              onPressed: () => _onBasicAlertPressed(context),
            ),

function body example:

_onBasicAlertPressed(context) {
    Alert(
            context: context,
            title: "RFLUTTER ALERT",
            desc: "Flutter is more awesome with RFlutter Alert.")
        .show();
  }

Reference link: https://github.com/RatelHub/rflutter_alert/tree/master/example

  •  Tags:  
  • Related