i am trying to create similar squircle box on flutter like css but no option to change top-center, botom-center, left-center and right-center border. is there any workaround to do so.
no option to achieve similar results.
import 'package:flutter/material.dart';
class frostedGlassBox extends StatelessWidget {
const frostedGlassBox({super.key});
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(22), color: Colors.amber),
);
}
}
2
Answers
If you care about the shadows on the borders you could use a card like this:
If you want to align the entire
Container
within its parent widget, you can wrap theContainer
with anAlign
widget and specify the alignment within theAlign
widget. Here’s how you can do it:In this updated code, the entire
Container
is wrapped with anAlign
widget, and the alignment property within theAlign
widget is set toAlignment.center
, which will align theContainer
at the center of its parent widget. You can change the alignment value as needed (e.g.,Alignment.topLeft
,Alignment.bottomRight
, etc.).