is_debug 0.0.1
is_debug: ^0.0.1 copied to clipboard
Determine if the app is running in debug mode.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:is_debug/is_debug.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
final _isDebugPlugin = IsDebug();
@override
void initState() {
super.initState();
initPlatformState();
}
Future<void> initPlatformState() async {
String platformVersion;
try {
platformVersion = await _isDebugPlugin.getPlatformVersion() ?? "--";
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
if (!mounted) return;
setState(() {
_platformVersion = platformVersion;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(
children: [
Text('Running on: $_platformVersion\n'),
FutureBuilder<bool?>(
future: IsDebug().isDebugHost(),
builder: (context, snapshot) {
return Text('isDebugHost on: ${snapshot.data}\n');
},
),
],
),
),
),
);
}
}