buildDocument method

Widget buildDocument()

Implementation

Widget buildDocument() {
  String documentUrl =
      widget.message['notification_content']['attachments']['attachment'];
  final isDarkMode = Theme.of(context).brightness == Brightness.dark;

  String fileExtension = path.extension(path.basename(documentUrl));

  String fileType = fileExtension.isNotEmpty
      ? fileExtension.substring(1).toUpperCase()
      : '';

  return SizedBox(
    height: 55,
    width: 55,
    child: InkWell(
      onTap: () {
        _launchUrl(Uri.parse(documentUrl));
      },
      child: ClipRRect(
        borderRadius: BorderRadius.circular(6.0),
        child: Container(
          padding: EdgeInsets.symmetric(horizontal: 15, vertical: 10),
          color: isDarkMode
              ? widget.themeConfig?.darkBackground?.withOpacity(0.6) ??
                  Colors.white.withOpacity(0.2)
              : widget.themeConfig?.lightBackground?.withOpacity(0.6) ??
                  Colors.black.withOpacity(0.2),
          child: Column(
            children: [
              Icon(
                Icons.file_copy,
                color: isDarkMode
                    ? widget.themeConfig?.darkText ?? Colors.white
                    : widget.themeConfig?.lightText ?? Colors.black,
                size: 20,
              ),
              Text(
                fileType,
                style: TextStyle(
                  color: isDarkMode
                      ? widget.themeConfig?.darkText ?? Colors.white
                      : widget.themeConfig?.lightText ?? Colors.black,
                  fontSize: 10,
                ),
              ),
            ],
          ),
        ),
      ),
    ),
  );
}