From 5526ab2d6a5c18cdbb8fb6c50e284dad24ba56eb Mon Sep 17 00:00:00 2001 From: zhangmeng1334717033 Date: Thu, 11 Jun 2020 09:51:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=99=BB=E9=99=86=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/chatting_build_page.dart | 20 ++++++++++++-------- lib/chatting_page.dart | 9 ++++++++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/lib/chatting_build_page.dart b/lib/chatting_build_page.dart index eb715e0..79123bc 100644 --- a/lib/chatting_build_page.dart +++ b/lib/chatting_build_page.dart @@ -19,11 +19,15 @@ class _ChattingDetailsPageState extends State { void initState() { super.initState(); getChattingfriednList(); + print(11111); } getChattingfriednList() async { List messageList = await chattingApi.getChattingList(); - messageData.addAll(messageList); + setState(() { + messageData.addAll(messageList); + print(messageData); + }); } @override @@ -32,13 +36,13 @@ class _ChattingDetailsPageState extends State { return Scaffold( //构造列表 body: ListView.builder( - //传入长度 - itemCount: messageData.length, - //构造列表项 - itemBuilder: (BuildContext context, int index) { - //传入 messageData 返回 表项 - return new ChattingItemPage(messageData[index]); - }, + //传入长度 + itemCount: messageData.length, + //构造列表项 + itemBuilder: (BuildContext context, int index) { + //传入 messageData 返回 表项 + return new ChattingItemPage(messageData[index]); + }, ), ); } diff --git a/lib/chatting_page.dart b/lib/chatting_page.dart index dab2234..2070460 100644 --- a/lib/chatting_page.dart +++ b/lib/chatting_page.dart @@ -35,6 +35,7 @@ class _ChattingPageState extends State { @override Widget build(BuildContext context) { + return Scaffold( appBar: AppBar( title: Text("微信"), @@ -72,7 +73,13 @@ class _ChattingPageState extends State { )) ], ), - body: ChattingBuildPage() + body: ChattingBuildPage(), ); } + + @override + void initState() { + super.initState(); + chattingApi.getChattingList(); + } }