50 lines
1.5 KiB
Dart
50 lines
1.5 KiB
Dart
|
|
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,
|
|||
|
|
),
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
}
|