Skip to content

Commit

Permalink
chart view loader fix
Browse files Browse the repository at this point in the history
  • Loading branch information
HemantKArya committed Mar 15, 2024
1 parent 35fcd1a commit 5efb541
Showing 1 changed file with 43 additions and 37 deletions.
80 changes: 43 additions & 37 deletions lib/screens/screen/chart/chart_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,43 +31,49 @@ class _ChartScreenState extends State<ChartScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: [
customDiscoverBar(context), //AppBar
SliverList(
delegate: SliverChildListDelegate([
FutureBuilder(
future: _chartData,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(),
);
} else if (snapshot.hasData) {
final List<Map<String, String>>? melon = snapshot.data;
return ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: melon?.length,
itemBuilder: (context, index) {
return ChartListTile(
title: melon![index]['title']!,
subtitle: melon[index]['label']!,
imgUrl: melon[index]['img']!,
);
},
);
} else {
return Center(
child: Text(
'Error: ${snapshot.error}',
style: Default_Theme.primaryTextStyle,
),
);
}
}),
]))
],
body: FutureBuilder(
future: _chartData,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(
child: SizedBox(
height: 50,
width: 50,
child: CircularProgressIndicator(
color: Default_Theme.accentColor2,
)),
);
} else if (snapshot.hasError) {
return Center(
child: Text(
"Error: ${snapshot.error}",
style: Default_Theme.secondoryTextStyleMedium,
),
);
} else {
final List<Map<String, String>>? melon = snapshot.data;
return CustomScrollView(
slivers: [
customDiscoverBar(context), //AppBar
SliverList(
delegate: SliverChildListDelegate([
ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: melon?.length,
itemBuilder: (context, index) {
return ChartListTile(
title: melon![index]['title']!,
subtitle: melon[index]['label']!,
imgUrl: melon[index]['img']!,
);
},
),
]))
],
);
}
},
),
backgroundColor: Default_Theme.themeColor,
);
Expand Down

0 comments on commit 5efb541

Please sign in to comment.