A build function returned null. Here is my code, how do I solve it?

class MyEvents extends StatefulWidget { static const String id = "my_events_screen";

@override _MyEventsState createState() => _MyEventsState(); }

class _MyEventsState extends State { FirebaseFirestore fireStore = FirebaseFirestore.instance;

@override Widget build(BuildContext context) { return Container( height: 0, width: 0, child: StreamBuilder( stream: fireStore.collection('events').snapshots(), builder: (context, snapshot) { if (!snapshot.hasData) { Center( child: CircularProgressIndicator( backgroundColor: Colors.lightBlueAccent, ), ); } final events = snapshot.data.docs; List eventWidgets = []; for (var event in events) { if (event.data()["publisher_id"] == email) { final eventTitle = event.data()['title']; final eventDescription = event.data()['description']; final eventLocation = event.data()['event_location']; final eventDate = event.data()['event_date']; final eventTime = event.data()['event_time']; var date = DateTime.parse(eventDate.toDate().toString()); final docId = event.id; final publisherId = event.data()['publisher_id']; final eventWidget = EventCard( onPress: () { Navigator.of(context).push( MaterialPageRoute( builder: (context) { return NewScreen(docId: docId); }, ), ); }, document: docId, title: eventTitle, publisher: publisherId, date: date, time: eventTime, location: eventLocation, description: eventDescription); eventWidgets.add(eventWidget); } }

        return Expanded(
          child: ListView(
              padding: EdgeInsets.symmetric(horizontal: 10, vertical: 20),
              children: eventWidgets),
        );
      }),
);

} }



Read more here: https://stackoverflow.com/questions/66346113/a-build-function-returned-null-here-is-my-code-how-do-i-solve-it

Content Attribution

This content was originally published by kishor chhetri at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: