To dismiss the AlertDialog when the FlatButton is clicked, you can use the Navigator.pop method in the _dismissDialog function. Here's an updated version of your code:
showDialog(
  context: context,
  child: AlertDialog(
    title: const Text("Location disabled"),
    content: const Text(
      "Location is disabled on this device. Please enable it and try again.",
    ),
    actions: [
      FlatButton(
        child: const Text("Ok"),
        onPressed: _dismissDialog,
      ),
    ],
  ),
);
void _dismissDialog() {
  Navigator.pop(context); // This will dismiss the dialog
}
In this code, the _dismissDialog function calls Navigator.pop(context), which will pop the top-most route off the navigator's stack. In this case, the top-most route is the AlertDialog, so calling Navigator.pop will dismiss it.
I hope this helps!