Open Manan-dynamic opened 1 year ago
Streambuilder listview firestore db ui
import 'dart:async';
//import 'package:transparent_image/transparent_image.dart';
//import'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:flutter/material.dart';
class Streambuil extends StatefulWidget {
const Streambuil({Key? key}) : super(key: key);
@override
State<Streambuil> createState() => _StreambuilState();
}
class _StreambuilState extends State<Streambuil> {
int count = 0;
StreamController controllerStream = StreamController();
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(child: StreamBuilder(
stream: controllerStream.stream,
builder: (context, snapshot) {
if (snapshot.hasData) {
return Text(
snapshot.data.toString(),
style: TextStyle(fontSize: 25),
);
}else{
return Text("0",style: TextStyle(fontSize: 25),);
}
})),
),
floatingActionButton: FloatingActionButton(
onPressed: (){
count++;
controllerStream.sink.add(count);
},
child: Text('+'),
),
);
}
}