Last active
January 7, 2020 16:25
-
-
Save voodoo/6a7e4b0f04b700a1e0c5b82f14c79471 to your computer and use it in GitHub Desktop.
Flutter test https://dartpad.dev/6a7e4b0f04b700a1e0c5b82f14c79471
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
import 'package:flutter/material.dart'; | |
//import 'dart:math'; | |
// import 'package:sticky_headers/sticky_headers.dart'; | |
// https://stackoverflow.com/questions/54151373/is-it-possible-to-select-a-random-icon-in-icons-or-fontawesomeicons-etc | |
// final List<int> points = <int>[0xe0b0, 0xe0b1, 0xe0b2, 0xe0b3, 0xe0b4]; | |
// final Random r = Random(); | |
// Icon randomIcon() => | |
// Icon(IconData(r.nextInt(points.length), fontFamily: 'MaterialIcons')); | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
debugShowCheckedModeBanner: false, | |
title: 'Menu', | |
theme: ThemeData( | |
primarySwatch: Colors.teal, | |
), | |
routes: { | |
Routes.meatDetails: (BuildContext context) => MeatDetailsView() | |
}, | |
home: Scaffold( | |
appBar: AppBar(title: Text('Products')), | |
body: BodyLayout() | |
), | |
); | |
} | |
} | |
class BodyLayout extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return _myListView(context); | |
} | |
} | |
Widget _myListView(BuildContext context) { | |
return ListView.separated( | |
itemCount: 1000, | |
itemBuilder: (context, index) { | |
if (index == 0) { | |
return Container( | |
child: Padding( | |
padding: EdgeInsets.all(23), | |
child: Text('Meats', style: TextStyle(fontSize: 23)))); | |
} | |
return Dismissible( | |
key: Key("item$index"), | |
background: Container( | |
alignment: Alignment.centerRight, | |
child: Icon(Icons.delete, color: Colors.white), | |
color: Colors.red), | |
child: ListTile( | |
leading: FlutterLogo(), | |
title: Text('Meat $index'), | |
subtitle: Text('Meat description subtitle $index'), | |
onTap: () { | |
Navigator.pushNamed(context, Routes.meatDetails); | |
//MaterialPageRoute( | |
//builder: (BuildContext context) => HeaderRowListView(), | |
//settings: RouteSettings(name: '/meatdetails') | |
//)); | |
}, | |
trailing: Icon(Icons.arrow_right)));//randomIcon())); | |
}, | |
separatorBuilder: (context, index) { | |
return Divider(thickness: 1.0); | |
}, | |
); | |
} | |
class Routes { | |
static const String meatDetails = '/meatDetails'; | |
// static const String secondPage = '/second'; | |
// static const String thirdPage = '/third'; | |
} |
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
class MeatDetailsView extends StatelessWidget { | |
final List<int> _listData = List<int>.generate(100, (i) => i); | |
@override | |
Widget build(BuildContext context) { | |
var route = ModalRoute.of(context).settings.name; | |
return Scaffold( | |
appBar: AppBar( | |
title: Text('Meat Details $route'), | |
), | |
body: ListView( | |
padding: EdgeInsets.all(8.0), | |
children: _listData.map((i) { | |
return i % 10 == 0 | |
? Container( | |
color: Colors.grey.withOpacity(.5), | |
child: Row( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
mainAxisSize: MainAxisSize.max, | |
children: <Widget>[ | |
Text("Header", | |
style: TextStyle( | |
fontSize: 20.0, | |
fontWeight: FontWeight.bold, | |
)), | |
Text("Feb 26th, 2019", | |
style: TextStyle( | |
fontSize: 14.0, | |
color: Colors.black45, | |
)), | |
], | |
), | |
padding: EdgeInsets.all(10.0), | |
) | |
: ListTile( | |
title: Text("Item $i"), | |
); | |
}).toList(), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment