0

This this part when I expand my text ui then up side and bottom i am getting line but i dont want this and i also want color light grey when my text is expanding but that things also not working. please help me to solve this

this is my code.

import 'package:cwc/constants/constants.dart';
import 'package:flutter/material.dart';

class ListItem extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return ListItemState();
  }
}

class ListItemState extends State<ListItem> {
  bool isExpand = false;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    isExpand = false;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ListView(
        children: [
          for (int i = 0; i < 15; i++)
            Card(
              child: Container(
                color: (isExpand == true) ? Color(0xfff6f7f9) : Colors.white,
                child: ExpansionTile(
                  backgroundColor: Colors.white,
                  title: Container(
                      width: double.infinity,
                      child: Text(
                        "How do I engage employees in a wellness program?",
                        style: TextStyle(
                            color: Color(0xFF444444),
                            fontSize: tSize14,
                            fontWeight: FontWeight.w500),
                      )),
                  trailing: (isExpand == true)
                      ? Icon(
                          Icons.keyboard_arrow_down,
                          size: 32,
                          color: Colors.grey,
                        )
                      : Icon(Icons.keyboard_arrow_up,
                          size: 32, color: Colors.grey),
                  onExpansionChanged: (value) {
                    setState(() {
                      isExpand = value;
                    });
                  },
                  children: [
                    Container(
                        width: double.infinity,
                        padding: EdgeInsets.only(
                            top: 20, left: 10, right: 10, bottom: 20),
                        child: Text(
                            """Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country, in which roasted parts of sentences fly into your mouth. 
Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country, in which roasted parts of sentences fly into your mouth. 
Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts.""",
                            style: TextStyle(
                              color: Color(0xFF444444),
                              fontSize: 13,
                            ))),
                  ],
                ),
              ),
            ),
        ],
      ),
    );
  }
}

In Actuall I want like this ui

enter image description here

But it is becoming like this (Page first when text not expand)

enter image description here

Page Second when text is expanded-- enter image description here

(Page Second when text is expanded)

Deepak
  • 1,664
  • 3
  • 19
  • 52
  • have you tried expansion_tile_card package? also you can copy the codes of it its free on github if you have something to change on the widget itself./ – Arbiter Chil Jan 28 '22 at 11:32
  • I already posted the anser for the question in the stackoverflow. [I think this will help you](https://stackoverflow.com/a/69309978/11789675) – Anand Jan 28 '22 at 12:59

1 Answers1

0

I already posted the anser for the question in the stackoverflow.

you can use the initially expanded to expand your widget

initiallyExpanded : true,

use this code inside your ExpansionTile

Here's where i answerd another question like yours. I think this will help you

Anand
  • 4,355
  • 2
  • 35
  • 45