有人可以启动一个快速的扑动项目,并用以下内容替换main.dart,看看我做错了什么?我试图在ListView中拖放工作。
我甚至不确定这是正确的做法,所以如果没有,请告诉我。
我现在得到的错误是:
抛出了另一个异常:' package:flutter / src / rendering / box.dart':失败断言:第1446行pos 12:' hasSize':不是真的。
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
final title = 'Basic List';
var tile1 = new Material(child:
new ListTile(
leading: new Icon(Icons.photo),
title: new Text('Row 1'),
trailing: new Icon(Icons.reorder),
));
var tile2 = new Material(
child:
new ListTile(
leading: new Icon(Icons.photo),
title: new Text('Row 2'),
trailing: new Icon(Icons.reorder),
));
return new MaterialApp(
title: title,
home: new Scaffold(
appBar: new AppBar(
title: new Text(title),
),
body:
new GestureDetector(
onVerticalDragStart: startDrag,
onVerticalDragEnd: endDrag,
child: new ListView(
shrinkWrap: true,
children: [
new Flex (
children: <Widget>[
new Flexible(
child: new Draggable(child: tile1, feedback:
tile1),
),
new Flexible(
child: new Draggable(child: tile2, feedback:
tile2),
),
],
direction: Axis.vertical,
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
),
],
),
),
),
);
}
void startDrag(DragStartDetails event) {}
void endDrag(DragEndDetails event) {}
}
由于
答案 0 :(得分:1)
在@Darky解决问题hasSize问题的过程中有一点帮助,这里是完成的可排序ListView示例:
https://github.com/marchampson/FluterSortableListView
connect = irc:connect("irc.chat.twitch.tv", 6667)