Created
May 2, 2019 08:21
-
-
Save buddypia/b85a94b98e77841572406217922835fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class CircleIndicator { | |
static Widget show() { | |
return Center( | |
child: new SizedBox( | |
height: 50.0, | |
width: 50.0, | |
child: new CircularProgressIndicator( | |
value: null, | |
strokeWidth: 7.0, | |
), | |
), | |
); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(widget.keyword), | |
), | |
body: FutureBuilder( | |
future: _fetchSearchKeyword(widget.keyword), | |
builder: | |
(BuildContext context, AsyncSnapshot<Autogenerated> snapshot) { | |
if (snapshot.hasError) { | |
print("snapshot.error: ${snapshot.error.toString()}"); | |
return Container(); | |
} | |
if (snapshot.hasData == false) { | |
return CircleIndicator.show(); | |
} | |
final items = snapshot.data.response.body.items.item; | |
return ListView.builder( | |
physics: ClampingScrollPhysics(), | |
scrollDirection: Axis.vertical, | |
itemCount: items.length, | |
itemBuilder: (context, index) { | |
final item = items[index]; | |
final contentValue = new ContentValue( | |
areaCode: item.areacode, | |
contentId: item.contentid, | |
contentTypeId: item.contenttypeid, | |
title: item.title, | |
imageUrl: item.firstimage); | |
final image = Utils.isNullOrEmpty(item.firstimage) | |
? ImageUtil.noImageWidget() | |
: Image.network(item.firstimage, fit: BoxFit.cover); | |
return _buildFeaturedItem(context, contentValue, () { | |
print("keyword: ${widget.keyword}, title: ${item.title}"); | |
Navigator.push( | |
context, | |
MaterialPageRoute( | |
builder: (context) => ContentTypeDetail( | |
contentValue: contentValue, | |
imageWidget: image, | |
))); | |
}, title: item.title, image: image, subTitle: ""); | |
}, | |
); | |
})); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment