Home > Software design >  Using flags in flutter
Using flags in flutter

Time:09-21

I have been searching if there are any packages in Flutter that can allow you to create flags to decide whether you run (or not) part of your code depending on if you want to make a debug build or a release build.

There are some features I systematically want to have when I run my app in debug, but that I don't want to have in my release build.

I have tried flagsmith which allow me to create flags which I can enable or disable manually (which isn't exactly what I want), but it doesn't seem to even work properly as I disable / enable the flag there is no hiding/showing my features dynamically.

My question: is there a tool, for flutter, which can allow me to create flags that run code depending I create a debug build or a release build ?

CodePudding user response:

You can use kDebugMode to check whether your code is running in debug mode.

Example:

import 'package:flutter/foundation.dart';
void foobar() {
  if (kDebugMode) {
    // Do something only in debug mode...
  }
}
  • Related