I'm working on a Flutter app and trying to replicate a Figma design for a container with an angular (conic) gradient border. Despite multiple attempts, I can't achieve the exact look specified in the Figma design. Below are the details of the Figma specs, my current code, and the issue I'm facing.
Figma Specifications Container Dimensions:
Width: 176px Height: 65px Border Radius: 16px Gradient Border: Border Width: 1px Border Style: Solid Border Image Source: conic-gradient(from 90deg at 50% 50%, rgba(255, 255, 255, 0) -37.26deg, #FFFFFF 50.99deg, rgba(255, 255, 255, 0) 143.54deg, #FFFFFF 235.25deg, rgba(255, 255, 255, 0) 322.74deg, #FFFFFF 410.99deg) Angle: 0 deg Opacity: 1 Backdrop Filter: Blur(5px) My Current Code Below is the Flutter code I tried to replicate the design:
import 'dart:math' as math; import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:gradient_borders/gradient_borders.dart'; import 'package:luma_active/core/responsive.dart'; class FrostedConicBox extends StatelessWidget { final String imagePath; final String label; const FrostedConicBox({ super.key, required this.imagePath, required this.label, }); @override Widget build(BuildContext context) { return ClipRRect( borderRadius: BorderRadius.circular(16), child: BackdropFilter( filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5), child: Container( width: ResponsiveHelper.wp(context, 176), height: ResponsiveHelper.hp(context, 65), padding: const EdgeInsets.symmetric(horizontal: 12), decoration: BoxDecoration( color: Colors.white.withOpacity(0.1), borderRadius: BorderRadius.circular(16), border: GradientBoxBorder( width: 1, gradient: SweepGradient( center: Alignment.center, startAngle: 0, endAngle: 2 * math.pi, tileMode: TileMode.clamp, colors: [ Colors.white.withOpacity(1.0), // 1st stop: 14% #FFFFFF 100% Colors.white.withOpacity(0.0), // 2nd stop: 40% #FFFFFF 0% Colors.white.withOpacity(1.0), // 3rd stop: 65% #FFFFFF 100% Colors.white.withOpacity(0.0), // 4th stop: 90% #FFFFFF 0% Colors.white.withOpacity(1.0), // wrap to start for smoothness ], stops: const [ 0.14, // 14% 0.40, // 40% 0.65, // 65% 0.90, // 90% 1.0, // wrap ], ), ), ), child: Row( children: [ ClipRRect( borderRadius: BorderRadius.circular(8), child: Image.asset( imagePath, width: 45, height: 45, fit: BoxFit.cover, ), ), const SizedBox(width: 10), Expanded( child: Text( label, style: const TextStyle( color: Colors.white, fontWeight: FontWeight.w600, fontSize: 15, ), overflow: TextOverflow.ellipsis, ), ), ], ), ), ), ); } } Flutter's Border or BoxDecoration doesn't seem to support conic gradients natively. I tried using LinearGradient and RadialGradient, but they don't match the angular gradient effect from Figma.
