Raf*_*san 11 dart flutter flutter-layout
我试图在活动之上创建一个透明的全屏对话框.我试过跟这个线程,但解决方案不起作用.
简而言之,我需要的是:
这是我的代码:
打开对话框
void onNextBtnClick(){
var route = new MaterialPageRoute(
builder: (BuildContext context) =>
new GenreDialogUI(),fullscreenDialog: true
);
Navigator.of(context).push(route);
}
Run Code Online (Sandbox Code Playgroud)
对话框视图
import 'package:flutter/widgets.dart';
class HolePuncherPainter extends CustomPainter {
static final clearPaint = new Paint()
..color = Colors.transparent,
..blendMode = BlendMode.clear;
const HolePuncherPainter();
@override
void paint(Canvas canvas, Size size) {
canvas.drawRect(
new Rect.fromLTWH(0.0, 0.0, size.width, size.height), clearPaint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
}
class GenreDialogUI extends StatefulWidget {
@override
_GenreDialogUI createState() => new _GenreDialogUI();
}
class _GenreDialogUI extends State<GenreDialogUI> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: addAppbar(),
body: new CustomPaint(
painter: HolePuncherPainter(),
child: new Container(
color: Colors.transparent,
alignment: Alignment.center,
child: UtilCommonWidget.addText('Transparent Dialog', Colors.red, 22.0, 1),
),
),
);
}
}
Run Code Online (Sandbox Code Playgroud)
gar*_*oke 14
Navigator.of(context).push(PageRouteBuilder(
opaque: false,
pageBuilder: (BuildContext context, _, __) {
return YourFullScreenAlertDialog()
}
));
Run Code Online (Sandbox Code Playgroud)
YourFullScreenAlertDialog可以是具有背景颜色的小部件,Colors.transparent,如前面提到的@creativecreatorormaybenot.
对我来说,以下工作:
showDialog(
context: context,
builder: (_) => Material(
type: MaterialType.transparency,
child: Center( // Aligns the container to center
child: Container( // A simplified version of dialog.
width: 100.0,
height: 56.0,
color: Colors.green,
child: Text('jojo'),
)
),
)
);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5779 次 |
最近记录: |