flutter-candlesticks icon indicating copy to clipboard operation
flutter-candlesticks copied to clipboard

StreamBuilder doesnt repaint

Open namdroid opened this issue 5 years ago • 3 comments

Hi, The candles called with rxdart. It works fine. But I have the problem that the widget doesn't refresh if candles data changed. Do i need call setstate ?

Container buildOHLCVGraph(List candles) { return Container( height: 500.0, child: OHLCVGraph( data: candles, enableGridLines: false, volumeProp: 0.1 ) ); }

namdroid avatar Jun 14 '19 13:06 namdroid

Yes if it doesn't change call setState.

trentpiercy avatar Jun 14 '19 16:06 trentpiercy

Hi trentpiercy, as i understand if using StreamBuilder i do not need to call setstate. Therefore i dont understand why doesn't repaint ? I have also tried with setstate in different way but no luck. If i tried with Text wigdet , it works fine too.

Here is the code:

@override
  Widget build(BuildContext context) {
  
    bloc = ChartBlocProvider.of(context);
    bloc.start();
    
    return Scaffold(
      body: Padding(
                padding: EdgeInsets.all(8.0),
                  child: StreamBuilder(
                    stream: bloc.candleListResponse,
                    builder: (BuildContext context,
                        AsyncSnapshot<CandleListResponse> snapshot) {
                      if (snapshot.hasData) {                        return Container(
                          height: 500.0,
                          child: OHLCVGraph(
                              data: snapshot.data.candles,
                              enableGridLines: false,
                              volumeProp: 0.1),
                        );
                      } else if (snapshot.hasError) {
                        return Center(
                          child: Text('Failed to load forex data',
                              style: TextStyle(
                                  color: Colors.black, fontSize: 20.0)),
                        );
                      } else {
                        return Center(child: CircularProgressIndicator());
                      }
                    },
                  ),
              ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          _imageFile = null;
          bloc.makeScreenShot();
        },
        tooltip: 'capture screen',
        child: Icon(Icons.camera_alt),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }

}

namdroid avatar Jun 16 '19 18:06 namdroid

the same thing happened to me, did you find any alternative?

ezzabuzaid avatar Jul 31 '19 19:07 ezzabuzaid