NewsCardView
🧩 Syntax:
import 'package:attend/src/ui/shared/dimens.dart';
import 'package:attend/src/ui/shared/styles.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../../helpers/scalable_dp_helper.dart';
import '../../shared/colors.dart';
class NewsCardView extends StatelessWidget {
const NewsCardView(this.imageUrl, this.newsUrl, this.cardWidth, {Key? key}) : super(key: key);
final double cardWidth;
final String imageUrl, newsUrl;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () async {
if (!await launchUrl(
Uri.parse(newsUrl),
mode: LaunchMode.externalApplication,
)) {
throw 'Could not launch $newsUrl';
}
},
child: Container(
width: cardWidth,
decoration: BoxDecoration(
image: DecorationImage(image: NetworkImage(imageUrl), fit: BoxFit.cover),
borderRadius: BorderRadius.circular(SDP.sdp(radius)),
boxShadow: [
BoxShadow(
color: BaseColors.black.withOpacity(0.1),
offset: const Offset(0, 4),
blurRadius: 8,
),
],
),
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: SDP.sdp(20.0),
vertical: SDP.sdp(20.0),
),
child: Column(
children: [
const Spacer(),
Text(
'Buku Baru di Perpustakaan',
maxLines: 2,
style: whiteBoldTextStyle.copyWith(
fontSize: SDP.sdp(bodySmall),
),
),
],
),
),
),
);
}
}