stablekernel / postgresql-dart

Dart PostgreSQL driver: supports extended query format, binary protocol and statement reuse.
https://www.dartdocs.org/documentation/postgres/latest
BSD 3-Clause "New" or "Revised" License
127 stars 32 forks source link

StreamBuilder #125

Closed agavrel closed 4 years ago

agavrel commented 4 years ago

Is there a way to use StreamBuilder with this Postgresql package ? (return a Stream instead of Future in order to feed results every 20 rows for example)

isoos commented 4 years ago

@agavrel: could you please add more details to this? I'm not sure what StreamBuilder you are referring to...

agavrel commented 4 years ago

Instead of

@override
  Widget build(BuildContext context) {
    return FutureBuilder<List<Data>>(
        future: _get_data(),
        builder: (context, snapshot) {
            (...)

use:

@override
  Widget build(BuildContext context) {
    return StreamBuilder<List<Data>>(
        stream: _get_data(),
        builder: (context, snapshot) {
            (...)

In order to get data as a stream

bettdouglas commented 4 years ago

I am not sure how you're getting your data from postgres to the app, but I'm sure using Stream.fromFuture(_get_data()) can return a stream from a future