1

Supposer I have a Text, I want to only show it in debug mode. In release mode, it's hidden.

Now I come out an idea that set it's text string to empty.

But what if it is a Button. How to show it only in debug mode?

In C#, I can use conditions like

#if DEBUG

#endif

Is there something alike in flutter?

Vincent
  • 3,124
  • 3
  • 21
  • 40
  • 1
    Please check this out. it surely has the answer for you. https://stackoverflow.com/questions/49707028/check-if-running-app-is-in-debug-mode – Tonny Bawembye Jul 02 '20 at 11:36

1 Answers1

3

You can show or hide a Widget by testing if kReleaseMode is false or not. So if you want to show a Widget if debug mode is on then do the following:

body: kReleaseMode == false ? 'Widget at Debug mode' : 'Widget at Release mode'
John Arnok
  • 594
  • 4
  • 11
  • Should we keep the code that way or should we remove it before release? I mean does it adds up in the output APK? – Hardik Feb 05 '23 at 04:46