flutter之不透明控件Opacity

时间:2024-05-22 14:52:11

Opacity控件能调整子控件的不透明度,使子控件部分透明,不透明度的量从0.0到1.0之间,0.0表示完全透明,1.0表示完全不透明。

 Opacity的用法:

import 'package:flutter/material.dart';
class OpactiyDemo extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text("透明度控件"),
      ),
      body: new Center(
        child: new Opacity(
            opacity: 0.1,
          child: new Container(
            height: 100.0,
            width: 250.0,
            color: Colors.red,
          ),
        ),
      )
    );
  }
}
void main(){
  runApp(new MaterialApp(
    title: "透明度控件",
    home: new OpactiyDemo(),
  ));
}

 

效果:

flutter之不透明控件Opacity