Skip to content

Instantly share code, notes, and snippets.

Last active April 19, 2020 14:13
Show Gist options
  • Save adash333/5b089d4c58ecef7d4d950264a14d8633 to your computer and use it in GitHub Desktop.
Save adash333/5b089d4c58ecef7d4d950264a14d8633 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
Widget build(BuildContext context) {
return MaterialApp(
title: '貸し借りメモ',
home: MyHomePage(),
class MyHomePage extends StatefulWidget {
_MyHomePageState createState() => _MyHomePageState();
class _MyHomePageState extends State<MyHomePage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('リスト画面')
body: Padding(
padding: const EdgeInsets.all(8.0),
child: StreamBuilder<QuerySnapshot>(
stream: Firestore.instance.collection('kasikarimemo').snapshots(),
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (!snapshot.hasData) return const Text('Loading...');
return ListView.builder(
padding: const EdgeInsets.only(top: 10.0),
itemBuilder: (context, index) =>
Widget _buildListItem(BuildContext context, DocumentSnapshot document) {
return Card(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
leading: const Icon(,
title: Text(" 【" + (document['borrowOrLend']=="lend" ? "貸" : "借") + "】" + document['stuff']),
subtitle: Text('期限:' + DateTime.fromMillisecondsSinceEpoch(int.tryParse(document['date'].toString().substring(18, 28)) * 1000).toString().substring(0, 10) + "\n相手:" + document['user']),
<!DOCTYPE html>
<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description" content="A new Flutter project.">
<!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="flutter_firestore_kasikari2">
<link rel="apple-touch-icon" href="/icons/Icon-192.png">
<link rel="manifest" href="/manifest.json">
<!-- This script installs service_worker.js to provide PWA functionality to
application. For more information, see: -->
if ('serviceWorker' in navigator) {
window.addEventListener('load', function () {
<script src=""></script>
<script src=""></script>
// TODO: Replace the following with your app's Firebase project configuration.
// See:
// "apiKey: ..." のところは、上記のFirebaseのご自身のapiKeyなどに書き換えてください。
var firebaseConfig = {
apiKey: "...",
authDomain: "[YOUR_PROJECT]",
databaseURL: "https://[YOUR_PROJECT]",
projectId: "[YOUR_PROJECT]",
storageBucket: "[YOUR_PROJECT]",
messagingSenderId: "...",
appId: "1:...:web:...",
measurementId: "G-..."
// Initialize Firebase
<script src="main.dart.js" type="application/javascript"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment