FlatButton(onPressed: () async {
List<Map<String, dynamic>> queryRow = await
DatabaseHelper.instance.queryAll(); print(queryRow);},
child: Text('query'), color: Colors.green[400]),
上記はコードで、コンソールに出力できます。queryRow の結果をリストとして新しい画面に出力するにはどうすればよいですか? どうぞよろしくお願いいたします。
以下は、コンソールに出力したデータです。
[{_id: 1, name: John}, {_id: 2, name: Hans}, {_id: 3, name: Carol}]
お気に入りページ
import 'package:flutter/material.dart';
class FavoritesPage extends StatelessWidget {
static String id = 'favoritesPage';
@override
Widget build(BuildContext context) {
var queryRow;
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
shadowColor: Colors.transparent,
iconTheme: IconThemeData(color: Colors.orange),
centerTitle: true,
title: const Text('Favorites', style: TextStyle(color: Colors.orange)),
elevation: 0,
),
body: ListView.builder(
itemCount: queryRow.length,
itemBuilder: (context, index) {
return ListTile(
title: Text("${queryRow[index]["name"]} - ID: ${queryRow[index]["id"]}"),
);
},
),
);
}
}