【发布时间】:2020-08-16 09:16:33
【问题描述】:
我正在使用 here 记录的 SlidingUpPanel 小部件。
当我使用 header 属性并将其设置为 TextField 小部件时,面板不再上下滑动,而是保持折叠状态。
页面的完整代码如下:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:sliding_up_panel/sliding_up_panel.dart';
class HomePage extends StatefulWidget {
HomePage();
@override
_HomePageState createState() => new _HomePageState();
}
class _HomePageState extends State<HomePage> {
_HomePageState();
Widget _buildSuggestions() {
List<myObject> myObjects = _getRecentmyObjects();
return new ListView.builder(
itemCount: myObjects.length,
itemBuilder: (context, index) {
return Card(
elevation: 2,
child: ListTile(
title: Text(myObjects[index].firstLine),
subtitle: Text(
myObjects[index].secondLine + "," + myObjects[index].thirdLine,
maxLines: 2,
),
),
);
});
}
List<myObject> _getmyObjects() {
return [
new myObject(
firstLine: "This is",
secondLine: "one element ",
thirdLine: "of a list of items",
aNumber: "00000"),
new myObject(
firstLine: "This is a",
secondLine: "second element of a list",
thirdLine: "",
aNumber: "00000"),
new myObject(
firstLine: "And a ", secondLine: "Third", thirdLine: "", aNumber: "000"),
];
}
PanelController _panelController = new PanelController();
@override
Widget build(BuildContext context) {
BorderRadiusGeometry radius = BorderRadius.only(
topLeft: Radius.circular(24.0),
topRight: Radius.circular(24.0),
);
return Scaffold(
body: SlidingUpPanel(
controller: _panelController,
minHeight: 80,
header: new TextField(),
panel:
child: Container(
padding: const EdgeInsets.only(top: 0),
child: Center(
child: _buildSuggestions(),
),
),
]),
body: Container(),
borderRadius: radius,
),
);
}
}
如果我删除 header 参数,小部件将按预期工作。 为什么它不会与 TextField 一起滑动?
【问题讨论】: