import 'package:buypeeb_mobile/models/user_listings.dart'; import 'package:buypeeb_mobile/models/yahoo_auctions_item.dart'; import 'package:flutter/material.dart'; import 'package:sprintf/sprintf.dart'; import 'package:provider/provider.dart'; import 'dart:math'; class RouteHome extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MainPage(); } } class MainPage extends StatefulWidget { @override _MainPageState createState() => _MainPageState(); } class _MainPageState extends State { final _items = []; final _rng = new Random(); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text("Buypeeb"), actions: [ IconButton( icon: Icon(Icons.search), onPressed: () => null, tooltip: "Search", ), IconButton( icon: Icon(Icons.list), onPressed: () => null, tooltip: "Filter", ), IconButton( icon: Icon(Icons.settings), onPressed: () => null, tooltip: "Settings", ) ]), body: _buildAuctionListings(), ); } Widget _buildAuctionListings() { var listings = context.watch(); return ListView.separated( padding: EdgeInsets.all(8.0), separatorBuilder: (context, i) => Divider(), itemCount: listings.items.length, itemBuilder: (context, i) { String key = listings.items.keys.elementAt(i); return ListTile( title: Text(listings.items[key].name), subtitle: Text(sprintf( "¥%d (≈\$%2.2f)", [listings.items[key].price, listings.items[key].getLocalPrice()] )), onTap: () { Navigator.pushNamed( context, '/view_listing', arguments: key ); } ); } ); } }