Created
October 9, 2025 19:12
-
-
Save hectorAguero/698ddd82d70ce1270bf9cd6af228fc45 to your computer and use it in GitHub Desktop.
ExpansionTile in Wrap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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