What’s new in Floor 1.4.2

Thomas Middel
Pinch.nl
Published in
2 min readApr 25, 2023

Floor is a typesafe, reactive, lightweight SQLite database for Flutter. Android developers will probably feel familiar from the get-go since this SQLite abstraction is heavily based on the Room persistence library Google has for native Android development.

Today marks the release of Floor 1.4.2, with many thanks to heavy contributor Dkaera 🙏 After the takeover last year, things have been, quieter than we would’ve liked. That’s why starting next month, the Floor project will get some more TLC, being treated like our other projects and having dedicated time available for Pinchers each month to spend on Floor. Floor will get more regular updates, aiming at a release every 2 months as a minimum, and with that having “What’s new” articles with these releases to keep you up-to-date with what’s happening. We hope you like it and continue to use Floor, below is a short overview of the things that came with our 1.4.2 release!

Stream updates on table modifications

With Floor, it has always been possible to either treat your queries as one-offs by using Futures, or by observing your data through Streams. Futures would return a result after they’re done, but streams on the other hand never got updated when modifying a table. Now, starting with Floor 1.4.2, your streams will receive updates when executing queries that modify your table: updates or deletes will now trigger stream updates, giving you up-to-date data when observing.

TypeConverters priority

Floor supports Dart primitive types out of the box: Strings, Integers, or even Enums. If, however, you have a type that is not supported, you can add your own TypeConverter. Previously, Floor would always prioritize primitive types over your own TypeConverters, meaning if you would’ve wanted to ‘override’ a primitive type this would not work.

Let’s say we have the following enum

It’s supported out of the box by Floor, but in this case, maybe we’d like to map it to something like its name instead. We could do so by writing our own converter:

In versions prior to 1.4.2, this will not work. Floor will treat the usage of the TodoStatus enum as a regular enum since it prioritizes primitive types over type converters, until now.

Starting version 1.4.2, this has been changed. Now, Floor will give your custom TypeConverter priority over a primitive type and handle it the way you wanted it to! 🎉

Constructor ordering

When generating code in previous versions, Floor would always take the first constructor as the default constructor, even if that means a named constructor instead of the public, non-factory one.

This wouldn’t break code generation but instead could lead to some weird, unexpected behavior.

Now, starting with Floor 1.4.2, code generation will take the constructor position into account, meaning Floor will always check for a public, non-factory constructor regardless of where it’s placed.

And that’s that! We hope you like this release of Floor. If you have any issues or ideas, feel free to let us know through Github so we can help you out.

--

--