Check for Debug/Release Mode in Flutter Apps 🎯

One of the main reasons for Flutter being so popular is its capacity to make complex tasks simple. Check your app’s build mode is one of those things which developers need in almost every app. We need it to dynamically set the API Endpoints for Debug and Release mode, Block some features which are under development, and even modify the analytics based on the mode we are using.

So, how exactly can we do that in Flutter? 🤔

Well, Flutter with its “foundations” package gives us with following constants:

  1. kReleaseMode
  2. kProfileMode
  3. kDebugMode

We can use these three constants to detect the mode around which we want our code to be dynamic. In most cases, you would want to use the “kReleaseMode” constant. This is only set to true when the application is built using the — release flag. Let’s take a look at this with an example:


Here is a code for a URLController class that we can use to define API endpoints and respective routes for various requests:

In this, you can see that we have two endpoints “_debugEndpoint” which we have to use for development purposes, and “_productionEndpoint” which we have to use for the production build of the app. So to choose between these we create a third constant and for its value, we use the kReleaseMode constant from the foundations package (imported on top) to check if our app is running in the release mode, and based on that we set the value of _endpoint. Then we use the _endpoint as an API Endpoint for our request routes namely login and profile.

Now if we run the app to display the login URL with the following code:

return Scaffold(
appBar: AppBar(
title: Text("Mode"),
body: Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 50.0),
child: Text("${URLController.login}",style: TextStyle(fontSize: 25),),

We see the following results:

Debug Mode
Release Mode

And that’s it! 🤯

It is that easy to detect the mode of Flutter Apps!

If you like to have a visual representation for reference, check out this tutorial on my Youtube Channel and you’ll have a good idea! And while you’re there, if you find this useful, consider Subscribing and Sharing!

If you find this Useful, Consider Subscribing to RetroPortal Studio on Youtube at:

Here are the links to my other Social Media Handles:






Happy Coding! ✌😁




Mobile Application and Web Developer | @Youtube Content Creator | Worship #reactjs #flutter #java #dart |

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Microservices vs. Serverless Architecture

Flexbox in 20 Minutes

Android Image Filters Algorithm

Kubernetes Mutating Webhook — Part II — Development

How to Sort An ArrayList In Java, Best Approaches to sort ArrayList In Java

How to sort arraylist in java

How I got my first dev job, and why I left it.

RPKI origin validation for resolvers!

Injecting Fault in Azure Cache for Redis using Azure Chaos Studio through Rest API (Part 2)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Paras Jain

Paras Jain

Mobile Application and Web Developer | @Youtube Content Creator | Worship #reactjs #flutter #java #dart |

More from Medium

Maintaining PageView’s Current Page after Orientation Changes using Keys

A Framework for Flutter Part 4

Add loading indicator toFlutter Web

Intro to golden tests in Flutter