닫을 수있는 위젯을 추가하려는 목록보기가 있습니다. 클릭하면 목록보기의 항목이 사라지기를 원합니다. 또한 목록의 모든 요소가 끝나면 전체 목록의 제목을 제거하고 싶습니다. Dismissible 위젯이나 다른 위젯으로 ListTile을 사라지게 할 수 있습니까?
이것은 내 목록보기의 코드입니다.
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.only(left: 12.0),
child: Container(
child: Text(
'New User Tasks',
style: TextStyle(
fontSize: 26.0,
fontWeight: FontWeight.w600,
fontFamily: "Netflix",
color: Colors.orange,
),
),
),
)),
SliverFixedExtentList(
itemExtent: 80.0,
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
Divider(
color: Colors.orange,
height: 7.0,
);
ChatModel _model = ChatModel.dummyData[index];
return Container(
alignment: Alignment.center,
color: Colors.transparent,
child: GestureDetector(
onTap: () {
if (index == 0) {
print('Hello');
}
if (index == 1) {
print('Helyyylo');
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SettingsView(),
),
);
}
if (index == 2) {
print('Heooooo');
}
},
child: Column(
children: <Widget>[
Divider(
height: 4.0,
),
ListTile(
leading: ClipRRect(
borderRadius: BorderRadius.circular(12.0),
child: Container(
// height:80,
// width:30,
child: Image.asset(_model.imagePath),
),
),
title: Row(
children: <Widget>[
Text(
_model.name,
style: TextStyle(
fontSize: 17.0,
fontWeight: FontWeight.w600,
fontFamily: "Netflix",
color: Colors.orange,
),
),
SizedBox(
width: 16.0,
),
],
),
subtitle: Text(
_model.message,
style: TextStyle(
fontSize: 15.0,
fontFamily: "Netflix",
),
),
),
],
),
),
);
},
childCount: 3,
),
),
어디:
class ChatModel {
final String imagePath;
final String name;
final String datetime;
final String message;
ChatModel({this.imagePath, this.name, this.datetime, this.message});
static final List<ChatModel> dummyData = [
ChatModel(
imagePath: 'assets/app/star1.jpg',
name: "Rate Us",
datetime: "20:18",
message: "I love the app",
),
ChatModel(
imagePath: 'assets/app/test.jpg',
name: "Invite Code",
datetime: "19:22",
message: "I love that idea, it's great!",
),
ChatModel(
imagePath: 'assets/app/share1.png',
name: "First Poll Reward",
datetime: "14:34",
message: "I wasn't aware of that. Let me check",
),
}
탭에서 항목을 제거하십시오.
onTap: () {
setState((){
ChatModel.dummyData.removeAt(index);
});
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다