How to check flutter application is running in debug?

后端 未结 9 1128
孤独总比滥情好
孤独总比滥情好 2020-12-08 12:25

I have a short question. I\'m looking for a way to execute code in Flutter when the app is in Debug mode. Is that possible in Flutter? I can\'t seem to find it anywhere in t

9条回答
  •  轮回少年
    2020-12-08 13:14

    Here is a simple solution to this:

    import 'package:flutter/foundation.dart';
    

    then you can use kReleaseMode like

    if(kReleaseMode){ // is Release Mode ??
        print('release mode');
    } else {
        print('debug mode');
    }
    

提交回复
热议问题