Search code examples
flutterflutter-widgetflutter-futurebuilder

Exception caught by widgets library 'package:flutter/src/widgets/sliver.dart': Failed assertion: line 543 pos 15: 'children != null': is not true


My all future builder occure error How can i solve ....................................................................................................................................................................................................................................

════════ Exception caught by widgets library ═══════════════════════════════════════════════════════ 'package:flutter/src/widgets/sliver.dart': Failed assertion: line 543 pos 15: 'children != null': is not true. The relevant error-causing widget was: FutureBuilder file:///D:/budgram/lib/pages/NotificationsPage.dart:23:16

notificatioons.dart

Widget build(BuildContext context) {
    return Scaffold(
      appBar: header(context, strTitle: "Notifications..."),
      body: Container(
        child: FutureBuilder(
          future: retrieveNotifications(),
          builder: (context, dataSnapshot) {
            if (!dataSnapshot.hasData) {
              circularProgress();
            }
            return ListView(
              children: dataSnapshot.data,
            );
          },
        ),

Solution

  • This

    circularProgress();
    

    needs to be

    return circularProgress();
    

    otherwise the flow will just continue and hit the line with the listview, even if the future has not completed yet.