Files
blinds_flutter/lib/BlindMasterResources/timezone_picker.dart
2026-03-21 20:30:37 -05:00

50 lines
1.5 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/material.dart';
const List<Map<String, String>> kTimezones = [
{'display': 'Eastern Time (ET)', 'tz': 'America/New_York'},
{'display': 'Central Time (CT)', 'tz': 'America/Chicago'},
{'display': 'Mountain Time (MT)', 'tz': 'America/Denver'},
{'display': 'Mountain Time Arizona (no DST)', 'tz': 'America/Phoenix'},
{'display': 'Pacific Time (PT)', 'tz': 'America/Los_Angeles'},
{'display': 'Alaska Time (AKT)', 'tz': 'America/Anchorage'},
{'display': 'Hawaii Time (HT)', 'tz': 'Pacific/Honolulu'},
{'display': 'UTC', 'tz': 'UTC'},
];
class TimezonePicker extends StatelessWidget {
const TimezonePicker({
super.key,
required this.value,
required this.onChanged,
this.label = 'Timezone',
});
final String? value;
final ValueChanged<String?> onChanged;
final String label;
@override
Widget build(BuildContext context) {
return InputDecorator(
decoration: InputDecoration(
labelText: label,
border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)),
contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
),
child: DropdownButton<String>(
value: value,
hint: const Text('Select timezone'),
isExpanded: true,
underline: const SizedBox.shrink(),
items: kTimezones
.map((tz) => DropdownMenuItem(
value: tz['tz'],
child: Text(tz['display']!),
))
.toList(),
onChanged: onChanged,
),
);
}
}