Find the right State object to call its setState()
In time, you’ll get to know one important circumstance when working with Flutter — you will regularly need to call a State object’s setState() function. In other words, you’ll need to repeatedly ‘refresh’ or ‘rebuild’ the app’s interface and reflect any ongoing changes, and that’s done by calling a State object’s setState() function. Doing so will have the Flutter framework call that State object’s build() function. You’re not to directly call the build() in the declarative programming framework that is Flutter. You’re to call setState().
In time, however, while working with…
An example app showcasing the PageView widget
With the very growing popularity of Flutter, you’ll find more and more blogs, medium articles, and YouTube videos out there on how to use Flutter’s ever-growing number of widgets. With that, I’ve pivoted in my efforts and now write articles more on the implementation of those widgets while possibly referencing any articles and or videos now out there on the subject.
I mean, why repeat what’s already been said? They’ve already describe a widget’s many parameters and how to use them, and so my articles will now mainly involve ‘looking under the hood’…
An in-depth look at the TextStyle Widget
We’re going to use the good ol’ startup app (the counter app) as a means to examine and demonstrate the TextStyle widget in this article. However, I’ve removed almost everything of the original code leaving just the sentence, ‘You have pushed the button this many times:’ The idea being, we’ll then introduce options in this article modifying ‘the style’ of the text and get an appreciation of what the TextStyle widget can do for you and your own apps. …
A look into Flutter’s Navigation System
In part 2 of this series, we’ll continue our look at Flutter’s navigation system and examine another approach used to navigate from screen to screen in your Flutter app. This approach works with ‘named routes’, using the static function,
Navigator.pushNamed(). We’ll also look at what’s involved when you go back through the ‘route stack’ with the static function,
An in-depth look at Testing in Flutter.
You’ve got to test your code. It’s a given. You’ve got to make sure it works, but like documentation, we programmers tend to write our test cases almost as an afterthought. Some shops, however, dedicate whole departments just to testing. Someone else then tests your code! Flutter offers a whole platform just for testing your code. Let’s take a look at how it’s done.
In every new Flutter project, you‘ll find a directory called, test. In this article, we’re going to look at the test file, widget_test.dart, found in that directory for this…
A dynamic and more adaptive popup menu
I hate Flutter’s popup menu. It’s ugly. It’s a block of white in the corner of the screen. Does it have to be just a square like that slapped on top of the AppBar? It doesn’t look good. It looks amateurish. Why can’t it look more like the menu in the screenshot below on the right-hand side? That’s a little better.
Another thing I don’t like about Flutter’s popup menus is the clutter. I hate the ‘Flutter clutter!’ You know what I mean. …
A look into Flutter’s Navigation System
In Flutter, the screens or pages presented to you in a mobile app are called routes. Behind the scenes, while you navigate through the app going from screen to screen, a ‘stack of routes’ is being managed by the StatefulWidget, Navigator. There is an actual class called, Navigator, involved in all this. With this article, we’ll introduce ourselves to this class as well as take a tentative look at Flutter’s navigation system. Subsequent articles on the subject will follow.
As always, I prefer using screenshots in my articles over gists to show concepts rather…
An in-depth look at the InheritedWidget
This sample app, counter_app_inherited, is being used in this article to showcase the InheritedWidget. It supplies the simple ‘counter app’ you’ll no doubt recognize whenever you create a new Flutter project. However, in this app, an InheritedWidget is involved in incrementing the counter.
Looking at the screenshot below, the red arrows highlight how the InheritedWidget is being implemented. As always when the ‘floating button’ is pressed, a setState() function is called. However, in this app, it’s a static setState() function defined in the class, BuildInheritedWidget. The traditional expression, _counter++;, is nowhere to be seen…
An in-depth look at MediaQuery Widget
It’s been said, many developers learning Flutter first encounter the MediaQuery widget with an error. Something akin to, “MediaQuery.of() called with a context that does not contain a MediaQuery.” For example, these developers were no doubt told to use the static function, of, in the MediaQuery class when they wanted the width and or height of the phone’s screen. However, they did so with a little too much enthusiasm without starting their app up with a MaterialApp widget or a CupertinoApp widget.
The example app, mediaQuery.dart, we’re using, today, in this article is listed…
More like State access, no? Conceptual discussion.
As you know, there’s a great number of architectural frameworks offered to Flutter developers to supply some form of State Management to their apps. I even threw in an offering that emulates a time-tested design pattern. However, I won’t promote it here. That would be uncouth.
Back in March of 2018, all I wanted was to get rid of two warning messages that I was always encountering when first learning Flutter. These messages were telling me I was doing something wrong and not optimizing my code to take full advantage of Flutter's unique…