Organizing my articles for Flutter and Server Side Dart
The articles below are mostly on Medium but also span a few other sites. If Medium is blocking you because you don’t have an account, let me know and I’ll provide a friend link. Click the (🤝) emoji to get the friend link.
These are some of my most important works:
What’s the difference?
Exception
is for an expected bad state that may happen at runtime. Because these exceptions are expected, you should catch them and handle them appropriately.Error
, on the other hand, is for developers who are using your code. You throw an Error to let them know that they are using your code wrong. As the developer using an API, you shouldn't catch errors. You should let them crash your app. Let the crash be a message to you that you need to go find out what you're doing wrong.assert
is similar…
A thousand pictures is worth a word
Consider this a visual supplement the InputDecoration
documentation. Sometimes it’s easier to just see and understand rather than reading a long description.
TextField(),
A whole new meaning to mobile developer
What? They don’t have computers?! How am I supposed to teach mobile app development if the students don’t have computers?
When asked if I would teach Mobile App Development in Spring 2021 at Mongolia International University, I gladly agreed. This would be a great opportunity to systematically present Flutter, a modern cross-platform UI framework for making native apps, one that I greatly prefer over plain Android and iOS development.
As Covid-19 continued to drag on throughout 2020 and into 2021, like at many of the schools around the world, the classes at MIU…
If you don’t crawl around the Flutter source code much you’ve probably never heard of text affinity, represented by the TextAffinity enum. It’s an interesting concept, though, and in this article I’ll try to make it easy to understand through the use of images.
The word affinity means attraction. This is referring to which part of the text the cursor (or caret as it’s sometimes called) is attracted to. To explain that, it’s first necessary to talk about text position, represented by the TextPosition class.
TextPosition has an offset property which is used for cursor location or text selection.
Take…
Text manipulation is a common programming problem. However, I generally try to avoid regular expressions (regex) because they are completely unreadable:
RegExp _email = RegExp(r"^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$")…
Sockets are a means of two-way communication over a network. This is similar to HTTP communication, but instead of making a single request and getting a single response, you leave the channel open for further communication. This has applications in chat apps, database communication, and other real-time messaging applications.
A socket server can listen for and receive connections from multiple socket clients. The server can then broadcast messages to all of the connected clients or take a message from one client and forward it on to another.
Part 3 in a series about Server Side Dart without a framework
If you haven’t read the first two parts of this series, you may want to start with them because they’ll provide a lot of background information that I won’t reexplain today:
If you’re comfortable with those topics, though, there’s no need to refer to them. This article will contain all the code you need to follow along.
Note: I’m using the pre-null safe version of Dart (2.10.4) to write this article, but I plan to…
Part 2 in a series about Server Side Dart without a framework
This article is a continuation in exploring Dart as an HTTP server backend, but without any frameworks or third-party packages. Knowing how to build a Dart server from scratch will not only make you a better developer in general, but will also keep you from being left in the lurch when your favorite framework falls off a cliff.
Go back and read Part 1: Building a Dart server from scratch if you haven’t already. …
The Uri class in Dart has good documentation, but sometimes seeing examples makes it a lot easier to understand. This article will show examples for all of the main parameters to make them more clear.
You can create a Uri by parsing string like this:
Uri uri = Uri.parse('http://www.example.com');
The following examples will all reference uri
but I’ll omit the line above to save space. Every example will start with the URL string to be parsed.
The scheme is something like http
, https
, or file
. There are a lot more.
http://www.example.comString scheme = uri.scheme;
print(scheme); // http
The authority…
A Flutter and Dart developer. Follow me on Twitter @suragch1 to get updates of new articles.