搜尋套件、儲存庫與 APP 分類

comment_box 封面
套件詳情v0.0.18

comment_box

一個簡單的 Flutter 評論框,用於貼文和產品。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
461
喜歡數
45
Pub 分數
130

安裝套件

flutter pub add comment_box

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個輕量級的 Flutter 套件,提供簡單且可自訂的評論方塊,用於將使用者評論整合至貼文與產品頁面。設計注重易用性,支援 Android、iOS、Web、macOS、Windows 與 Linux 多個平台。此套件讓開發者能快速加入評論功能,無需複雜設定。非常適合社交媒體應用、電商平台或內容驅動的網站,其中使用者互動至關重要。

適用情境

  • 向部落格文章新增評論
  • 啟用使用者對產品的反饋
  • 在應用程式中整合社交互動
  • 支援社群討論
  • 構建互動式內容提要
  • 促進網頁和行動應用上的使用者參與

主要特色

  • 跨平台相容性
  • 簡單整合,設定最少
  • 可自定義的 UI 組件
  • 支援文字輸入與提交
  • 輕量且快速的性能
  • 適用於所有裝置的響應式設計

適合對象

  • 開發社交功能的開發者
  • 電子商務應用程式創作者
  • 內容管理系統整合商
  • 移動和網頁應用團隊
  • 需要快速評論功能的初創企業
  • 專注於使用者互動的應用程式

使用建議

  • 有限的進階功能,如回覆或讚
  • 無內建驗證或後端
  • 需要自定義後端以實現資料持久化
  • 不適合大規模評論系統
  • 僅基本樣式選項
  • 開箱即用無即時更新

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

comment_box

A simple Flutter comment box for posts and products.

Youtube Preview

IMAGE ALT TEXT HERE

Pub

Overview

Overview

Features

  • Smooth Scrolling Supported.
  • User image Supported (Local and Url).
  • Text Wrapping Supported.
  • Many more . . .

Getting started

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  ...
  comment_box: ^0.0.18

In your library add the following import:

import 'package:comment_box/comment/comment.dart';

For help getting started with Flutter, view the online documentation.

Constructors

You can create a CommentBox:

CommentBox(
          userImage: CommentBox.commentImageParser(
              imageURLorPath: "assets/img/userpic.jpg"),
          child: commentChild(filedata),
          labelText: 'Write a comment...',
          errorText: 'Comment cannot be blank',
          withBorder: false,
          sendButtonMethod: () {
            if (formKey.currentState!.validate()) {
              print(commentController.text);
              setState(() {
                var value = {
                  'name': 'New User',
                  'pic':
                      'https://lh3.googleusercontent.com/a-/AOh14GjRHcaendrf6gU5fPIVd8GIl1OgblrMMvGUoCBj4g=s400',
                  'message': commentController.text,
                  'date': '2021-01-01 12:00:00'
                };
                filedata.insert(0, value);
              });
              commentController.clear();
              FocusScope.of(context).unfocus();
            } else {
              print("Not validated");
            }
          },
          formKey: formKey,
          commentController: commentController,
          backgroundColor: Colors.pink,
          textColor: Colors.white,
          sendWidget: Icon(Icons.send_sharp, size: 30, color: Colors.white),
        );
Full Example
import 'package:comment_box/comment/comment.dart';
import 'package:flutter/material.dart';

class TestMe extends StatefulWidget {
  @override
  _TestMeState createState() => _TestMeState();
}

class _TestMeState extends State<TestMe> {
  final formKey = GlobalKey<FormState>();
  final TextEditingController commentController = TextEditingController();
  List filedata = [
    {
      'name': 'Chuks Okwuenu',
      'pic': 'https://picsum.photos/300/30',
      'message': 'I love to code',
      'date': '2021-01-01 12:00:00'
    },
    {
      'name': 'Biggi Man',
      'pic': 'https://www.adeleyeayodeji.com/img/IMG_20200522_121756_834_2.jpg',
      'message': 'Very cool',
      'date': '2021-01-01 12:00:00'
    },
    {
      'name': 'Tunde Martins',
      'pic': 'assets/img/userpic.jpg',
      'message': 'Very cool',
      'date': '2021-01-01 12:00:00'
    },
    {
      'name': 'Biggi Man',
      'pic': 'https://picsum.photos/300/30',
      'message': 'Very cool',
      'date': '2021-01-01 12:00:00'
    },
  ];

  Widget commentChild(data) {
    return ListView(
      children: [
        for (var i = 0; i < data.length; i++)
          Padding(
            padding: const EdgeInsets.fromLTRB(2.0, 8.0, 2.0, 0.0),
            child: ListTile(
              leading: GestureDetector(
                onTap: () async {
                  // Display the image in large form.
                  print("Comment Clicked");
                },
                child: Container(
                  height: 50.0,
                  width: 50.0,
                  decoration: new BoxDecoration(
                      color: Colors.blue,
                      borderRadius: new BorderRadius.all(Radius.circular(50))),
                  child: CircleAvatar(
                      radius: 50,
                      backgroundImage: CommentBox.commentImageParser(
                          imageURLorPath: data[i]['pic'])),
                ),
              ),
              title: Text(
                data[i]['name'],
                style: TextStyle(fontWeight: FontWeight.bold),
              ),
              subtitle: Text(data[i]['message']),
              trailing: Text(data[i]['date'], style: TextStyle(fontSize: 10)),
            ),
          )
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Comment Page"),
        backgroundColor: Colors.pink,
      ),
      body: Container(
        child: CommentBox(
          userImage: CommentBox.commentImageParser(
              imageURLorPath: "assets/img/userpic.jpg"),
          child: commentChild(filedata),
          labelText: 'Write a comment...',
          errorText: 'Comment cannot be blank',
          withBorder: false,
          sendButtonMethod: () {
            if (formKey.currentState!.validate()) {
              print(commentController.text);
              setState(() {
                var value = {
                  'name': 'New User',
                  'pic':
                      'https://lh3.googleusercontent.com/a-/AOh14GjRHcaendrf6gU5fPIVd8GIl1OgblrMMvGUoCBj4g=s400',
                  'message': commentController.text,
                  'date': '2021-01-01 12:00:00'
                };
                filedata.insert(0, value);
              });
              commentController.clear();
              FocusScope.of(context).unfocus();
            } else {
              print("Not validated");
            }
          },
          formKey: formKey,
          commentController: commentController,
          backgroundColor: Colors.pink,
          textColor: Colors.white,
          sendWidget: Icon(Icons.send_sharp, size: 30, color: Colors.white),
        ),
      ),
    );
  }
}


所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。