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

A Flutter widget that creates a TV static/noise effect for censoring content.

example/lib/main.dart

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

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

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

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

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

  @override
  State<CensorDemo> createState() => _CensorDemoState();
}

class _CensorDemoState extends State<CensorDemo> {
  bool _isCensoredExample1 = true;
  bool _isCensoredExample2 = true;
  bool _isCensoredExample3 = true;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Censor Widget Demo'),
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
      ),
      body: SafeArea(
        child: Padding(
          padding: const .all(16),
          child: Column(
            mainAxisAlignment: .start,
            crossAxisAlignment: .start,
            children: [
              const SizedBox(height: 32),
              Text(
                "Tap to reveal or censor content",
                style: Theme.of(context).textTheme.titleLarge,
              ),
              const SizedBox(height: 32),
              Text(
                "Example 1: Censored text",
                style: Theme.of(context).textTheme.titleMedium,
              ),
              const SizedBox(height: 16),
              GestureDetector(
                onTap: () {
                  setState(() {
                    _isCensoredExample1 = !_isCensoredExample1;
                  });
                },
                child: Censor(
                  censored: _isCensoredExample1,
                  child: const Text(
                    'Secret Information',
                    style: TextStyle(fontSize: 32, fontWeight: FontWeight.bold),
                  ),
                ),
              ),
              const SizedBox(height: 32),
              Text(
                "Example 2: Censored image, bigger particles and spacing",
                style: Theme.of(context).textTheme.titleMedium,
              ),
              const SizedBox(height: 16),
              GestureDetector(
                onTap: () {
                  setState(() {
                    _isCensoredExample2 = !_isCensoredExample2;
                  });
                },
                child: Censor(
                  censored: _isCensoredExample2,
                  particleSize: 20,
                  particleSpacing: 1,
                  animationSpeed: 0.005,
                  child: Container(
                    width: 200,
                    height: 150,
                    decoration: BoxDecoration(
                      border: Border.all(color: Colors.grey),
                      borderRadius: BorderRadius.circular(8),
                    ),
                    child: const Center(
                      child: Icon(Icons.lock, size: 64, color: Colors.red),
                    ),
                  ),
                ),
              ),
              const SizedBox(height: 32),
              Text(
                "Example 3: Faster animation",
                style: Theme.of(context).textTheme.titleMedium,
              ),
              const SizedBox(height: 16),
              GestureDetector(
                onTap: () {
                  setState(() {
                    _isCensoredExample3 = !_isCensoredExample3;
                  });
                },
                child: Censor(
                  censored: _isCensoredExample3,
                  particleSize: 3,
                  particleSpacing: 1,
                  animationSpeed: 2.0,
                  child: Container(
                    padding: const EdgeInsets.all(16),
                    decoration: BoxDecoration(
                      color: Colors.blue.shade100,
                      borderRadius: BorderRadius.circular(12),
                    ),
                    child: const Text(
                      'Confidential Data',
                      style: TextStyle(fontSize: 20),
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
2
likes
160
points
127
downloads

Publisher

verified publisherolegnovosad.com

Weekly Downloads

A Flutter widget that creates a TV static/noise effect for censoring content.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on censor