Skip to content

Instantly share code, notes, and snippets.

@ryanlid
Created February 16, 2020 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanlid/f9b4fb12e9461dd9cb45902108bb8337 to your computer and use it in GitHub Desktop.
Save ryanlid/f9b4fb12e9461dd9cb45902108bb8337 to your computer and use it in GitHub Desktop.
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