konami_detector 1.0.0 copy "konami_detector: ^1.0.0" to clipboard
konami_detector: ^1.0.0 copied to clipboard

A package to detect your konami codes and executes the provided callbacks.

example/lib/main.dart

import 'package:example/konami_codes/show_device_info_konami_code.dart';
import 'package:example/konami_codes/test_crash_konami_code.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:konami_detector/konami_detector.dart';

void main() {
  const enviroment = Environment.development;
  runApp(const MyApp(
    enviroment: enviroment,
  ));
}

class MyApp extends StatelessWidget {
  const MyApp({
    Key? key,
    required this.enviroment,
  }) : super(key: key);

  final Environment enviroment;

  @override
  Widget build(
    BuildContext context,
  ) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(enviroment: enviroment),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({
    Key? key,
    required this.enviroment,
  }) : super(key: key);

  final Environment enviroment;

  @override
  Widget build(
    BuildContext context,
  ) {
    return KonamiDetector(
      codes: [
        if (enviroment != Environment.production) TestCrashKonamiCode(),
        ShowDeviceInfoKonamiCode(),
      ],
      child: Scaffold(
        appBar: AppBar(
          title: const Text('Flutter Demo Home Page'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Container(
                width: MediaQuery.of(context).size.width * 0.75,
                height: MediaQuery.of(context).size.width * 0.75,
                padding: const EdgeInsets.all(16),
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(16),
                  color: Colors.greenAccent,
                ),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    const Text(
                      "Show Device Info: ",
                      style: TextStyle(
                        fontWeight: FontWeight.bold,
                        fontSize: 16,
                      ),
                    ),
                    Text(
                      ShowDeviceInfoKonamiCode()
                          .codes
                          .map(describeEnum)
                          .join(', '),
                    ),
                    const SizedBox(height: 16),
                    const Text(
                      "Test Crash",
                      style: TextStyle(
                        fontWeight: FontWeight.bold,
                        fontSize: 16,
                      ),
                    ),
                    Text(
                      TestCrashKonamiCode().codes.map(describeEnum).join(', '),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

enum Environment { development, staging, production }
8
likes
130
pub points
29%
popularity

Publisher

verified publisherbaseflow.com

A package to detect your konami codes and executes the provided callbacks.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, flutter_swipe_detector

More

Packages that depend on konami_detector