2023-10-09 07:48:03 +02:00
# Flutter Timeline
2024-04-23 13:39:49 +02:00
Flutter Timeline is a package which shows a list posts by a user. This package also has additional features like liking a post and leaving comments. Default this package adds support for a Firebase back-end.
2023-10-09 07:48:03 +02:00

## Setup
To use this package, add flutter_timeline as a dependency in your pubspec.yaml file:
```
2024-04-23 13:39:49 +02:00
flutter_timeline:
2023-10-09 07:48:03 +02:00
git:
2024-04-23 13:39:49 +02:00
url: https://github.com/Iconica-Development/flutter_timeline.git
path: packages/flutter_timeline
2023-10-09 07:48:03 +02:00
```
If you are going to use Firebase as the back-end of the Timeline, you should also add the following package as a dependency to your pubspec.yaml file:
```
flutter_timeline_firebase:
git:
2024-04-23 13:39:49 +02:00
url: https://github.com/Iconica-Development/flutter_timeline.git
path: packages/flutter_timeline_firebase
2023-10-09 07:48:03 +02:00
```
2024-04-23 13:39:49 +02:00
In firebase add firestore and storage to your project.
In firestore add a collection named `timeline` and a collection named `users` .
In the `timeline` collection all posts will be stored. In the `users` collection all users will be stored.
In the `users` collection you should add your users data.
2024-01-29 11:52:23 +01:00
Add the following code in your `main` function, before the runApp().
2024-04-23 13:39:49 +02:00
And import this package: import 'package:intl/date_symbol_data_local.dart';
2024-01-29 11:52:23 +01:00
```
initializeDateFormatting();
```
2023-10-09 07:48:03 +02:00
## How to use
2024-08-01 09:32:09 +02:00
To use the userstory add the following code somewhere in your widget tree:
2024-01-25 14:33:14 +01:00
````
timeLineNavigatorUserStory(TimelineUserStoryConfiguration, context),
````
Or create your own routing using the Screens:
2024-01-16 16:21:11 +01:00
To add the `TimelineScreen` add the following code:
````
TimelineScreen(
userId: currentUserId,
service: timelineService,
options: timelineOptions,
),
````
`TimelineScreen` is supplied with a standard `TimelinePostScreen` which opens the detail page of the selected post. Needed parameter like `TimelineService` and `TimelineOptions` will be the same as the ones supplied to the `TimelineScreen` .
2024-01-29 15:30:26 +01:00
The standard `TimelinePostScreen` can be overridden by defining `onPostTap` as shown below.
2024-01-16 16:21:11 +01:00
```
TimelineScreen(
userId: currentUserId,
service: timelineService,
options: timelineOptions,
onPostTap: (tappedPost) {
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Scaffold(
body: TimelinePostScreen(
userId: currentUserId,
service: timelineService,
options: timelineOptions,
post: post,
onPostDelete: () {
service.deletePost(post);
},
),
),
),
);
},
),
```
A standard post creation is provided named: `TimelinePostCreationScreen` . Routing to this has to be done manually.
```
TimelinePostCreationScreen(
postCategory: selectedCategory,
userId: currentUserId,
service: timelineService,
options: timelineOptions,
onPostCreated: (post) {
Navigator.of(context).pop();
},
),
```
2024-03-25 14:29:56 +01:00
You can choose to show an overview of the post before actually posting it using the `enablePostOverviewScreen` config setting.
2024-01-16 16:21:11 +01:00
The `TimelineOptions` has its own parameters, as specified below:
| Parameter | Explanation |
|-----------|-------------|
2024-01-25 14:33:14 +01:00
| theme | Used to set icon colors and textstyles |
2024-01-16 16:21:11 +01:00
| translations | Ability to provide desired text and tanslations. |
2024-01-25 14:33:14 +01:00
| imagePickerConfig | Config for the image picker in the post creation screen. |
| imagePickerTheme | Theme for the image picker in the post creation screen. |
2024-01-16 16:21:11 +01:00
| timelinePostHeight | Sets the height for each post widget in the list of post. If null, the size depends on the size of the image. |
| allowAllDeletion | Determines of users are allowed to delete thier own posts. |
2024-03-25 14:29:56 +01:00
| afterPostCreationGoHome | Boolean to enable redirect to home after post creation. If false, it will redirect to created post screen. |
| enablePostOverviewScreen | Boolean to enable timeline post overview screen before submitting. |
2024-01-16 16:21:11 +01:00
| sortCommentsAscending | Determines if the comments are sorted from old to new or new to old. |
| sortPostsAscending | Determines if the posts are sorted from old to new or new to old. |
2024-01-25 14:33:14 +01:00
| doubleTapToLike | Enables the abilty to double tap the image to like the post. |
| iconsWithValues | Ability to provide desired text and tanslations. |
| likeAndDislikeIconsForDoubleTap | Ability to override the standard icon which appears on double tap. |
2024-03-25 14:29:56 +01:00
| homeOpenPageBuilder | Open page builder function for the home page. |
| postCreationOpenPageBuilder | Open page builder function for the post creation page. |
| postViewOpenPageBuilder | Open page builder function for the post view page. |
| postOverviewOpenPageBuilder | Open page builder function for the post overview page. |
2024-01-25 14:33:14 +01:00
| itemInfoBuilder | Ability to override the bottom of the postwidgets. (Everything under the like and comment icons) |
2024-01-16 16:21:11 +01:00
| dateFormat | Sets the used date format |
| timeFormat | Sets the used time format |
| buttonBuilder | The ability to provide a custom button for the post creation screen. |
| textInputBuilder | The ability to provide a custom text input widget for the post creation screen. |
2024-01-25 14:33:14 +01:00
| dividerBuilder | Ability to provide desired text and tanslations. |
2024-01-16 16:21:11 +01:00
| userAvatarBuilder | The ability to provide a custom avatar. |
| anonymousAvatarBuilder | The ability to provide a custom avatar for anonymous users. |
| nameBuilder | The ability to override the standard way of display the post creator name. |
| padding | Padding used for the whole page. |
| iconSize | Size of icons like the comment and like icons. Dafualts to 26. |
2024-01-25 14:33:14 +01:00
| postWidgetHeight | Ability to provide desired text and tanslations. |
2024-03-25 14:29:56 +01:00
| minTitleLength | Minimum length of the title. |
| maxTitleLength | Maximum length of the title. |
| minContentLength | Minimum length of the post content. |
| maxContentLength | Maximum length of the post content. |
2024-01-25 14:33:14 +01:00
| postPadding | Padding for each post. |
| filterOptions | Options for using the filter to filter posts. |
| categoriesOptions | Options for using the category selector to provide posts of a certain category. |
2024-01-16 16:21:11 +01:00
2024-04-23 13:39:49 +02:00
The `ImagePickerTheme` and `imagePickerConfig` also have their own parameters, how to use these parameters can be found in [the documentation of the flutter_image_picker package ](https://github.com/Iconica-Development/flutter_image_picker ).
2023-10-09 07:48:03 +02:00
## Issues
Please file any issues, bugs or feature request as an issue on our [GitHub ](https://github.com/Iconica-Development/flutter_timeline/pulls ) page. Commercial support is available if you need help with integration with your app or services. You can contact us at [support@iconica.nl ](mailto:support@iconica.nl ).
## Want to contribute
If you would like to contribute to the plugin (e.g. by improving the documentation, solving a bug or adding a cool new feature), please carefully review our [contribution guide ](../CONTRIBUTING.md ) and send us your [pull request ](https://github.com/Iconica-Development/flutter_timeline/pulls ).
## Author
This `flutter_timeline` for Flutter is developed by [Iconica ](https://iconica.nl ). You can contact us at < support @ iconica . nl >