55 Widget
build(BuildContext context) {
56 final Color primaryColor = widget.
primaryColor ?? Theme.of(context).primaryColor;
57 final Color textColor = widget.textColor ?? Colors.white;
58 final double borderRadius = widget.borderRadius ?? 12.0;
61 data: Theme.of(context).copyWith(
62 popupMenuTheme: PopupMenuThemeData(
64 shape: RoundedRectangleBorder(
65 borderRadius: BorderRadius.circular(borderRadius),
69 child: PopupMenuButton<Locale>(
70 offset:
const Offset(0, 10),
71 position: PopupMenuPosition.under,
78 onSelected: (Locale locale) {
79 context.setLocale(locale);
84 padding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
85 decoration: BoxDecoration(
87 borderRadius: BorderRadius.circular(borderRadius),
90 color: primaryColor.withValues(alpha: 0.3),
92 offset:
const Offset(0, 3),
97 mainAxisSize: MainAxisSize.min,
100 Icons.language_rounded,
109 fontWeight: FontWeight.bold,
116 Icons.arrow_drop_down,
123 itemBuilder: (BuildContext context) => <PopupMenuEntry<Locale>>[
133 final bool isSelected = context.locale.languageCode == code;
135 return PopupMenuItem<Locale>(
138 padding:
const EdgeInsets.symmetric(vertical: 8),
140 mainAxisAlignment: MainAxisAlignment.spaceBetween,
149 fontWeight:
isSelected ? FontWeight.bold : FontWeight.normal,
157 padding:
const EdgeInsets.all(4),
158 decoration: BoxDecoration(
159 color: widget.primaryColor ?? Theme.of(context).primaryColor,
160 shape: BoxShape.circle,