Chapter 6, section 6 includes the following code snippet:
// 1
return Consumer<TabManager>(builder: (context, tabManager, child) {
return Scaffold(
appBar: AppBar(
title: Text(
'Fooderlich',
style: Theme.of(context).textTheme.headline6,
),
),
// 2
// TODO: Replace body
body: pages[tabManager.selectedTab],
bottomNavigationBar: BottomNavigationBar(
selectedItemColor: Theme.of(context)
.textSelectionTheme.selectionColor,
// 3
currentIndex: tabManager.selectedTab,
onTap: (index) {
// 4
tabManager.goToTab(index);
},
items: <BottomNavigationBarItem>[
const BottomNavigationBarItem(
icon: Icon(Icons.explore),
label: 'Explore',
),
const BottomNavigationBarItem(
icon: Icon(Icons.book),
label: 'Recipes',
),
const BottomNavigationBarItem(
icon: Icon(Icons.list),
label: 'To Buy',
),
],
),
);
},
);
I am having difficulty parsing the first line of this code. Abstracting out the details that I understand, I get this:
return Consumer<TabManager>(builder: (context, tabManager, child) { return Scaffold(...) });
Basically, it appears that the code returns a Consumer widget that is constructed with two arguments:
- “builder”, which is
(context, tabManager, child)
- Syntax I don’t understand:
{ return Scaffold()}
Could someone explain this syntax use to me?
Thanks!