nameSelectAlertDialog method

void nameSelectAlertDialog(
  1. BuildContext context,
  2. dynamic onOkPressed(
    1. String
    )
)

Implementation

void nameSelectAlertDialog(
    BuildContext context, Function(String) onOkPressed) {
  TextEditingController textFieldController = TextEditingController();
  showDialog(
    context: context,
    builder: (BuildContext context) {
      return AlertDialog(
        title: const Text('ChangeName'),
        content: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            const Text('Change the audio file'),
            TextField(
              controller: textFieldController,
              decoration: const InputDecoration(hintText: 'Enter new name'),
            ),
          ],
        ),
        actions: <Widget>[
          TextButton(
            onPressed: () {
              Navigator.of(context).pop();
              onOkPressed(textFieldController.text);
            },
            child: const Text('OK'),
          ),
        ],
      );
    },
  );
}