Skip to content

Instantly share code, notes, and snippets.

@ponnamkarthik
Last active May 25, 2019 12:37
Show Gist options
  • Save ponnamkarthik/6c3c55fb56e3a36d8203d4a961d773f8 to your computer and use it in GitHub Desktop.
Save ponnamkarthik/6c3c55fb56e3a36d8203d4a961d773f8 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import 'package:flutter_demo_provider/app_state.dart';
import 'package:provider/provider.dart';
class ResponseDisplay extends StatelessWidget {
@override
Widget build(BuildContext context) {
final appState = Provider.of<AppState>(context);
return Container(
padding: const EdgeInsets.all(16.0),
child: appState.isFetching
? CircularProgressIndicator()
: appState.getResponseJson() != null
? ListView.builder(
primary: false,
shrinkWrap: true,
itemCount: appState.getResponseJson().length,
itemBuilder: (context, index) {
return ListTile(
leading: CircleAvatar(
backgroundImage: NetworkImage(
appState.getResponseJson()[index]['avatar']),
),
title: Text(
appState.getResponseJson()[index]["first_name"],
),
);
},
)
: Text("Press Button above to fetch data"),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment