flutter-candlesticks
flutter-candlesticks copied to clipboard
StreamBuilder doesnt repaint
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 ) ); }
Yes if it doesn't change call setState.
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.
);
}
}
the same thing happened to me, did you find any alternative?