How to gather desktop disk drives information in Flutter

Angelo Cassano
3 min readSep 18, 2022

--

In my humble opinion, Flutter desktop has been a wonderful breakthrough for desktop app development, more than Flutter web.

My experience as a developer started almost fourteen years ago: I wasn’t a good programmer because I was a lazy person, I didn’t want to study algorithms and data structures from books and the only thing I kept doing was copy-pasting stuff or doing things without knowledge of the facts.

Why am I telling you that? Because of that attitude, I decided to stick with a simple programming language like Visual Basic .NET to start developing my first desktop apps.

A screenshot of a Visual Studio IDE with a Windows Form app

In the following years, as many of you know, I abandoned desktop app development in favor of mobile app development. In the meantime, I had the chance to test some other desktop frameworks or technologies like Electron or GTK, but nothing has surprised me like Flutter desktop: for instance, Electron apps are generally heavy-resources consuming due to the Chromium instances.

The disks desktop library

After this boring introduction, let’s stick back to the point of this article. Even though Flutter desktop moved to stable a few months ago, it still lacks some things like interaction with its native operative system.

In my case, I needed to develop a desktop app able to burn ISO or IMG images to external disk drives. When I started diving into the internet looking for libraries or code to do that I found literally nothing.

I mean, you can do very high-level things like gathering paths with some well-known libraries like path provider, but I wasn’t able to enumerate the available disk drives in my system or understand whether that drive is a system drive, is removable, and so on.

And that’s why I decided to develop disks_desktop, a Flutter desktop library able to retrieve installed disk drives information. disks_desktop is available for Windows, macOS and Linux.

The disks_desktop library logo

With Disks Desktop you can get access to disks’ information like:

  • block size
  • bus type
  • bus version
  • description
  • device name
  • device path
  • logical block size
  • available mountpoints
  • disk size
  • partition table type
  • is in error
  • is a card
  • is read only
  • is removable
  • is scsi
  • is system
  • is uas
  • is usb
  • is virtual
  • is raw

Setup

In general, put it under dependencies, in your pubspec.yaml:

dependencies:
disks_desktop: ^1.0.1

You can install packages from the command line:

flutter pub get

or simply add it through the command line:

flutter pub add disks_desktop

Usage

To get the list of the available drives with their details, simply create an instance of a Disk Repository and invoke the query getter.

Example:

final repository = DiskRepository();
final disks = await repository.query;

You can also use it with a FutureBuilder:

FutureBuilder<List<Disk>>(
future: DisksRepository().query,
builder: (context, snapshot) => [...]
),

Links and Examples

The disks_desktop library is available under pub.dev and on GitHub. Please check the example project to better understand how to create a desktop app.

Thank you for reading 👋

I hope you enjoyed this article. If you have any queries or suggestions please let me know in the comments down below.

--

--

Angelo Cassano
Angelo Cassano

Written by Angelo Cassano

A perfectionist. Software engineer and IT passionate.

No responses yet