is_debug 0.0.6 copy "is_debug: ^0.0.6" to clipboard
is_debug: ^0.0.6 copied to clipboard

is running in debug.

example/lib/main.dart

import 'dart:async';
import 'dart:io';

import 'package:flutter/material.dart';

import 'package:is_debug/is_debug.dart';

void main() {
  runApp(const MaterialApp(home: MyApp()));
}

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool hostDisableScreenshot = false;
  StreamSubscription<dynamic>? screenshotListener;
  bool hostPausedSecret = false;
  bool flutterWatermark = false;
  bool pausedSecret = false;
  bool resumedSecret = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Plugin example app'),
        centerTitle: true,
      ),
      body: ListView(
        children: [
          ...ListTile.divideTiles(context: context, tiles: [
            const SizedBox(),
            ListTile(
              title: const Text('Running on: '),
              trailing: FutureBuilder<String?>(
                future: IsDebug.getPlatformVersion(),
                builder: (c, s) => Text('${s.data}'),
              ),
            ),
            ListTile(
              title: const Text('isDebugHost: '),
              trailing: FutureBuilder<bool>(
                future: IsDebug.isDebugHost(),
                builder: (c, s) => Text('${s.data}'),
              ),
            ),
            ListTile(
              title: const Text('isSimulatorHost: '),
              trailing: FutureBuilder<bool>(
                future: IsDebug.isSimulatorHost(),
                builder: (c, s) => Text('${s.data}'),
              ),
            ),
            ListTile(
              title: const Text('isRootHost: '),
              trailing: FutureBuilder<bool>(
                future: IsDebug.isRootHost(),
                builder: (c, s) => Text('${s.data}'),
              ),
            ),
            CheckboxListTile(
              title: const Text("hostDisableScreenshot"),
              subtitle: const Text("only support android"),
              value: hostDisableScreenshot,
              onChanged: (b) {
                if (!Platform.isAndroid) {
                  ScaffoldMessenger.of(context).showSnackBar(
                    const SnackBar(content: Text("only support android")),
                  );
                  return;
                }
                hostDisableScreenshot = b == true;
                setState(() {});
                IsDebug.hostDisableScreenshot(hostDisableScreenshot);
              },
            ),
            CheckboxListTile(
              title: const Text("screenshotListener"),
              subtitle:
                  const Text("android14 below requires permission.photos"),
              value: screenshotListener != null,
              onChanged: (b) {
                if (b == true) {
                  screenshotListener = IsDebug.onScreenshot.listen((event) {
                    ScaffoldMessenger.of(context).showSnackBar(
                      const SnackBar(content: Text("Host Screenshot running")),
                    );
                  });
                } else {
                  screenshotListener?.cancel();
                  screenshotListener = null;
                }
                setState(() {});
              },
            ),
            CheckboxListTile(
              title: const Text("hostPausedSecret"),
              subtitle: const Text("support android13(33) and ios"),
              value: hostPausedSecret,
              onChanged: (b) {
                hostPausedSecret = b == true;
                setState(() {});
                IsDebug.hostPausedSecret(hostPausedSecret);
              },
            ),
            CheckboxListTile(
              title: const Text("flutterWatermark"),
              value: flutterWatermark,
              onChanged: (b) {
                flutterWatermark = b == true;
                setState(() {});
                if (flutterWatermark) {
                  IsDebug.addWatermark(context, "jawa0919@163.com");
                } else {
                  IsDebug.removeWatermark();
                }
              },
            ),
            CheckboxListTile(
              title: const Text("pausedSecret"),
              subtitle: const Text("support android13(33) and ios"),
              value: pausedSecret,
              onChanged: (b) {
                pausedSecret = b == true;
                setState(() {});
                if (pausedSecret) {
                  IsDebug.addPausedSecret(context);
                } else {
                  IsDebug.removePausedSecret();
                }
              },
            ),
            CheckboxListTile(
              title: const Text("resumedSecret"),
              value: resumedSecret,
              onChanged: (b) {
                resumedSecret = b == true;
                setState(() {});
                if (resumedSecret) {
                  IsDebug.addResumedSecret(context);
                } else {
                  IsDebug.removeResumedSecret();
                }
              },
            ),
            Padding(
              padding: const EdgeInsets.all(16.0),
              child: Center(child: CircularProgressIndicator()),
            ),
            const SizedBox(),
          ]),
        ],
      ),
    );
  }
}
0
likes
0
points
39
downloads

Publisher

unverified uploader

Weekly Downloads

is running in debug.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on is_debug