Responsive Split View in Flutter

Did you know?

In Flutter, you can easily create a responsive split-view widget that works on mobile, desktop and web.

You can do this in 30 lines of code, without any 3rd party packages: 👇

Responsive Split View in Flutter

Example Code

class SplitView extends StatelessWidget {
  const SplitView({super.key, required this.navigationBuilder,
      required this.contentBuilder, this.breakpoint = 600,
      this.navigationWidth = 300});
  final WidgetBuilder navigationBuilder;
  final WidgetBuilder contentBuilder;
  final double breakpoint;
  final double navigationWidth;
 
  @override
  Widget build(BuildContext context) {
    final screenWidth = MediaQuery.sizeOf(context).width;
    if (screenWidth >= breakpoint) {
      // * wide screen: navigation on the left, content on the right
      return Row(
        children: [
          SizedBox(
            width: navigationWidth,
            child: navigationBuilder(context),
          ),
          // if you want, add a divider here
          Expanded(child: contentBuilder(context)),
        ],
      );
    } else {
      // * show content only (handle navigation with a drawer or similar)
      return contentBuilder(context);
    }
  }
}

For a more complete tutorial, read this article (slightly outdated, but the main principles still apply):

Happy coding!

Want More?

Invest in yourself with my high-quality Flutter courses.

Flutter in Production

Flutter in Production

Learn about flavors, environments, error monitoring, analytics, release management, CI/CD, and finally ship your Flutter apps to the stores. 🚀

Flutter Foundations Course

Flutter Foundations Course

Learn about State Management, App Architecture, Navigation, Testing, and much more by building a Flutter eCommerce app on iOS, Android, and web.

Flutter & Firebase Masterclass

Flutter & Firebase Masterclass

Learn about Firebase Auth, Cloud Firestore, Cloud Functions, Stripe payments, and much more by building a full-stack eCommerce app with Flutter & Firebase.

The Complete Dart Developer Guide

The Complete Dart Developer Guide

Learn Dart Programming in depth. Includes: basic to advanced topics, exercises, and projects. Last updated to Dart 2.15.

Flutter Animations Masterclass

Flutter Animations Masterclass

Master Flutter animations and build a completely custom habit tracking application.