import 'package:flutter/material.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; void main() => runApp(new MyApp()); class MyApp extends StatelessWidget { const MyApp(); @override Widget build(BuildContext context) { return new MaterialApp( title: 'Baby Names', home: const MyHomePage(title: 'Baby Name Votes'), ); } } class MyHomePage extends StatelessWidget { const MyHomePage({Key key, this.title}) : super(key: key); final String title; @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar(title: new Text(title)), body: new StreamBuilder( stream: Firestore.instance.collection('baby').snapshots(), builder: (context, snapshot) { if (!snapshot.hasData) return const Text('Loading...'); print(snapshot.data.documents); print(snapshot.hasData); print(snapshot.data.documents.length); return new ListView.builder( itemCount: snapshot.data.documents.length, padding: const EdgeInsets.only(top: 10.0), itemExtent: 25.0, itemBuilder: (context, index) { DocumentSnapshot ds = snapshot.data.documents[index]; return new Text(" ${ds['name']} ${ds['votes']}"); } ); }), ); } }
(edited)// Allow read/write access on all documents to any user signed in to the application service cloud.firestore { match /databases/{database}/documents { match /{document=**} { allow read, write: if request.auth.uid != null; } } }
Launching lib/main.dart on macOS in debug mode... --- xcodebuild: WARNING: Using the first of multiple matching destinations: { platform:macOS, arch:arm64, id:00008112-000C082E3C8B401E, name:My Mac } { platform:macOS, arch:x86_64, id:00008112-000C082E3C8B401E, name:My Mac } .../namer_app/build/macos/Build/Products/Debug/namer_app.app: replacing existing signature .../namer_app/build/macos/Build/Products/Debug/namer_app.app: resource fork, Finder information, or similar detritus not allowed Command CodeSign failed with a nonzero exit code ** BUILD FAILED ** Error: Build process failed Exited (1).
出力されたプロジェクトを確認したところ、Xcodeプロジェクトが生成されていましたので、Xcodeで開いてビルド&実行したところ、問題なく起動できました。 VSCodeからflutter SDKを通して、CodeSign コマンドを呼んだ際に、セキュリティ的な理由で制限されているのかなと予想したのですが、原因お分かりのかたはいらっしゃるでしょうか?