swipeable_drawer_layout 0.0.7 copy "swipeable_drawer_layout: ^0.0.7" to clipboard
swipeable_drawer_layout: ^0.0.7 copied to clipboard

A customizable swipeable drawer layout widget for Flutter supporting 4-way swipe directions and programmatic control.

example/main.dart

// ============================================================================
// SWIPEABLE DRAWER LAYOUT - EXAMPLE
// Easy to use swipeable drawer layout for Flutter applications.
//
// Developed by: Anas4711
// Package: swipeable_drawer_layout
//
// A simple example demonstrating basic usage of [SwipeableDrawerLayout].
// ============================================================================

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

/// Entry point of the example application.
void main() {
  runApp(
    const MaterialApp(debugShowCheckedModeBanner: false, home: ExampleScreen()),
  );
}

/// A sample screen demonstrating the usage of [SwipeableDrawerLayout].
class ExampleScreen extends StatefulWidget {
  /// Creates an [ExampleScreen].
  const ExampleScreen({super.key});

  @override
  State<ExampleScreen> createState() => _ExampleScreenState();
}

class _ExampleScreenState extends State<ExampleScreen> {
  // Swipeable Drawer Controller
  final SwipeableDrawerController _drawerController =
      SwipeableDrawerController();

  // Dispose the controller to prevent memory leaks.
  @override
  void dispose() {
    _drawerController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return SwipeableDrawerLayout(
      controller: _drawerController,
      direction: DrawerDirection.leftToRight,

      // 1. Secondary Screen (Background)
      secondaryScreen: Container(
        color: Colors.white,
        child: Center(
          child: ElevatedButton.icon(
            onPressed: () => _drawerController.close(),
            icon: const Icon(Icons.arrow_back),
            label: const Text('Back'),
          ),
        ),
      ),

      // 2. Main Screen (Foreground)
      mainScreen: Scaffold(
        appBar: AppBar(
          title: const Text('Home'),
          leading: IconButton(
            icon: const Icon(Icons.menu),
            onPressed: () => _drawerController.toggle(),
          ),
        ),
        body: const Center(child: Text('Swipe right or tap menu icon')),
      ),
    );
  }
}
1
likes
160
points
343
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A customizable swipeable drawer layout widget for Flutter supporting 4-way swipe directions and programmatic control.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on swipeable_drawer_layout