BuildContext is show which widget in the tree so each widget has that. and also i know why builder widget need in below example
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text(widget.title),
),
body: new Container(),
/// Builders let you pass context
/// from your *current* build method
/// Directly to children returned in this build method
///
/// The 'builder' property accepts a callback
/// which can be treated exactly as a 'build' method on any
/// widget
floatingActionButton: new Builder(builder: (BuildContext context) {
return new FloatingActionButton(onPressed: () {
Scaffold.of(context).showSnackBar(
new SnackBar(
backgroundColor: Colors.blue,
content: new Text('SnackBar'),
),
);
});
}),
);
}
Beacuse in floationactionbutton it has to know scaffold. if i don't use builder that widget use context come from build function and that's not contain scaffold info here is question some cases i saw hyphen is used in context space
builder: (_) {}
like this
return Consumer<CounterProvider>
( builder: (_, counter, child) => Scaffold( appBar: AppBar( title: Text(widget.title), ),
or like this how is it work? why context don't need?