Getting an exception saying
_TypeError (type 'List<dynamic>' is not a subtype of type 'List<Widget>')in.toList()below.
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:student_community/app/constants/colors.dart';
import 'package:student_community/app/constants/dimensions.dart';
import 'package:student_community/core/viewmodels/video_view_model.dart';
import 'package:student_community/meta/widgets/loading_widget.dart';
class VideoView extends StatelessWidget {
final ScrollController scrollController = ScrollController();
@override
Widget build(BuildContext context) {
return Consumer<VideoViewModel>(
builder: (context, model, child) => Scaffold(
resizeToAvoidBottomInset: true,
backgroundColor: bgColor,
body: StreamBuilder<QuerySnapshot>(
stream: model.streamOfVideos(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return loadingWidget();
} else {
return listOfVideos(snapshot, context);
}
},
),
));
}
Widget listOfVideos(dynamic querySnapshot, BuildContext context) {
return Scrollbar(
controller: scrollController,
isAlwaysShown: false,
child: ListView(
children: querySnapshot.data.docs
.map((DocumentSnapshot documentSnapshot) =>
blockOfVideo(context, documentSnapshot))
.toList(),
),
);
}
Widget blockOfVideo(BuildContext context, DocumentSnapshot documentSnapshot) {
return GestureDetector(
onTap: () {}, //Proxy provider of detailed screen,
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Stack(
children: [
Container(
height: MediaQuery.of(context).size.height * 0.3,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(
documentSnapshot.data()['thumbnail']))),
),
Positioned(
top: 195,
left: 355,
child: Container(
child: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
documentSnapshot.data()['length'],
style: TextStyle(
color: whiteColor, fontWeight: FontWeight.bold),
),
),
),
decoration: BoxDecoration(
color: darkColor,
borderRadius: BorderRadius.circular(4.0)),
))
],
),
Row(
children: [
CircleAvatar(
backgroundImage:
NetworkImage(documentSnapshot.data()['userimage']),
),
hSizedBox2,
Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
documentSnapshot.data()['title'],
style: TextStyle(
fontSize: 20.0,
color: whiteColor,
fontWeight: FontWeight.bold),
),
Text(
documentSnapshot.data()['username'],
style: TextStyle(
fontSize: 16.0,
color: yellowColor,
fontWeight: FontWeight.bold),
)
],
),
),
Spacer(),
IconButton(
icon: Icon(
EvaIcons.moreVertical,
color: whiteColor,
),
onPressed: () {})
],
),
Divider()
],
),
),
);
}
}
raina77owit fixed my problem.