import 'dart:convert';

import 'package:flutter/material.dart';

class PostFavicon extends StatelessWidget {
  final String faviconData;
  const PostFavicon(this.faviconData, {super.key});

  @override
  Widget build(BuildContext context) {
    try {
      return Image.memory(
        base64Decode(faviconData.split(',')[1]),
        width: 20,
        height: 20,
        errorBuilder: (context, error, stackTrace) {
          print("Failed to render favicon: $error");
          return Container();
        },
      );
    } catch (e) {
      print("Caught exception while trying to render favicon: $e");
      return Container();
    }
  }
}
