This repository has been archived on 2024-06-08. You can view files and clone it, but cannot push or open issues or pull requests.
SolarAgent/lib/widgets/feed.dart
2024-03-23 23:05:04 +08:00

44 lines
1.2 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:solaragent/models/feed.dart';
class FeedItem extends StatelessWidget {
final Feed item;
const FeedItem({super.key, required this.item});
String getDescription(String desc) =>
desc.isEmpty ? "No description yet." : desc;
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Column(
children: [
Container(
color: Colors.grey[50],
child: ListTile(
title: Text(item.author.name),
leading: CircleAvatar(
backgroundImage: NetworkImage(item.author.avatar),
),
subtitle: Text(
getDescription(item.author.description),
overflow: TextOverflow.ellipsis,
maxLines: 1,
softWrap: false,
),
),
),
Markdown(
data: item.content,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
),
],
),
);
}
}