Search
 
SCRIPT & CODE EXAMPLE
 

DART

expansion tile widget flutter opening one at time

int selected; //attention

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Short Product"),
      ),
      body: ListView.builder(
        key: Key('builder ${selected.toString()}'), //attention
        itemCount: 10,
        itemBuilder: (context, i) {
          return ExpansionTile(
              key: Key(i.toString()), //attention
              initiallyExpanded: i == selected, //attention
              title: Text(i.toString()),
              children: _Product_ExpandAble_List_Builder(i),
              onExpansionChanged: ((newState) {
                if (newState)
                  setState(() {
                    selected = i;
                  });
                else
                  setState(() {
                    selected = -1;
                  });
              }));
        },
      ),
    );
  }

  _Product_ExpandAble_List_Builder(int cat_id) {
    List<Widget> columnContent = [];
    [1, 2, 4, 5].forEach((product) => {
          columnContent.add(
            ListTile(
              title: ExpansionTile(
                title: Text(product.toString()),
              ),
              trailing: Text("$product (Kg)"),
            ),
          ),
        });
    return columnContent;
  }
Comment

PREVIOUS NEXT
Code Example
Dart :: flutter performance tips 
Dart :: dart regex to have at least one integer 
Dart :: flutter sliver TabBar 
Dart :: flutter remove appbar leading padding 
Dart :: dart promise all 
Dart :: dart terbary 
Dart :: flutter snackbar 
Dart :: dart round 
Dart :: sliver persistent tabbar 
Dart :: fluter check that date is greater than another date 
Dart :: how to sort and order a list by date in flutter 
Dart :: srring reverse dart 
Dart :: extension function flutter 
Dart :: ClipRRect for flutter 
Dart :: how to get image file size in flutter 
Dart :: dart http image upload 
Dart :: onpressed pass context flutter 
Dart :: string to int in dart, string to double in dart, int to string in dart 
Dart :: special characters flutter 
Dart :: flutter Explain Hot Reload in 
Dart :: inkwell splash color not working flutter 
Dart :: how to get real time data flutter 
Dart :: var keys = snap.value.keys; 
Dart :: perform async function in widget build method 
Dart :: dart compiler 
Dart :: how to small button in futter inside a listview 
Dart :: dropdown flutter transparent 
Dart :: add firest in list in dart 
Swift :: swift ui debug print 
Swift :: swift set view order front 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =