showAppChooserDialog static method

Future<AppInfo?> showAppChooserDialog(
  1. BuildContext context, {
  2. required List<AppInfo> apps,
  3. String? title,
  4. String? message,
})

Shows a multi-choice dialog for iOS to let the user select an app.

Returns the selected AppInfo or null if the user cancels.

Implementation

static Future<AppInfo?> showAppChooserDialog(
  BuildContext context, {
  required List<AppInfo> apps,
  String? title,
  String? message,
}) async {
  return await showDialog<AppInfo>(
    context: context,
    builder: (BuildContext context) {
      return AlertDialog(
        title: Text(title ?? 'Choose an app'),
        content: SingleChildScrollView(
          child: ListBody(
            children: apps.map((app) {
              return GestureDetector(
                onTap: () {
                  Navigator.of(context).pop(app);
                },
                child: Padding(
                  padding: const EdgeInsets.symmetric(vertical: 8.0),
                  child: Text(app.name),
                ),
              );
            }).toList(),
          ),
        ),
      );
    },
  );
}