Created
December 9, 2022 16:35
-
-
Save ibrajix/60f2cf535683efab8e3f3c28b75c4890 to your computer and use it in GitHub Desktop.
trending_items.dart
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
_trendingItems(){ | |
return BlocBuilder<NftBloc, ApiState>( | |
builder: (context, state) { | |
final data = state.trendingNft; | |
return Container( | |
padding: const EdgeInsets.only(top: 20, bottom: 20), | |
width: MediaQuery.of(context).size.width, | |
child: ListView.builder( | |
shrinkWrap: true, | |
physics: const ClampingScrollPhysics(), | |
itemCount: state.trendingNft.length, | |
itemBuilder: (context, index){ | |
return DisplayTrendingItems(data: data[index], index: index); | |
} | |
), | |
); | |
}, | |
); | |
} | |
class DisplayTrendingItems extends StatelessWidget { | |
const DisplayTrendingItems({this.data, this.index, Key? key}) : super(key: key); | |
final TrendingNft? data; | |
final int? index; | |
@override | |
Widget build(BuildContext context) { | |
return GestureDetector( | |
onTap:() { | |
ScaffoldMessenger.of(context).showSnackBar(SnackBar( | |
content: Text("${Strings.trendingItemClicked} ${data?.id}"), | |
duration: const Duration(milliseconds: 200) | |
)); | |
}, | |
child: Padding( | |
padding: index == - 1 | |
? const EdgeInsets.fromLTRB(8, 0, 8, 0) | |
: const EdgeInsets.only(bottom: 20), | |
child: Row( | |
children:[ | |
Container( | |
width: 80, | |
height: 80, | |
decoration: BoxDecoration( | |
shape: BoxShape.circle, | |
image: DecorationImage( | |
fit: BoxFit.fill, | |
image: NetworkImage(data?.image ?? "") | |
) | |
)), | |
const SizedBox(width: 20), | |
Column( | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: [ | |
Text( | |
data?.name ?? "", | |
style: const TextStyle( | |
fontSize: 14, | |
color: Colors.white, | |
), | |
), | |
const SizedBox(height: 4), | |
Text( | |
data?.category ?? "", | |
style: const TextStyle( | |
fontSize: 14, | |
color: Colors.white, | |
fontStyle: FontStyle.italic | |
), | |
), | |
], | |
) | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment