Skip to content

Instantly share code, notes, and snippets.

@hectorAguero
Created October 9, 2025 19:12
Show Gist options
  • Select an option

  • Save hectorAguero/698ddd82d70ce1270bf9cd6af228fc45 to your computer and use it in GitHub Desktop.

Select an option

Save hectorAguero/698ddd82d70ce1270bf9cd6af228fc45 to your computer and use it in GitHub Desktop.
ExpansionTile in Wrap
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ExpansionTile(
controller: ExpansibleController(
),
title: Text('Adult'),
children: [
Text('Morning Slots'),
Wrap(
children: List.generate(
3,
(index) => TimeSlot(
isSoldOut: index.isEven,
timeString: '10:00 AM - 11:00 AM',
),
),
),
Text('Afternoon Slots'),
Wrap(
children: List.generate(
3,
(index) => TimeSlot(
isSoldOut: index.isEven,
timeString: '15:00 AM - 11:00 AM',
),
),
),
],
),
],
),
),
);
}
}
class TimeSlot extends StatefulWidget {
const TimeSlot({
super.key,
required this.isSoldOut,
required this.timeString,
});
final bool isSoldOut;
final String timeString;
@override
State<TimeSlot> createState() => _TimeSlotState();
}
class _TimeSlotState extends State<TimeSlot> {
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: widget.isSoldOut ? null : () {},
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text('10:00 AM - 11:00 AM'),
if (widget.isSoldOut)
Text('Sold Out', style: TextStyle(color: Colors.red)),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment