Im trying to create a collection of users in my flutter application.
The application has a stock collection with items which are documents and those documents, like plates or bags, has 2 fields
I create a root users collection and that collection documents which identified the used with their user ID, one document for each user ID (the one you get from FirebaseAuth).
Ive been told that I have to set the access rules in Firebase to allow to each user to have their own stock collection.
Github https://github.com/juancarlosjr97/flutter_ims
Each user should have their own collection
My database the own it works looks like this: 
and the other collection with a collection of users looks like this:

This is my code where I get access to the stock collection
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
class StockWidget extends StatefulWidget {
@override
StockWidgetApp createState() => new StockWidgetApp();
}
class StockWidgetApp extends State<StockWidget> {
@override
Widget build(BuildContext context) {
return StreamBuilder<QuerySnapshot>(
stream: Firestore.instance.collection('stock').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return LinearProgressIndicator();
return _buildList(context, snapshot.data.documents);
},
);
}
Widget _buildList(BuildContext context, List<DocumentSnapshot> snapshot) {
return ListView(
padding: const EdgeInsets.only(top: 20.0),
children: snapshot.map((data) => _buildListItem(context, data)).toList(),
);
}
Widget _buildListItem(BuildContext context, DocumentSnapshot data) {
final record = Record.fromSnapshot(data);
return Padding(
key: ValueKey(record.item),
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
child: Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.grey),
borderRadius: BorderRadius.circular(5.0),
),
child: ListTile(
title: Text(record.item),
trailing: Text(record.instock.toString()),
onTap: () =>
record.reference.updateData({'instock': record.instock + 1}),
onLongPress: () =>
record.reference.updateData({'instock': record.instock - 1}),
),
),
);
}
}
class Record {
final String item;
final int instock;
final DocumentReference reference;
@override
String toString() => "Record<$item:$instock>";
Record.fromMap(Map<String, dynamic> map, {this.reference})
: assert(map['item'] != null),
assert(map['instock'] != null),
item = map['item'],
instock = map['instock'];
Record.fromSnapshot(DocumentSnapshot snapshot)
: this.fromMap(snapshot.data, reference: snapshot.reference);
}