Last active
November 10, 2018 13:00
-
-
Save andytwoods/13c56c196bf50558f1a6979b983c326b to your computer and use it in GitHub Desktop.
ExpansionPanel Issue
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
// instantiating the expansion panel with the below. Note the 500ms delay then adding another item. | |
// body: (){ | |
// List<MinimalModel> items = [MinimalModel(),MinimalModel()]; | |
// | |
// Timer(Duration(milliseconds: 500), (){ | |
// items.add(MinimalModel()); //should be wrapped with setState | |
// }); | |
// | |
// return ExpansionPanelIssue(items); | |
// }() | |
import 'package:flutter/material.dart'; | |
class MinimalModel { | |
final selected = true; | |
} | |
class ExpansionPanelIssue extends StatefulWidget { | |
static const String routeName = '/material/expansion_panels'; | |
final List<MinimalModel> minimalModel; | |
ExpansionPanelIssue(List<MinimalModel> this.minimalModel); | |
@override | |
_ExpansionPanelIssue createState() { | |
return _ExpansionPanelIssue(minimalModel); | |
} | |
} | |
class _ExpansionPanelIssue extends State<ExpansionPanelIssue> { | |
List<MinimalModel> _shoePairs; | |
_ExpansionPanelIssue(this._shoePairs); | |
@override | |
Widget build(BuildContext context) { | |
return SingleChildScrollView( | |
child: SafeArea( | |
top: false, | |
bottom: false, | |
child: Container( | |
margin: const EdgeInsets.all(24.0), | |
child: Theme( | |
data: Theme.of(context).copyWith(cardColor: Colors.white), | |
child: ExpansionPanelList( | |
expansionCallback: (int index, bool isExpanded) { | |
setState(() {}); | |
}, | |
children: _shoePairs.map<ExpansionPanel>( | |
(MinimalModel minimalModel) { | |
return ExpansionPanel( | |
isExpanded: minimalModel.selected, | |
headerBuilder: | |
(BuildContext context, bool isExpanded) { | |
return Container(child: Text('my header')); | |
}, | |
body: Text('my body')); | |
}, | |
).toList()), | |
), | |
))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment