Search code examples
fluttertextoverflow

Issue with Textoverflow



I have some troubles with the overflow attribute of the text widget. I tried several options (fade, ellipsis, clip) but none of them work...
Here is my code :
return ListView.builder(
      itemBuilder: (context, position) {
        var store = Store.fromJson(stores[position]);
        return GestureDetector(
          child: Card(
            child: Row(
              children: [
                Container(
                  alignment: Alignment.center,
                  width: 120,
                  height: 120,
                  child: Text(store.brand),
                ),
                Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      store.distance.toString() + " M",
                      style: TextStyle(
                        fontSize: 40,
                        fontFamily: "Gobold",
                      ),
                    ),
                    Text(
                      store.name,
                      style: TextStyle(
                        fontSize: 15,
                        fontFamily: "Abel",
                      ),
                    ),
                    Text(
                      store.address + " " + store.zipCode + " " + store.city,
                      overflow: TextOverflow.fade,
                      maxLines: 1,
                      style: TextStyle(
                        fontSize: 15,
                        fontFamily: "Abel",
                      ),
                    ),
                  ],
                )
              ],
            ),
          ),
          onTap: () => {
            setState(() {
              currentView = VIEW.detail;
              _store = store;
            })$
          },
        );
      },
      itemCount: stores.length,
    );

And there is the result : enter image description here

Could someone help me? I've been looking for a solution for several days.
Thank you


Solution

  • try Expanded:

            Expanded(child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  store.distance.toString() + " M",
                  style: TextStyle(
                    fontSize: 40,
                    fontFamily: "Gobold",
                  ),
                ),
                Text(
                  store.name,
                  style: TextStyle(
                    fontSize: 15,
                    fontFamily: "Abel",
                  ),
                ),
                Expanded(child: Text(
                  store.address + " " + store.zipCode + " " + store.city,