mirror of
https://github.com/Iconica-Development/flutter_timeline.git
synced 2025-05-19 18:43:45 +02:00
fix: add proper placeholder images to the local repository and a fallback image
This commit is contained in:
parent
c1b74e97f3
commit
6273a9e686
5 changed files with 33 additions and 10 deletions
BIN
packages/flutter_timeline/assets/error_image.png
Normal file
BIN
packages/flutter_timeline/assets/error_image.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
|
@ -35,6 +35,7 @@ class TimelineOptions {
|
||||||
this.onTapCategory,
|
this.onTapCategory,
|
||||||
this.onTapOverview,
|
this.onTapOverview,
|
||||||
this.onTapCreatePostInOverview,
|
this.onTapCreatePostInOverview,
|
||||||
|
this.placeholderImageAssetUrl,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Builders
|
// Builders
|
||||||
|
@ -71,6 +72,7 @@ class TimelineOptions {
|
||||||
final ImagePickerTheme? imagePickerTheme;
|
final ImagePickerTheme? imagePickerTheme;
|
||||||
final Widget? timelineScreenDrawer;
|
final Widget? timelineScreenDrawer;
|
||||||
final AppBarBuilder? timelineScreenAppBarBuilder;
|
final AppBarBuilder? timelineScreenAppBarBuilder;
|
||||||
|
final String? placeholderImageAssetUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _defaultFloatingActionButton(
|
Widget _defaultFloatingActionButton(
|
||||||
|
|
|
@ -29,6 +29,8 @@ class TimelinePostWidget extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TimelinePostWidgetState extends State<TimelinePostWidget> {
|
class _TimelinePostWidgetState extends State<TimelinePostWidget> {
|
||||||
|
bool imageError = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var theme = Theme.of(context);
|
var theme = Theme.of(context);
|
||||||
|
@ -110,8 +112,27 @@ class _TimelinePostWidgetState extends State<TimelinePostWidget> {
|
||||||
height: 250,
|
height: 250,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
image: DecorationImage(
|
image: imageError
|
||||||
image: CachedNetworkImageProvider(widget.post.imageUrl!),
|
? DecorationImage(
|
||||||
|
image: options.placeholderImageAssetUrl != null
|
||||||
|
? AssetImage(
|
||||||
|
options.placeholderImageAssetUrl!,
|
||||||
|
)
|
||||||
|
: const AssetImage(
|
||||||
|
"assets/error_image.png",
|
||||||
|
package: "flutter_timeline",
|
||||||
|
),
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
)
|
||||||
|
: DecorationImage(
|
||||||
|
onError: (exception, stackTrace) {
|
||||||
|
setState(() {
|
||||||
|
imageError = true;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
image: CachedNetworkImageProvider(
|
||||||
|
widget.post.imageUrl!,
|
||||||
|
),
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -19,7 +19,7 @@ class LocalPostRepository implements PostRepositoryInterface {
|
||||||
userId: "1",
|
userId: "1",
|
||||||
firstName: "Jane",
|
firstName: "Jane",
|
||||||
lastName: "Doe",
|
lastName: "Doe",
|
||||||
imageUrl: "https://via.placeholder.com/150",
|
imageUrl: "https://placehold.co/150.png?text=Jane",
|
||||||
);
|
);
|
||||||
|
|
||||||
final List<TimelinePost> _posts = List.generate(
|
final List<TimelinePost> _posts = List.generate(
|
||||||
|
@ -47,7 +47,7 @@ class LocalPostRepository implements PostRepositoryInterface {
|
||||||
userId: "2",
|
userId: "2",
|
||||||
firstName: "John",
|
firstName: "John",
|
||||||
lastName: "Doe",
|
lastName: "Doe",
|
||||||
imageUrl: "https://via.placeholder.com/150",
|
imageUrl: "https://placehold.co/150.png?text=John",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -56,9 +56,9 @@ class LocalPostRepository implements PostRepositoryInterface {
|
||||||
userId: "1",
|
userId: "1",
|
||||||
firstName: "Jane",
|
firstName: "Jane",
|
||||||
lastName: "Doe",
|
lastName: "Doe",
|
||||||
imageUrl: "https://via.placeholder.com/150",
|
imageUrl: "https://placehold.co/150.png?text=Jane",
|
||||||
),
|
),
|
||||||
imageUrl: "https://via.placeholder.com/1000",
|
imageUrl: "https://placehold.co/1000.png?text=$index",
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,13 @@ class LocalTimelineUserRepository implements TimelineUserRepositoryInterface {
|
||||||
userId: "1",
|
userId: "1",
|
||||||
firstName: "john",
|
firstName: "john",
|
||||||
lastName: "doe",
|
lastName: "doe",
|
||||||
imageUrl: "https://via.placeholder.com/150",
|
imageUrl: "https://placehold.co/150.png?text=John",
|
||||||
),
|
),
|
||||||
const TimelineUser(
|
const TimelineUser(
|
||||||
userId: "2",
|
userId: "2",
|
||||||
firstName: "jane",
|
firstName: "jane",
|
||||||
lastName: "doe",
|
lastName: "doe",
|
||||||
imageUrl: "https://via.placeholder.com/150",
|
imageUrl: "https://placehold.co/150.png?text=Jane",
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue