smart_seat_selector 0.0.3
smart_seat_selector: ^0.0.3 copied to clipboard
A universal grid-based seat selection widget for Flutter supporting Cinemas, Buses, Flights, and Event halls with zoom and pan interaction.
Smart Seat Selector #
A universal grid-based seat selection widget for Flutter supporting Cinemas, Buses, Flights, and Event halls with zoom and pan interaction.
Features #
- 🎥 Universal Support: Works for Cinemas (Screens), Buses (Drivers), and Events (Stages).
- 👆 Interactive: Built-in Zoom & Pan (InteractiveViewer) for large seat maps.
- 🎨 Highly Customizable: Control colors, sizing, gap spacing, and selection limits.
- 🧠 Smart Logic: Automatically prevents selecting booked seats, aisles, or disabled seats.
- 📱 Responsive: Grid adapts to the data you pass.
Installation #
Add this to your pubspec.yaml:
dependencies:
smart_seat_selector: ^0.0.1
Usage #
Import the package in your Dart code:
import 'package:smart_seat_selector/smart_seat_selector.dart';
1. Basic Implementation #
To display a seat layout, use the SeatLayout widget. You need to
provide the dimensions and the initial state of the seats.
SeatLayout(
rowCount: 10,
colCount: 4,
seatConfig: SeatConfig(
selectedColor: Colors.green,
bookedColor: Colors.grey,
availableColor: Colors.white,
),
onSeatSelected: (row, col) {
print("User clicked seat at Row $row, Col $col");
},
)
2. Using the Controller #
Use SeatController to manage selections programmatically (e.g., to get
the final list of selected seats for checkout).
// 1. Create the controller
final SeatController controller = SeatController();
// 2. Attach it to the widget
SeatLayout(
controller: controller,
rowCount: 10,
colCount: 4,
// ...
)
// 3. Access data later
void performBooking() {
List<SeatState> selected = controller.getSelectedSeats();
print("Booking ${selected.length} seats...");
}
Customization #
You can fully customize the look and feel to match your app theme using the SeatConfig class.
| Property | Type | Description |
|---|---|---|
selectedColor |
Color |
Color of seats when clicked by user |
bookedColor |
Color |
Color of seats that are already taken |
gapColor |
Color |
Usually transparent, defines the aisle color |
seatSize |
Size |
The dimension of a single seat box |
pathDisabled |
bool |
Set to true to disable path drawing for aisles |
License #
This project is licensed under the MIT License - see the LICENSE file for details.