Skip to content

Instantly share code, notes, and snippets.

@alardizabal
Created April 22, 2020 16:21
Show Gist options
  • Save alardizabal/15eedf83b32c868b5bdf1b2d4ea1bb55 to your computer and use it in GitHub Desktop.
Save alardizabal/15eedf83b32c868b5bdf1b2d4ea1bb55 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
class ExpansionTileSample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('ExpansionTile'),
),
body: ListView.builder(
itemBuilder: (BuildContext context, int index) {
return Stack(
children: <Widget>[
Positioned.fill(
child: Column(
children: <Widget>[
Expanded(
child: Container(
margin: EdgeInsets.only(left: 17),
decoration: BoxDecoration(
border: Border(
left: BorderSide(color: Colors.blue, width: 2),
),
),
),
),
Expanded(
child: Container(
margin: EdgeInsets.only(left: 17),
decoration: BoxDecoration(
border: Border(
left: BorderSide(color: Colors.blue, width: 2),
),
),
),
),
],
),
),
EntryItem(isFirst: index == 0, isLast: index == 2),
],
);
},
itemCount: 3,
),
),
);
}
}
// One entry in the multilevel list displayed by this app.
class Entry {
Entry(this.title, [this.children = const <Entry>[]]);
final String title;
final List<Entry> children;
}
class EntryItem extends StatelessWidget {
Entry entry;
final bool isFirst;
final bool isLast;
EntryItem({this.isFirst, this.isLast});
Widget _buildTiles(Entry root) {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Stack(
children: <Widget>[
Container(
margin: const EdgeInsets.only(left: 10, top: 21, right: 10),
height: 16,
width: 16,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.blue,
),
),
// Positioned.fill(
// child: Column(
// children: <Widget>[
// Expanded(
// child: Container(
// margin: EdgeInsets.only(left: 17),
// decoration: BoxDecoration(
// border: Border(
// left: BorderSide(color: Colors.blue, width: 2),
// ),
// ),
// ),
// ),
// Expanded(
// child: Container(
// margin: EdgeInsets.only(left: 17),
// decoration: BoxDecoration(
// border: Border(
// left: BorderSide(color: Colors.blue, width: 2),
// ),
// ),
// ),
// ),
// ],
// ),
// ),
],
),
Flexible(
child: ExpansionTile(
key: PageStorageKey<Entry>(root),
title: Text('SAMPLE STEP'),
children: <Widget>[
ListTile(
title: Text('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'),
),
],
),
),
],
);
}
@override
Widget build(BuildContext context) {
return _buildTiles(entry);
}
}
void main() {
runApp(ExpansionTileSample());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment