title: Flutter - Sending SQL data to a ListView
body: <p>Using the flutter package <a href="https://pub.dartlang.org/packages/sqflite" rel="nofollow noreferrer">sqflite</a> I've managed to save data from a news source to a database, such as <code>title</code>, <code>description</code> and more.</p>
  
  <p>Please take the time to look at this application created <a href="https://drive.google.com/open?id=1MUjDq78avRF05l5nJDben5dwPne4Clcw" rel="nofollow noreferrer">database file</a> that follows my structure.</p>
  
  <p>This is how I create the database, and how I save data to it from an online source.</p>
  
  <pre><code>var title = articles[index].title;
  var description = articles[index].description;
  var url = articles[index].url;
  var urlToImage = articles[index].urlToImage;
  var publishedAt = articles[index].publishedAt;
  
  var databasesPath = await getDatabasesPath();
  String path = join(databasesPath, 'saved_articles.db');
  
  Database database = await openDatabase(path, version: 1,
      onCreate: (Database db, int version) async {
    // When creating the db, create the table
    await db.execute(
          'CREATE TABLE Article (id INTEGER PRIMARY KEY, title TEXT, description TEXT, url TEXT, urltoimage TEXT, publishedat TEXT)');
  });
  
  print(database);
  
  print(databasesPath);
  
  // Insert some records in a transaction
  await database.transaction((txn) async {
    int id1 = await txn.rawInsert(
      'INSERT INTO Article(title, description, url, urltoimage, publishedat) VALUES("$title", "$description", "$url", "$urlToImage", "$publishedAt")'
    );
    debugPrint('inserted1: $id1');
  
  });
  </code></pre>
  
  <p><strong>I'm looking for a method in which to send this data straight to an ordered <code>ListView</code></strong>. The end goal for this being a favourites page which saves articles to the user's device for offline viewing.</p>
  
  <p>This is how I'm retrieving specific data for converting into the bottom <code>title</code> list.</p>
  
  <pre><code>var databasesPath = await getDatabasesPath();
  String path = join(databasesPath, 'saved_articles.db');
  
  Database database = await openDatabase(path, version: 1,
      onCreate: (Database db, int version) async {
    // When creating the db, create the table
    await db.execute(
          'CREATE TABLE Article (id INTEGER PRIMARY KEY, title TEXT, description TEXT, url TEXT, urltoimage TEXT, publishedat TEXT)');
  });
  
  List&lt;Map&gt; title = await database.rawQuery('SELECT title FROM Article');
  List&lt;Map&gt; description = await database.rawQuery('SELECT description FROM Article');
  List&lt;Map&gt; url = await database.rawQuery('SELECT url FROM Article');
  </code></pre>
  
  <p>This is what I'm using to send specific queries to list, but I'm not sure where to go from here in terms of creating a viable structure for sending this data to the desired <code>ListView</code></p>
  
  <pre><code>List&lt;Map&gt; title = await database.rawQuery('SELECT title FROM Article');
  </code></pre>
  
  <p>Thanks</p>