Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StreamBuilder doesnt repaint #9

Open
namdroid opened this issue Jun 14, 2019 · 3 comments
Open

StreamBuilder doesnt repaint #9

namdroid opened this issue Jun 14, 2019 · 3 comments

Comments

@namdroid
Copy link

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
)
);
}

@trentpiercy
Copy link
Owner

Yes if it doesn't change call setState.

@namdroid
Copy link
Author

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.
    );
  }

}

@ezzabuzaid
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants