Skip to content

Instantly share code, notes, and snippets.

@TobiCrackIT
Last active June 19, 2020 08:17
Show Gist options
  • Save TobiCrackIT/10cd85c0d848c68e80369c40e7d66e9f to your computer and use it in GitHub Desktop.
Save TobiCrackIT/10cd85c0d848c68e80369c40e7d66e9f to your computer and use it in GitHub Desktop.
Flutter Github App+
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
final List<String> names=[
'Armani Diogo','Bob Taboor','Curry Rice','Doe Doenna','Eilish Smith',
'Fally Pupa','Gandhi Makwa','Harry Kane','Idina Menzel','Jaden Rupert',
'Killi Mark','Layo Rayo','Manny Roo','Nani Roberts','Opportunist P',
'Pierce Morgan','Q Basic','Rowland Rope','Scooter Scott','Virat Ravel',
];
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: Text(
'Github Users',
style: TextStyle(color: Colors.white, fontSize: 14),
),
centerTitle: false,
backgroundColor: Colors.black87,
),
body: ListView.separated(
itemBuilder: (context, index) => userTile(names[index],'The Location'),
separatorBuilder: (context, index) => Divider(
height: 1,
),
itemCount: 20,
shrinkWrap: true,
),
);
}
Widget userTile(String fullName, String location,) {
return ListTile(
leading: Container(
height: 50,
width: 50,
decoration: BoxDecoration(
color: Colors.black87,
borderRadius: BorderRadius.all(Radius.circular(25))),
child: ClipRRect(
borderRadius: BorderRadius.circular(25),
child: Image.network(
'https://picsum.photos/250?image=9',
fit: BoxFit.contain,
),
),
),
title: Text(
'$fullName',
style: TextStyle(
color: Colors.black87, fontSize: 15, fontWeight: FontWeight.w500),
),
subtitle: Text(
'$location',
style: TextStyle(
color: Colors.grey, fontSize: 12, fontWeight: FontWeight.w300),
),
trailing: GestureDetector(
onTap: ()=>_launchURL('https://github.com/'),
child: Container(
height: 25,
width: 80,
decoration: BoxDecoration(
border: Border.all(color: Colors.black, width: 1.5),
borderRadius: BorderRadius.all(Radius.circular(22))),
padding: EdgeInsets.all(3),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'View Profile',
style: TextStyle(
color: Colors.black87,
fontSize: 8,
fontWeight: FontWeight.w400),
),
Image.asset(
'assets/images/github.png',
width: 20,
height: 20,
),
],
),
),
),
);
}
_launchURL(String url) async {
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment