title: Null check operator used on a null value - StaggeredGridView
body: <p>I'm working on a <strong>'Notes'</strong> app.</p>
  <p>So far, it has a <strong><code>HomeScreen()</code></strong> and <strong><code>Note()</code></strong> widget. The first is the screen where the notes are to be displayed and the second is a custom widget which is inflated by the way the notes are going to be displayed. I'm using <strong><code>Card()</code></strong> to display each note.</p>
  <p>To dynamically set the sizes of the Cards, I'm using <code>StaggeredGridView</code>.</p>
  <p>Here's my code.. <strong><code>notesList</code></strong> is the array of notes.</p>
  <pre><code>import 'package:flutter/material.dart';
  import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
  import 'package:get_it/get_it.dart';
  
  import '../models/notes_list.dart';
  import '../services/notes_service.dart';
  import '../note.dart';
  import './add_note_screen.dart';
  
  class HomeScreen extends StatefulWidget {
    @override
    _HomeScreenState createState() =&gt; _HomeScreenState();
  }
  
  class _HomeScreenState extends State&lt;HomeScreen&gt; {
    NotesService get service =&gt; GetIt.I&lt;NotesService&gt;();
    List&lt;NotesList&gt; notesList = [];
  
    @override
    void initState() {
      notesList = service.getNotes();
      super.initState();
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: notesList.length == 0
            ? AppBar(title: Text('Create a Note'))
            : AppBar(title: Text('Safe')),
        body: StaggeredGridView.builder(
          padding: EdgeInsets.all(10),
          itemCount: notesList.length,
          gridDelegate: SliverStaggeredGridDelegateWithFixedCrossAxisCount(
            crossAxisCount: 2,
            staggeredTileBuilder: (index) =&gt; StaggeredTile.fit(1),
          ),
          itemBuilder: (_, index) =&gt; Note(
            notesList[index].noteTitle,
            notesList[index].noteContent,
            notesList[index].noteDateTime,
          ),
        ),
        floatingActionButton: FloatingActionButton(
          child: Icon(Icons.add),
          onPressed: () =&gt; Navigator.push(
              context, MaterialPageRoute(builder: (_) =&gt; AddNoteScreen())),
        ),
        floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
      );
    }
  }
  </code></pre>
  <p>I want to display only 2 notes across the screen and with the help of above code, I'm able to achieve that.</p>
  <p>One problem I was already facing was that the <strong><code>StaggeredGridView</code></strong> was scrolling infinitely. My actual work today was to solve this issue. However, I stumbled upon a new issue and that's</p>
  <blockquote>
  <p>Null check operator used on a null value</p>
  </blockquote>
  <p>My debug console points to the StaggeredGridView as the source of this error. I'm trying to find a solution, only I couldn't.</p>
  <p>Here's the error stack trace.</p>
  <pre><code>The following assertion was thrown during performLayout():
  'package:flutter_staggered_grid_view/src/rendering/sliver_variable_size_box_adaptor.dart': Failed assertion: line 365 pos 12: 'child != null': is not true.
  
  The relevant error-causing widget was
  SliverStaggeredGrid
  ..\…\widgets\staggered_grid_view.dart:506
  When the exception was thrown, this was the stack
  #2      RenderSliverVariableSizeBoxAdaptor.paintExtentOf
  package:flutter_staggered_grid_view/…/rendering/sliver_variable_size_box_adaptor.dart:365
  #3      RenderSliverStaggeredGrid.performLayout
  package:flutter_staggered_grid_view/…/rendering/sliver_staggered_grid.dart:317
  #4      RenderObject.layout
  package:flutter/…/rendering/object.dart:1777
  #5      RenderSliverEdgeInsetsPadding.performLayout
  package:flutter/…/rendering/sliver_padding.dart:132
  #6      RenderSliverPadding.performLayout
  package:flutter/…/rendering/sliver_padding.dart:371
  </code></pre>