Skip to content

Instantly share code, notes, and snippets.

@ryanlid
Created Feb 16, 2020
Embed
What would you like to do?
Opacity 透明度
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
title: "Opacity不透明度示例",
home: LayoutDemo(),
),
);
}
class LayoutDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Opaxity 不透明度示例"),
),
body: Center(
child: Opacity(
opacity: 0.3, // 不透明度值 设置为0.3
child: Container(
width: 250.0,
height: 100.0,
decoration: BoxDecoration(
color: Colors.black, // 背景色设置为纯黑
),
child: Text(
"不透明度0.3",
style: TextStyle(
color: Colors.white,
fontSize: 28.0,
),
),
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment