import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; class SettingsSection extends StatelessWidget { final String title; final List items; const SettingsSection({Key? key, required this.title, required this.items}) : super(key: key); @override Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.all(8.0), child: Text( title, style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.black), ), ), ...items.map((item) => _buildItem(item)).toList(), ], ); } Widget _buildItem(SettingsItem item) { return ExpansionTile( title: Text(item.title), children: [ ListTile( title: Text(item.detail), trailing: item.url != null ? GestureDetector( child: Text( item.trailingText ?? "", style: const TextStyle(color: Colors.grey), ), onTap: () => _launchURL(Uri.parse(item.url!)), ) : null, onTap: item.onTap, ), ], ); } void _launchURL(Uri url) async { if (await canLaunchUrl(url)) { await launchUrl(url); } else { if (kDebugMode) { print("Could not launch $url"); } } } } class SettingsItem { final String title; final String detail; final String? trailingText; final String? url; final VoidCallback? onTap; SettingsItem({ required this.title, this.detail = '', this.trailingText, this.url, this.onTap, }); }