I'm new on Flutter and I want to add Widgets tests to my app. But I have some problems and questions about widget tests a little more complex than flutter documentation. Indeed i have a Scaffold widget with this body :
body: StreamBuilder<List<UserData>> (
stream: DatabaseService().searchUser(searchValue),
builder: (context, snapshot) {
if (snapshot.hasData && searchValue.length >= 3){
return ListView.builder(
itemCount: snapshot.data.length,
itemBuilder: (context, index) {
return ListTile(
onTap: () {
Navigator.pushReplacementNamed(context, '/friends/search/details', arguments: snapshot.data[index]);
},
title: Text(snapshot.data[index].name),
);
}
);
}
return Center();
},
)
The first question is:
Is it necessary to test this StreamBuilder?
And if yes: How can I mock the stream and test these widgets ?
Aucun commentaire:
Enregistrer un commentaire