easy_report 0.0.8
easy_report: ^0.0.8 copied to clipboard
An easy report management system for various type of data for Flutter and Firebase
Easy Report #
easy_report package provides an easy way of reporting and managing users, posts, comments, photos, chat, and other user generated contents. It is designed to be used in any kind of app that has user generated contents. It provides a way of reporting users and their contents.
TODO #
- Let admin list the reported users and their contents. And decide to block(disbable) their account. So that they cannot use the app.
Concept #
-
It does not require an input from user to avoid the inconveniencing the user. Instead, it ask users to press a button for the reason of the report. And it offers three options.
Spam,Abusive,Otherand I think these are enough. -
It saves
- The uid of the user who is responsible for the data. It can be the uid of the user who created the data or the uid of the user who is the admin of the data.
- the path of the data. The data can be a path of realtime database or a path of firestore document.
- The type of the data. It can be
user,post,comment,photo,chat, etc. - The reason of the report. It can be
spam,abusive,other. - The summary of the report. It can be a text that describes the report. Or it can be a text that describes the reason of the report. Or it can be a text that describes the data.
Database Structure #
-
reports/$reportKeypath$reportKeyis the node data key.-
reporteefield: The uid of the user who is responsible for the data. -
reporterfield: The uid of the user who created the report. It is usually the login user's uid. -
pathfield: The path of the data. It can be a path of realtime database or a path of firestore document. -
typefield: The type of the data. It can beuser,post,comment,photo,chat, etc. -
reasonfield: The reason of the report. It can bespam,abusive,other. -
summaryfield: The summary of the report. -
createdAtfield: The time when the report is created.
-
-
reports/---key-list/$reportKeypath---key-listis the node data key. It holds all the report Keys. This is for admin's report listing purpose.$reportKeyfield: This key is the reoprt key. It has uid as value.
How to use #
Initialize #
- You may(or may not) want to initialize the
ReportServicebefore using it. - With the
initmethod, you can- customize the
onCreatecallback. TheonCreatecallback is called after the report is created. It contains the newly createdreportinformation. - set the path of user name and photo url. The default path is
user-mirrors/{uid}/nameanduser-mirrors/{uid}/photoUrl. If your database has different structure, you can set the path withuserNamePathandphotoUrlPathparameters.
- customize the
ReportService.instance.init();
Displaying a report button #
You can display report button like this. And call the report method.
TextButton(
onPressed: () async {
await ReportService.instance.report(
context: context,
otherUid: user.uid,
documentReference: user.ref,
);
},
child: const Text('Report'),
),
Displaying the list of blocks #
You can display the list of blocked users.
ElevatedButton(
onPressed: () =>
ReportService.instance.showReportListScreen(context),
child: const Text(
'Report list',
),
),
UI/UX customization #
It's open source. You can simply open the source code of this package and copy/paste/edit the code. The code would be easy enough to re-use.
- To display the reports that the login user made, call
ReportService.instance.showReportListScreen(). - To customize the UI of the report list screen, you can create your own screen and use
ReportListView.ReportListViewsupports most of the properties of the list view widget.
onCreate CallBack #
The onCreate is a callback after the report is created. It contains the newly created report information.
Usage: (e.g. send push notification admin about the report)
In the example below, we can send push notification to admin after report is created.
ReportService.instance.init(
onCreate: (Report report) async {
/// set push notification. e.g. send push notification to reportee
/// or developer can send push notification to admin
MessagingService.instance.sendMessageToUids(
uids: [report.reportee],
title: 'You have been reported',
body: 'Report reason ${report.reason}',
data: {
"action": 'report',
'reportId': report.id,
'documentReference': report.documentReference.toString(),
},
);
},
);