【发布时间】:2020-09-07 08:27:41
【问题描述】:
我有一个 ReorderableListView,其中包含 Containers 我的问题是,为了更漂亮(在我看来),我的容器有圆角,并且它们不占用全宽(我在列表中添加了填充) em>。
问题是,当我LongPress 对一个元素重新排序时,它会自动给它我容器的宽度,忽略填充,然后放置我的容器周围有阴影 (在我的情况下这很丑)
我想做什么:
我尝试将 ReorderableListView 包装在一个容器中,并在该容器中放置一个填充而不是 ReorderableListView。但是我的容器有阴影,这样做会导致裁剪阴影。
复制步骤:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(home: MyHomePage());
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
child: ReorderableListView(
padding: EdgeInsets.only(top: 100, left: 15, right: 15),
onReorder: (oldIndex, newIndex) => {},
children: <Widget>[
Container(
key: ValueKey("1"),
height: 80,
margin: EdgeInsets.only(bottom: 15.0),
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.circular(16.0),
boxShadow: <BoxShadow>[
BoxShadow(
color: Colors.black12,
offset: Offset(1.0, 10.0),
blurRadius: 10.0
)
]
)
)
],
),
),
);
}
}
【问题讨论】:
标签: flutter dart flutter-widget reorderable-list