ModalBarrier
ModalBarrier
是一个静态蒙层控件,ModalRoute
控件就是间接使用的此控件。
- 构造函数
const ModalBarrier({
super.key,
this.color,
this.dismissible = true, //是否可点击
this.onDismiss,
this.semanticsLabel,
this.barrierSemanticsDismissible = true,
});
例子:
import 'package:flutter/material.dart';
class ModalBarrierPage extends StatelessWidget {
const ModalBarrierPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('ModalBarrier'),),
body: Stack(
children: const [
Opacity(
opacity: 0.3,
child: ModalBarrier(
dismissible: true,
color: Colors.black87,
),
),
Center(child: Text('Hello'),)
],
),
);
}
}