smart_seat_selector 0.0.7
smart_seat_selector: ^0.0.7 copied to clipboard
A universal grid-based seat selection widget for Flutter supporting Cinemas, Buses, Flights, and Event halls with zoom and pan interaction.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:smart_seat_selector/smart_seat_selector.dart';
void main() {
runApp(const MaterialApp(home: UniversalSeatExample()));
}
class UniversalSeatExample extends StatefulWidget {
const UniversalSeatExample({super.key});
@override
State<UniversalSeatExample> createState() => _UniversalSeatExampleState();
}
class _UniversalSeatExampleState extends State<UniversalSeatExample> {
// 0 = Gap, 1 = Available, 2 = Booked, 3 = Disabled
final List<List<int>> _cinemaGrid = [
[1, 1, 1, 0, 0, 1, 1, 1],
[1, 1, 1, 0, 0, 1, 1, 1],
[1, 1, 1, 0, 0, 2, 2, 3],
];
late SeatController _controller;
@override
void initState() {
super.initState();
_controller = SeatController(
seatGrid: _cinemaGrid,
maxSelection: 3,
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("Cinema Selection")),
body: Center(
child: SeatLayout(
controller: _controller,
seatConfig: SeatLayoutConfig(
seatSize: 30,
selectedColor: Colors.red,
disabledColor: Colors.grey.withOpacity(0.3),
),
// OPTION 1: CINEMA SCREEN
headerWidget: Container(
height: 40,
width: 300,
decoration: BoxDecoration(
color: Colors.grey[300],
borderRadius:
const BorderRadius.vertical(bottom: Radius.circular(100)),
border:
const Border(top: BorderSide(color: Colors.grey, width: 4)),
),
alignment: Alignment.center,
child: const Text("SCREEN", style: TextStyle(letterSpacing: 3)),
),
onSeatStateChanged: (selectedSeats) {
final labels =
selectedSeats.map((e) => "Row${e.row}:${e.col + 1}").join(", ");
print("Current Selection: [$labels]");
},
),
),
);
}
}