搜索插件、代码仓与 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 项

源码仓库

使用此插件的项目

暂无相关数据。