Skip to content

Instantly share code, notes, and snippets.

@azamsharp
Last active February 8, 2021 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azamsharp/a2b9c35f0913c446a5f3ef7ab7472580 to your computer and use it in GitHub Desktop.
Save azamsharp/a2b9c35f0913c446a5f3ef7ab7472580 to your computer and use it in GitHub Desktop.
class CustomerList extends StatelessWidget {
final List<String> customers;
CustomerList({@required this.customers});
@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: customers.length,
itemBuilder: (context, index) {
final customer = customers[index];
return ListTile(
title: Text(customer),
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (context) => CustomerDetailScreen(customer: customer)
));
},
);
}
);
}
}
class CustomerListScreen extends StatelessWidget {
final customers = ["Alex", "John", "Bryan", "Jerry", "Mary"];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Customers")
),
body: CustomerList(customers: customers)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment