1
0
mirror of https://github.com/flutter/samples.git synced 2026-06-25 15:49:43 +00:00
Files
samples/compass_app/app/lib/ui/activities/widgets/activity_entry.dart
Eric Windmill f755c81579 Fix image loading error (#2865)
*Replace this paragraph with a description of what this PR is changing
or adding, and why. Consider including before/after screenshots.*

*List which issues are fixed by this PR. For larger changes, raising an
issue first helps
reduce redundant work.*

## Pre-launch Checklist

- [ ] I read the [Flutter Style Guide] _recently_, and have followed its
advice.
- [ ] I signed the [CLA].
- [ ] I read the [Contributors Guide].
- [ ] I have added sample code updates to the [changelog].
- [ ] I updated/added relevant documentation (doc comments with `///`).


If you need help, consider asking for advice on the #hackers-devrel
channel on [Discord].

<!-- Links -->
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md
[CLA]: https://cla.developers.google.com/
[Discord]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Chat.md
[Contributors Guide]:
https://github.com/flutter/samples/blob/main/CONTRIBUTING.md
[changelog]: ../CHANGELOG.md

---------

Co-authored-by: NiazSagor <niazsagor@gmail.com>
Co-authored-by: Niaz Sagor <50655067+NiazSagor@users.noreply.github.com>
2026-06-19 14:14:31 -07:00

90 lines
2.5 KiB
Dart

// Copyright 2024 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import '../../../domain/models/activity/activity.dart';
import '../../../utils/image_error_listener.dart';
import '../../core/ui/custom_checkbox.dart';
class ActivityEntry extends StatelessWidget {
const ActivityEntry({
super.key,
required this.activity,
required this.selected,
required this.onChanged,
});
final Activity activity;
final bool selected;
final ValueChanged<bool?> onChanged;
@override
Widget build(BuildContext context) {
return SizedBox(
height: 80,
child: Row(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(8),
child: CachedNetworkImage(
errorWidget: (context, url, error) => _ActivityErrorPlaceholder(),
imageUrl: activity.imageUrl,
height: 80,
width: 80,
errorListener: imageErrorListener,
),
),
const SizedBox(width: 20),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
activity.timeOfDay.name.toUpperCase(),
style: Theme.of(context).textTheme.labelSmall,
),
Text(
activity.name,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.bodyMedium,
),
],
),
),
const SizedBox(width: 20),
CustomCheckbox(
key: ValueKey('${activity.ref}-checkbox'),
value: selected,
onChanged: onChanged,
),
],
),
);
}
}
class _ActivityErrorPlaceholder extends StatelessWidget {
const _ActivityErrorPlaceholder();
@override
Widget build(BuildContext context) {
return Container(
width: 80,
height: 80,
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: BorderRadius.circular(8),
),
child: Icon(
Icons.broken_image_outlined,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
);
}
}