flutter_nsfw_detector_text 0.0.3 copy "flutter_nsfw_detector_text: ^0.0.3" to clipboard
flutter_nsfw_detector_text: ^0.0.3 copied to clipboard

Pure-Dart text content filtering with keyword matching, profanity detection, and leet-speak normalization.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Text Filter Example',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  // 1. Initialize the scanner with some basic rules
  final scanner = TextScanner(
    filters: [
      ProfanityFilter(words: {'badword1', 'badword2'}),
      KeywordFilter(keywords: {'drugs'}),
    ],
  );

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Text Filter Example')),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          children: [
            const Text('Try typing "badword1" or "drugs" below:'),
            const SizedBox(height: 16),
            TextField(
              // 2. Attach the formatter for real-time censoring
              inputFormatters: [
                NsfwTextInputFormatter(
                  scanner: scanner,
                  mode: NsfwInputMode.censorInPlace,
                ),
              ],
              decoration: const InputDecoration(
                border: OutlineInputBorder(),
                hintText: 'Enter some text...',
              ),
            ),
          ],
        ),
      ),
    );
  }
}
0
likes
160
points
42
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Pure-Dart text content filtering with keyword matching, profanity detection, and leet-speak normalization.

Repository (GitHub)
View/report issues

Topics

#content-moderation #text-moderation #profanity-filter #nsfw

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_nsfw_detector_text