Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save asad-albadi/f089c2ff47f76c6ad1aeb0a11d17ef07 to your computer and use it in GitHub Desktop.
Save asad-albadi/f089c2ff47f76c6ad1aeb0a11d17ef07 to your computer and use it in GitHub Desktop.

Flutter with LibAdwaita and Bitsdojo Window Integration

This guide walks you through integrating LibAdwaita, Bitsdojo Window, and related plugins to create a polished, GNOME-native experience for your Flutter desktop application.


Required Plugins

Add the following dependencies to your pubspec.yaml:

dependencies:
  adwaita: latest
  libadwaita: latest
  libadwaita_bitsdojo: latest
  desktop_notifications: latest
  lucide_icons: latest

Run the command to install them:

flutter pub get

Applying Rounded Corners

Modify your MaterialApp widget to apply rounded corners to the home page:

return MaterialApp(
  home: ClipRRect(
    borderRadius: BorderRadius.circular(15),
    child: const HomePage(), // Replace with your actual home widget
  ),
);

Removing Default Headerbar

Modify linux/my_application.cc:

  1. Locate the following lines:

    gtk_window_set_default_size(window, 1280, 720);
    gtk_widget_show(GTK_WIDGET(window));
  2. Replace them with:

    auto bdw = bitsdojo_window_from(window);
    bdw->setCustomFrame(true);
    gtk_window_set_default_size(window, 600, 450); // Adjust as needed
    gtk_widget_show(GTK_WIDGET(window));
  3. Save the file and rebuild your project.


Using AdwScaffold and GNOME Headerbar

Replace Scaffold with AdwScaffold for better GNOME integration:

import 'package:flutter/material.dart';
import 'package:adwaita/adwaita.dart';
import 'package:lucide_icons/lucide_icons.dart';
import 'package:libadwaita_bitsdojo/libadwaita_bitsdojo.dart';

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return AdwaitaTheme(
      child: MaterialApp(
        home: MyHomePage(),
      ),
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return AdwScaffold(
      actions: AdwActions().bitsdojo,
      start: [
        AdwHeaderButton(
          icon: const Icon(LucideIcons.rocket, size: 15),
          onPressed: () {},
        )
      ],
      title: const Text('Bitsdojo Window'),
      body: Center(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [const Text('Welcome to Bitsdojo Window!')],
        ),
      ),
    );
  }
}

Running the Application

To run your Flutter app with LibAdwaita and Bitsdojo Window integration:

flutter run -d linux

This will launch your Flutter app with a GNOME-like UI, custom window decorations, and proper integration with desktop features.


Additional Notes

  • LibAdwaita provides better GTK theming and widgets for a native GNOME look.
  • Bitsdojo Window allows customization of the window frame, making it feel more native.
  • Lucide Icons provides a modern icon set, ideal for GNOME apps.
  • Desktop Notifications can be used to trigger native system notifications.

This setup ensures that your Flutter application has a polished and well-integrated GNOME experience on Linux desktops.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment