container封装

2
Widget _buildNavItem(String section, IconData icon, String title) {
    final isSelected = _selectedSection == section;
    return Container(
      margin: const EdgeInsets.symmetric(vertical: 2),
      child: Material(
        color: Colors.transparent,
        child: InkWell(
          borderRadius: BorderRadius.circular(8),
          onTap: () {
            setState(() => _selectedSection = section);
            switch (section) {
              case 'storage':
                context.go(RouteConstants.settingsStorage);
                break;
              case 'general':
                context.go(RouteConstants.settingsGeneral);
                break;
              case 'appearance':
                context.go(RouteConstants.settingsAppearance);
                break;
              case 'sync':
                context.go(RouteConstants.settingsSync);
                break;
              case 'about':
                context.go(RouteConstants.settingsAbout);
                break;
              default:
                context.go(RouteConstants.settings);
            }
          },
          child: AnimatedContainer(
            duration: const Duration(milliseconds: 200),
            padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
            decoration: BoxDecoration(
              color: isSelected ? Colors.blue.shade50 : Colors.transparent,
              borderRadius: BorderRadius.circular(8),
              border: isSelected
                  ? Border.all(color: Colors.blue.shade100, width: 1)
                  : null,
            ),
            child: Row(
              children: [
                AnimatedContainer(
                  duration: const Duration(milliseconds: 200),
                  padding: const EdgeInsets.all(6),
                  decoration: BoxDecoration(
                    color: isSelected ? Colors.blue.shade100 : Colors.grey.shade100,
                    borderRadius: BorderRadius.circular(6),
                  ),
                  child: Icon(
                    icon,
                    color: isSelected ? Colors.blue.shade600 : Colors.grey.shade600,
                    size: 18,
                  ),
                ),
                const SizedBox(width: 12),
                Expanded(
                  child: Text(
                    title,
                    style: TextStyle(
                      color: isSelected ? Colors.blue.shade700 : Colors.grey.shade700,
                      fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
                      fontSize: 14,
                    ),
                  ),
                ),
                if (isSelected)
                  Icon(
                    Icons.chevron_right,
                    color: Colors.blue.shade400,
                    size: 16,
                  ),
              ],
            ),
          ),
        ),
      ),
    );
  }