xxxxxxxxxx
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// Set a custom color with opacity
Color customColor = Colors.blue.withOpacity(0.5);
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Flutter Color Opacity'),
),
body: Container(
color: customColor,
child: Center(
child: Text(
'Custom Color with Opacity',
style: TextStyle(color: Colors.white),
),
),
),
),
);
}
}
xxxxxxxxxx
Opacity(
opacity: 0.5,
child: Container(
color: Colors.red,
width: 200,
height: 200,
),
),