Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FutureBuilder<List>(
- future: GetSchedule().getService(),
- builder:
- (BuildContext context, AsyncSnapshot<List> snapshot) {
- switch (snapshot.connectionState) {
- case ConnectionState.active:
- case ConnectionState.none:
- case ConnectionState.waiting:
- return Center(
- child: Padding(
- padding:
- EdgeInsets.only(top: 16.0, bottom: 16.0),
- child: CircularProgressIndicator(),
- ),
- );
- break;
- case ConnectionState.done:
- if (!snapshot.hasData) {
- return SizedBox(
- height: 80,
- child: Container(
- padding:
- EdgeInsets.only(top: 8.0, bottom: 8.0),
- child: Center(
- child: Text(
- "Sem serviços disponiveis no momento!",
- style: TextStyle(
- fontWeight: FontWeight.w200),
- ),
- ),
- ),
- );
- } else {
- return ListView.builder(
- shrinkWrap: true,
- itemCount: snapshot.data.length,
- itemBuilder: (context, index) {
- return ListTile(
- onTap: () {
- setState(() {
- service = true;
- _service = snapshot.data[index]["id"];
- Navigator.of(context).pop();
- });
- },
- leading: CircleAvatar(
- radius: 25.0,
- backgroundColor: Colors.yellow,
- backgroundImage: NetworkImage(snapshot
- .data[index]["image"]),
- ),
- title: Text(
- snapshot
- .data[index]["name"],
- style: TextStyle(
- fontWeight: FontWeight.w300),
- ),
- trailing: Column(
- children: <Widget>[
- Text(
- "R\$${snapshot.data[index]["price"]}",
- style: TextStyle(
- fontWeight: FontWeight.w300),
- ),
- Text(
- "${snapshot.data[index]["time"]} min")
- ],
- ),
- );
- },
- );
- }
- }
- },
- ),
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement