Never miss a beat

Join my newsletter.

The Archives

The Many Constructors of Dart

Published: 9/9/2020

Last night, as I was writing code in a Flutter app, I came across an interesting dilemma. I wanted to throw a custom exception if I was unable to sign in with Apple on the login screen — nothing too crazy. Naturally, this lead me to creating a custom exception. I tried something along the lines of: However, I found out quickly that this wasn’t valid. In fact, you get an error that looks like this: The generative constructor 'Exception Exception([dynamic message])' expected, but factory found…

Flutter routing inside of the Scaffold

Published: 8/11/2020

If you’re coming from React Native to Flutter, one of the first things you’ll likely ask is “How do I do routing?” First, I’d ask you to consider if you actually need routing. Instead, could you just have a global state that determines which screen to show? In most cases, probably. But if you want things to feel right when building Flutter for Web (or want decent deep linking support), you’ll probably want to build your flutter app with routing. Routing can easily be accomplished via the…

TypeScript Tuples

Published: 4/9/2020

TypeScript offers a plethora of types for developers to leverage, but some of the types may be ones that you’re unfamiliar with. Take the tuple, for example. JavaScript doesn’t have a concept of tuples , so figuring out how and when to use one might feel tricky. Thankfully, Tuples are pretty simple and are used by popular frameworks, like React. What is a tuple? Tuples allow you to express an array with a fixed number of elements of which each element may be of a different type. For example…

Arrow Functions in PHP 7.4+

Published: 3/31/2020

PHP is finally getting arrow functions (also known as Short Closures)! I know, I know. I’m just as excited as you are. Here’s everything you need to know about arrow functions in PHP. First, arrow functions are an approved RFC for PHP 7.4. If you’re using a version of PHP that’s lower than 7.4, you won’t be able to use arrow functions. Second, arrow functions can only contain one single expression. The goal with arrow functions ( as stated in the RFC ) is to help reduce verbosity and multi-line…

Building a simple URL Shortener in PHP with Laravel

Published: 3/12/2020

I’ve recorded a quick Youtube video for you! In this video, we walk through building a simple URL shortener (think in PHP with the Laravel framework. This originally started as part of my Laravel foundations course (link coming soon) but I felt that we could quickly get through an example on Youtube, too. In the course, we dive into things and go a bit slower to really get a grasp on how everything works, but this less than 30 minute video should get you started down the right path. If…

How to read from a file in PHP

Published: 3/9/2020

Reading from a file in PHP is an extremely common problem to solve. You may keep configuration variables in an environment file, or perhaps you pull in HTML from another file. Either way, you need your PHP code to read the contents of those files. Good news: It’s actually a fairly simple task to perform! What’s interesting is that there’s actually quite a few ways to read from a file in PHP. We’ll cover two common cases here and talk about why you’d use one over the other. Heads up: If…