Slide 29
Slide 29 text
class ScopedModelHome extends StatelessWidget
{
@overrid
e
Widget build(BuildContext context)
{
// StatelessWidgetͰఆٛ͠ModelΛݺͼग़͢=> ViewʹϏδωεϩδοΫ͕ೖͬͯ͜ͳ͍
return ScopedModel
(
model: TeamScopedModel()
,
child: ScopedModelDescendant
(
// ScopedModelDescendantԼͰϞσϧΛࢀর
builder: (context, child, model) => Scaffold
(
appBar: AppBar
(
title: const Text('νʔϜҰཡ')
,
)
,
drawer: Header()
,
body: ListView.builder
(
itemBuilder: (BuildContext context, int index)
{
return Card
(
child: ListTile
(
title: Text(model.teams[index].name)
,
)
,
)
;
}
,
itemCount: model.teams.length
,
)
,
)
,
)
,
)
;
}
}
ScopedModel - SampleCode