Some checks are pending
Flutter CI / build (push) Waiting to run
Co-authored-by: aider (ollama_chat/7b) <aider@aider.chat>
35 lines
1.1 KiB
Dart
35 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'product_provider.dart';
|
|
|
|
class ProductListScreen extends StatelessWidget {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final productProvider = Provider.of<ProductProvider>(context);
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text('商品一覧'),
|
|
),
|
|
body: FutureBuilder<void>(
|
|
future: productProvider.fetchProducts(),
|
|
builder: (context, snapshot) {
|
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
|
return Center(child: CircularProgressIndicator());
|
|
} else {
|
|
return ListView.builder(
|
|
itemCount: productProvider.products.length,
|
|
itemBuilder: (context, index) {
|
|
final product = productProvider.products[index];
|
|
return ListTile(
|
|
title: Text(product.name),
|
|
subtitle: Text('単価: ${product.unitPrice}, 値引き: ${product.discount}'),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|