52 lines
1.4 KiB
Dart
52 lines
1.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class PhonePrefixSelector extends StatelessWidget {
|
|
const PhonePrefixSelector({
|
|
super.key,
|
|
required this.value,
|
|
required this.items,
|
|
this.onChanged,
|
|
});
|
|
|
|
final String value;
|
|
final List<String> items;
|
|
final ValueChanged<String>? onChanged;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
return Padding(
|
|
padding: const EdgeInsets.only(left: 12, right: 8),
|
|
child: PopupMenuButton<String>(
|
|
onSelected: onChanged,
|
|
itemBuilder: (context) => items
|
|
.map(
|
|
(item) => PopupMenuItem<String>(value: item, child: Text(item)),
|
|
)
|
|
.toList(growable: false),
|
|
color: colorScheme.surface,
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
value,
|
|
style: TextStyle(
|
|
fontSize: 15,
|
|
fontWeight: FontWeight.w500,
|
|
color: colorScheme.onSurface,
|
|
),
|
|
),
|
|
const SizedBox(width: 4),
|
|
Icon(
|
|
Icons.arrow_drop_down,
|
|
size: 18,
|
|
color: colorScheme.onSurfaceVariant,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|