How to Fix a Flutter Linux Build Error X Window System GLXBadFBConfig

When I first started building Flutter apps for Linux, I ran into a frustrating issue the X Window System error. It completely stopped my app from launching, and at first, I thought my setup was broken.

If you’re working on Elementary OS (or any Ubuntu-based distro), you might see this same problem after updating your system. Don’t worry it’s fixable. In this post, I’ll walk you through what I did: from writing a minimal Flutter app, to understanding the error, fixing it, and even extending the project with some extra functionality.

A Minimal Flutter Linux Code

To start, I created the simplest main.dart file just to check if my Flutter Linux environment was working.

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Linux Flutter App',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: const HomeScreen(),
    );
  }
}

class HomeScreen extends StatelessWidget {
  const HomeScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("Linux Flutter Example")),
      body: const Center(
        child: Text("Hello Flutter on Linux!", style: TextStyle(fontSize: 20)),
      ),
    );
  }
}

When running this, I expected a simple screen with a blue AppBar and some centered text.

The Error Explain

But instead, I got this error when running:

flutter run -d linux
(store_items:6176): Gdk-ERROR **: The program 'store_items' received an X Window System error.
The error was 'GLXBadFBConfig'.

At first, this message was confusing. After digging deeper, I figured out what it meant.

  • GLXBadFBConfig → This means the program tried to use a framebuffer configuration (FBConfig) that my GPU driver or X server couldn’t handle.
  • Flutter for Linux relies on GTK3 (see GTK3 docs) and OpenGL for rendering.
  • If your Mesa / NVIDIA / AMD graphics drivers are outdated or misconfigured, the Flutter engine crashes before drawing anything.

So, this was essentially a graphics driver issue.

Fix the Issue

Here’s how I fixed it. You might not need all of these steps, but I’ll list them in the order I tried them.

Update GPU Driver

On Ubuntu or Elementary OS, I updated my drivers with:

sudo apt update
sudo apt upgrade
sudo ubuntu-drivers autoinstall

Then I rebooted.

Install Linux desktop dependencies

Flutter apps on Linux depend on GTK3 and a few other libraries. I installed them with:

sudo apt install libgtk-3-dev libblkid-dev liblzma-dev libstdc++-12-dev

Run with software rendering (temporary fix)

When I still had issues, I tried forcing Flutter to use CPU rendering:

flutter run -d linux --enable-software-rendering

This worked! It’s slower than GPU rendering, but it at least let me continue testing my app.

Debug with GDK Synchronization

To get clearer logs, I enabled synchronization with:

GDK_SYNCHRONIZE=1 flutter run -d linux

This makes the error messages line up better with what’s happening in the app.

Add More Functionality

Once I got the app running, I wanted to test Flutter’s Linux capabilities. I added a simple button that displays system info when pressed.

Here’s the updated HomeScreen:

import 'dart:io';
import 'package:flutter/material.dart';

class HomeScreen extends StatefulWidget {
  const HomeScreen({super.key});

  @override
  State<HomeScreen> createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  String _info = "Press the button to get system info";

  void _getSystemInfo() {
    setState(() {
      _info = "OS: ${Platform.operatingSystem} ${Platform.operatingSystemVersion}\n"
              "Dart: ${Platform.version}\n"
              "Executable: ${Platform.resolvedExecutable}";
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("Linux Flutter Example")),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(_info, textAlign: TextAlign.center),
            const SizedBox(height: 20),
            ElevatedButton(
              onPressed: _getSystemInfo,
              child: const Text("Get System Info"),
            ),
          ],
        ),
      ),
    );
  }
}

What this does:

  • Displays your Linux OS name and version.
  • Shows the Dart runtime version.
  • Prints the executable path.

This was a nice little test project to confirm that Flutter desktop apps can interact with system-level details.

Final Thought

Fixing the GLXBadFBConfig error taught me that while Flutter on Linux is incredibly powerful, it’s still tightly dependent on the graphics drivers underneath. Many times, the problem isn’t Flutter itself but the system’s OpenGL setup. The best approach is to start with updating drivers and installing the right dependencies, and only use software rendering as a last resort. Once the issue is resolved, you can move forward with confidence and dive into the exciting desktop features Flutter has to offer.

Related blog posts