This is a Flutter application that implements a comment section with nested replies. It allows users to add comments, reply to existing comments, edit, and delete comments. The application ensures that nested replies are scrollable and the latest comments are displayed by default with an option to view previous comments.
- Add new comments
- Reply to existing comments
- Edit and delete comments
- Display latest 4 comments by default
Before you begin, ensure you have met the following requirements:
- You have installed the latest version of Flutter SDK
- You have a connected device (physical or emulator) to run the app
- You have a code editor such as Visual Studio Code or Android Studio
Follow these steps to set up and run the project:
-
Clone the repository:
git clone [email protected]:Akash4097/creative_dalaal_demo.git cd creative_dalaal_demo
-
Install dependencies:
Navigate to the project directory and install the dependencies:
flutter pub get
- Run the app:
Ensure you have a connected device or emulator running, then use the following command to run the app:
flutter run
-
lib/
-
data_models/
comment.dart:
data-model class for comment.user.dart:
data-model class for user.
-
notifier/
comment_service_notifier.dart:
Manages the state and logic for comments, including adding, editing, and deleting comments.
-
ui/
screens/
comment_section_screen.dart:
The main screen that displays the comment section.
widgets/
comment_widget.dart:
The CommentWidget class for displaying individual comments and their nested replies.
-
utils/
date_format_extension.dart:
Extension method for formatting dates.responsive.dart:
class to make the widget resposive to width upto 720.unique_id.dart:
class contain method that generate unique ids.
-
- Type your comment in the text field at the top.
- Press the send button to add the comment.
- Press the "Reply" button below the comment you want to reply to.
- Type your reply in the text field that appears.
- Press the send button to add the reply.
- Press the menu icon (three dots) on the comment you want to edit.
- Select "Edit" from the dropdown menu.
- Edit your comment in the text field that appears and press the check icon to save.
- Press the menu icon (three dots) on the comment you want to delete.
- Select "Delete" from the dropdown menu.
- If there are more than four comments, a "Show Previous Comments" button will appear.
- Press the button to view all comments.
- Press "Hide Previous Comments" to collapse the view back to the latest four comments.
The user-name which are shown in the comments are selected randomly from the hard-coded list of user which can be found in user.dart
file