title: Flutter sqflite red query error using Cubit state management
body: <p>i want to build a crud application using sqlite and Flutter Cubit, the problem is that when i want to red data from my database it return an error. i test my query in console it work prefect but when i use with Listview it dos not working. i though maybe problem relate to my  Cubit implementation but it was not,this is my code:</p>
  <pre><code> database red query: 
   Future&lt;List&lt;Account&gt;&gt; redAllAccounts() async {
      final result = await db.query('account');
      return result.map((e) =&gt; Account.fromjsonAccount(e)).toList();
    } 
  
  
  
  my Cubit file: 
   import 'package:bloc/bloc.dart';
  import 'package:project/Model/account.dart';
  import 'package:project/control/database.dart';
  
  class AccountCubit extends Cubit&lt;List&lt;Account&gt;&gt; {
    AccountCubit(intistate) : super(intistate);
  
    Future getAccount() async {
      DatabaseHelper database = DatabaseHelper();
      List&lt;Account&gt; account;
  
      account = await database.redAllAccounts();
      emit(account);
    }
  }
   
  my list account file: 
   
  class AccountList extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      BlocProvider.of&lt;AccountCubit&gt;(context).getAccount();
      //  var account = BlocProvider.of&lt;AccountCubit&gt;(context).account;
      return Container(
        padding: EdgeInsets.all(20),
        child: BlocBuilder&lt;AccountCubit, List&lt;Account&gt;&gt;(
          builder: (context, state) {
            return ListView.builder(
                padding: EdgeInsets.all(20),
                itemCount: state.length,
                itemBuilder: (context, index) {
                  var acc = state[index];
                  return Column(
                    children: [
                      Text(acc.name),
                      //  Text(acc.adress),
                      TextButton(
                          onPressed: () {
                            // BlocProvider.of&lt;AccountBlock&gt;(context)
                            //     .add(AccountEvent.delete(acc.accountNumber));
                          },
                          child: Text('delete'))
                    ],
                  );
                });
  
  
  
  ***error: 
   NoSuchMethodError (NoSuchMethodError: The method 'query' was called on null.
  Receiver: null
  Tried calling: query(&quot;account&quot;))***
  </code></pre>