show method

Future show(
  1. BuildContext context, {
  2. LogLvl? lvl,
})

Implementation

Future<dynamic> show(BuildContext context, {LogLvl? lvl}) {
  var logs = lvl != null ? getLvl(lvl) : getAll();
  return showDialog(
      context: context,
      builder: (context) => AlertDialog(
            title: const Text("Logs"),
            titleTextStyle: const TextStyle(
                fontSize: 14,
                color: Colors.black,
                fontWeight: FontWeight.bold),
            insetPadding: const EdgeInsets.all(0),
            contentPadding: const EdgeInsets.all(0),
            scrollable: true,
            content: SingleChildScrollView(
              child: Column(
                children: List.generate(
                    logs.length,
                    (index) => ListTile(
                          title: Text(logs[index].date.toString()),
                          titleTextStyle: const TextStyle(
                              fontSize: 10, color: Colors.black),
                          subtitle: Text(logs[index].msg),
                          leading: Text(
                            logs[index].type.name,
                            style: const TextStyle(
                                color: Colors.black, fontSize: 10),
                          ),
                          minLeadingWidth: 5,
                          minVerticalPadding: 0,
                          trailing: logs[index].stackTrace == null
                              ? null
                              : const Icon(Icons.chevron_right),
                          onTap: logs[index].stackTrace == null
                              ? null
                              : () => showDialog(
                                  context: context,
                                  builder: (context) => SimpleDialog(
                                        children: [
                                          Text(logs[index]
                                              .stackTrace!
                                              .toString())
                                        ],
                                      )),
                        )),
              ),
            ),
            actions: [
              TextButton(
                  onPressed: () => Navigator.pop(context),
                  child: const Text("close"))
            ],
          ));
}