Drawer
In ProgressDark modeRTLA bottom sheet drawer that slides up from the bottom.
Installation
Copy the component into your project using the CLI:
$ronakcn add drawer
Usage
Import and use the component in your Flutter widget tree:
lib/pages/example.dart
import 'package:flutter/material.dart';
import '../components/drawer/drawer.dart';
class ExamplePage extends StatelessWidget {
const ExamplePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('RcnDrawer Example')),
body: Center(
child: RcnDrawer(
// Configure props here
),
),
);
}
}Variants
Drawer ships with the following variants:
default
A bottom sheet drawer.
from-right
Drawer sliding from the right.
fullscreen
A full-screen drawer.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
child* | Widget | — | Content inside the drawer. |
isOpen | bool | false | Whether the drawer is open. |
onClose | VoidCallback? | null | Called when the drawer closes. |
side | DrawerSide | DrawerSide.bottom | Side from which the drawer slides in. |
Source files
lib/components/ui/drawer.dart
import 'package:flutter/material.dart';
enum DrawerSide { bottom, right, left }
class RcnDrawer extends StatelessWidget {
const RcnDrawer({super.key, required this.child, this.isOpen = false, this.onClose, this.side = DrawerSide.bottom});
final Widget child;
final bool isOpen;
final VoidCallback? onClose;
final DrawerSide side;
static Future<void> show(BuildContext context, {required Widget child, DrawerSide side = DrawerSide.bottom}) {
return showModalBottomSheet(
context: context,
isScrollControlled: true,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(20))),
builder: (_) => child,
);
}
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: const BorderRadius.vertical(top: Radius.circular(20)),
),
child: Column(mainAxisSize: MainAxisSize.min, children: [
Container(width: 40, height: 4, margin: const EdgeInsets.only(bottom: 20),
decoration: BoxDecoration(color: Theme.of(context).colorScheme.outline.withOpacity(0.3), borderRadius: BorderRadius.circular(9999))),
child,
]),
);
}
}Version
0.1.0 · feedback category