badword_guard 1.0.1 copy "badword_guard: ^1.0.1" to clipboard
badword_guard: ^1.0.1 copied to clipboard

A Flutter plugin for detecting and filtering out offensive language and bad words in text input.

example/lib/main.dart

import 'package:badword_guard/badword_guard.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final LanguageChecker checker = LanguageChecker();
  final TextEditingController textController = TextEditingController();
  String resultText = "";
  String filteredText = "";

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Bad Word Filter plugin'),
        ),
        body: Padding(
          padding: const EdgeInsets.all(16.0),
          child: Column(
            children: [
              TextField(
                controller: textController,
                decoration: const InputDecoration(
                  labelText: 'Enter text',
                  border: OutlineInputBorder(),
                ),
                maxLines: 5,
              ),
              const SizedBox(height: 16),
              ElevatedButton(
                onPressed: _checkAndFilterText,
                child: const Text('Check & Filter'),
              ),
              const SizedBox(height: 16),
              if (resultText.isNotEmpty) Text(resultText),
              const SizedBox(height: 8),
              if (filteredText.isNotEmpty) Text('Filtered: $filteredText'),
            ],
          ),
        ),
      ),
    );
  }

  void _checkAndFilterText() {
    String inputText = textController.text;
    bool containsBadWord = checker.containsBadLanguage(inputText);

    setState(() {
      resultText = containsBadWord
          ? 'The text contains inappropriate language.'
          : 'The text is clean.';
      filteredText = checker.filterBadWords(inputText);
    });
  }
}
3
likes
150
pub points
76%
popularity

Publisher

verified publishermdshahidulislam.tech

A Flutter plugin for detecting and filtering out offensive language and bad words in text input.

Repository (GitHub)
View/report issues

Topics

#badword #guard #filter #offensive

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on badword_guard