我对扑打很陌生,我一直在尝试创建一个现代的抽屉,但我发现了一个,问题是我发现的那个抽屉quadraticBezierTo
和enddrawer
会打开抽屉从右到左,但要使用drawer
,它从左到右打开抽屉窗体。这是我的代码
Widget build(BuildContext context) {
width = MediaQuery.of(context).size.width - 50;
return MaterialApp(
home: Scaffold(
appBar: AppBar(),
drawerScrimColor: Colors.grey.shade900.withOpacity(0.5),
drawer: ClipPath(
clipper: _DrawerClipper(),
child: Drawer(
child: Container(
padding: const EdgeInsets.only(top: 48, bottom: 32),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Container(
color: Colors.blue.shade200,
child: DrawerHeader(
child:Wrap(
children:<Widget>[
Container(
alignment: Alignment.topCenter,
child: CircleAvatar(
maxRadius: 40,
child: Image.asset("assets/profile.png"),
),
),
Container(padding: EdgeInsets.fromLTRB(0, 10, 0, 0), alignment: Alignment.center,
child:Text("Name",style: TextStyle(fontSize: 20,color: Colors.white),
),
),
Container( alignment: Alignment.center,
child:Text("E-mail Address",style: TextStyle(fontSize: 20,color: Colors.white),
),
),
],
),
),
),
ListTile(
title: Center(
child: Text(
"Item1",
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
)),),],
)),),),
并且我将以下类用于clipper
:
class _DrawerClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
Path path = Path();
path.moveTo(50, 0);
path.quadraticBezierTo(0, size.height / 2, 50, size.height);
path.lineTo(size.width, size.height);
path.lineTo(size.width, 0);
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) => true;
}
这是它的外观照片:
如果我使用endDrawe
,这看起来很正常,但是我想使用drawer
。我认为它与quadraticBezierTo
参数有关,但我不确定。我怎样才能解决这个问题?
感谢您的帮助