в моем вызывающем приложении я получаю данные истории вызовов из моей базы данных sqlite, приведенной ниже, это функция
List<HistoryRecord> historyRecords;
void getData(String argv) async {
queryRows = [];
historyRecords=null;
List<Map<String, dynamic>> ok =
await DatabaseHelper.instance.getAllLogsByGroup(argv);
setState(() {
queryRows = ok;
historyRecords=List<HistoryRecord>.from(
queryRows.map((row) => HistoryRecord.fromJson(row)));
});
}
Ниже приведен мой виджет
StreamBuilder(
stream: historyRecords.asStream(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return ListView.builder(
shrinkWrap: true,
itemCount: snapshot.data.length,
itemBuilder: (context, index) {
return snapshot.data[index].displayName != null
? ListTile(
onTap: () async {
Position position = (await Geolocator
.getCurrentPosition(
desiredAccuracy:
LocationAccuracy.high));
var number = snapshot
.data[index].callHistoryNumber;
number = number.startsWith("+92")
? "0" + number.substring(3)
: number;
print("Number Is " + number);
await platform
.invokeMethod("callMazay", {
"number": number,
"lat": position.latitude.toString(),
"long": position.longitude.toString()
});
},
leading: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
gradient: snapshot
.data[index].avatar ==
null
? LinearGradient(
colors: [
Colors.red,
Colors.black12
],
begin:
Alignment.bottomLeft,
end: Alignment.topRight)
: null),
child: snapshot.data[index].avatar ==
null
? CircleAvatar(
backgroundImage: AssetImage(
'assets/images/user.png'),
)
: CircleAvatar(
backgroundImage: AssetImage(
'assets/images/user.png')
/*bckgroundImage: MemoryImage(
snapshot.dataa[index].avatar,scale: 0.1),*/
)),
trailing: Padding(
padding: const EdgeInsets.all(10.0),
child: Builder(
builder: (context) {
if (snapshot.data[index]
.callHistoryType ==
'MISSED') {
return Wrap(
children: [
Padding(
padding: const EdgeInsets.only(bottom:8.0,right: 12.0),
child: Icon(Icons.call_missed,
color: Colors.red),
),
Padding(
padding:
const EdgeInsets.only(
bottom: 8.0),
child: Column(
children: [
Icon(Icons.info_outline,
color: Colors.red),
],
),
)
],
);
} else if (snapshot.data[index]
.callHistoryType ==
'RECEIVED') {
/*Column(
children: [
Icon(Icons.info_outline,
color: Colors.red)
],
);*/
return Wrap(
children: [
Padding(
padding: const EdgeInsets.only(bottom:8.0,right: 12.0),
child: Icon(Icons.call_received,
color: Colors.green),
),
Padding(
padding:
const EdgeInsets.only(
bottom: 8.0),
child: Column(
children: [
Icon(Icons.info_outline,
color: Colors.red),
],
),
)
],
);
} else {
/* return Column(
children: [
Icon(Icons.info_outline,
color: Colors.red)
],
);*/
return Wrap(
children: [
Padding(
padding: const EdgeInsets.only(bottom:8.0,right: 12.0),
child: Icon(Icons.call_made,
color: Colors.yellow.shade900),
),
Padding(
padding:
const EdgeInsets.only(
bottom: 8.0),
child: Column(
children: [
Icon(Icons.info_outline,
color: Colors.red),
],
),
)
],
);
}
},
),
),
title: snapshot.data[index].total_calls !=
null &&
snapshot.data[index]
.total_calls ==
1
? Text(
snapshot.data[index].displayName,
style:TextStyle(
color: snapshot.data[index].callHistoryType ==
'MISSED'?Colors.red:Colors.black,
))
: Text(snapshot
.data[index].displayName +
" ( " +
snapshot.data[index].total_calls
.toString() +
" )",style:TextStyle(
color: snapshot.data[index].callHistoryType ==
'MISSED'?Colors.red:Colors.black,
)),
subtitle: Text(
snapshot.data[index].callHistoryDatetime,
style:TextStyle(
color: snapshot.data[index].callHistoryType ==
'MISSED'?Colors.red:Colors.black,
)
),
)
: null;
},
);
} else {
return Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SpinKitRing(
color: Colors.red,
size: 50.0,
),
Text("Loading...")
],
)
],
),
);
}
},
),
Я вызываю getData () в функциях initState () и didChangeAppLifecycleState (состояние AppLifecycleState) соответственно, но всякий раз, когда я делаю вызов и завершаю вызов, эта страница возобновляется, запись добавляется в мою базу данных, но не отражается в моем streamBuilder