Breaking News: Flutter 3.7 shocker — The most obvious widget finally added!

Alex Josef Bigler
Full Struggle Developer
3 min readApr 16, 2023

People new to Flutter will be amazed.

The widget we’re talking about is available in third-party libraries, but for such simple things, it’s not very desirable to use someone else’s code. First, I’ll show you how this widget was implemented by me (previously), and then I’ll replace the entire code with just one line.

Before trying it yourself, make sure that Flutter is updated to version 3.7 using the command:

flutter doctor

If not, then…

flutter upgrade

The widget we’re talking about is the Badgeyes, that small circle with a number in the corner of an icon. It didn’t exist before, and you could get around the issue like this…

              Stack(alignment: Alignment.center, children: [
IconButton(
icon: const Icon(Icons.notifications_active),
onPressed: () => {}),
Positioned(
right: 5,
top: 5,
child: Container(
padding: const EdgeInsets.all(2.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
color: Colors.red,
),
constraints: const BoxConstraints(
minWidth: 16,
minHeight: 16,
),
child: const Text(
"4",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 10, color: Colors.white),
),
))
])

And it worked overall (I’ll show the result below). But now, with the release of Flutter 3.7, you can simply do it like this, without any imports:

const Badge(
label: Text("4"),
child: Icon(Icons.notifications_active),
)

Without any imports, the result is…

Can you guess where the new badge is? Hint: it’s the one with fewer lines of code 🤡.

While you recover from the shock, you might be interested in my series of articles on working with REST APIs in Flutter, so don’t miss out:

And some benchmarking stuff:

Investing stuff:

Or tech stuff:

--

--

Alex Josef Bigler
Full Struggle Developer

Enthusiast of new technologies, entrepreneur, and researcher. Writing about IT, economics, and other stuff. Exploring the world through the lens of data.