Home > front end >  flutter problem : A RenderFlex overflowed by 248 pixels on the right
flutter problem : A RenderFlex overflowed by 248 pixels on the right

Time:01-18

I am using three text in side a column, one text is long then I got this error "A RenderFlex overflowed by 248 pixels on the right."

I am using three text in side a column, one text field is long then I got this error "A RenderFlex overflowed by 248 pixels on the right." How to fix it?

enter image description here This is m code.

import 'package:cwc/ApiManager/api_magager.dart';
import 'package:cwc/constants/constants.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';

class EVDetails extends StatefulWidget {
  final eventsListDetails;
  const EVDetails({Key? key, this.eventsListDetails}) : super(key: key);

  @override
  State<EVDetails> createState() => _EVDetailsState();
}

class _EVDetailsState extends State<EVDetails> {

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      child: Padding(
        padding: const EdgeInsets.fromLTRB(20, 20, 20, 0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Padding(
                  padding: const EdgeInsets.fromLTRB(0, 0, 0, 10),
                  child:widget.eventsListDetails['image'] == null || widget.eventsListDetails['description'] =="" ?Image.asset(
                    'assets/video_cover.png',
                    height: 120,
                    width: 100,
                  ):Image.network(
                    imgBaseUrl '${widget.eventsListDetails['image']}',
                    height: 120,
                    width: 100,
                    fit: BoxFit.fill,
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.fromLTRB(19, 15, 0, 0),
                  child: Flexible(
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.start,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text(
                          '${widget.eventsListDetails['name']}',
                          style: GoogleFonts.poppins(
                            fontSize: 18,
                            color: Color(0xff444444),
                            fontWeight: FontWeight.w600,

                          ),maxLines: 1,
                          overflow: TextOverflow.ellipsis,
                        ),
                        Text(
                          'Cancer, Diabetes and Dental \nProblems',
                          style: GoogleFonts.poppins(
                            fontSize: 12,
                            color: Color(0xff8F9698),
                            fontWeight: FontWeight.normal,
                          ),
                        ),
                        Text(
                          'For Champion Membership',
                          style: GoogleFonts.poppins(
                            fontSize: 14,
                            color: Color(0xffC691D3),
                            fontWeight: FontWeight.w600,
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
               
              ],
            ),
            Text(
              'Event Description',
              style: GoogleFonts.poppins(
                  fontSize: 18,
                  // color: Color(0xFFC691D3),
                  color: Color(0xff444444),
                  fontWeight: FontWeight.w500),
            ),
            SizedBox(
              height: 11,
            ),
            Text(
             "${widget.eventsListDetails['description']}",
              style:
                  GoogleFonts.poppins(fontSize: 13, color: Color(0xFF444444)),
              textAlign: TextAlign.justify,
            ),
            Padding(
              padding: EdgeInsets.fromLTRB(0, 24, 0, 0),
              child: Container(
                decoration: BoxDecoration(
                  color: Color(0xffC691D3).withOpacity(0.2),
                  borderRadius: BorderRadius.only(
                      topRight: Radius.circular(10.0),
                      bottomRight: Radius.circular(10.0),
                      topLeft: Radius.circular(10.0),
                      bottomLeft: Radius.circular(10.0)),
                ),
                child: Padding(
                  padding: const EdgeInsets.all(10.0),
                  child: Row(
                    children: [
                      Column( crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Column(
                            mainAxisAlignment: MainAxisAlignment.start,
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              Text(
                                'Start Date & Time',
                                style: GoogleFonts.poppins(
                                  fontSize: 12,
                                  color: Color(0xFF444444),
                                ),
                              ),
                              Text(
                                  "${formateDat(DateTime.parse(widget.eventsListDetails['startTime']))} at ${DateFormat("hh:mm a").format(DateFormat("yyyy-MM-ddTHH:mm:ssZ").parseUTC("${widget.eventsListDetails['startTime']}").toLocal())} PT",
                                style: GoogleFonts.poppins(
                                  fontSize: 14,
                                  color: Color(0xFF444444),
                                ),
                              ),

                            ],
                          ),
                          SizedBox(height: 20,),
                          Column(
                            mainAxisAlignment: MainAxisAlignment.start,
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              Text(
                                'End Date & Time',
                                style: GoogleFonts.poppins(
                                  fontSize: 12,
                                  color: Color(0xFF444444),
                                ),
                              ),
                              Text(
                                "${formateDat(DateTime.parse(widget.eventsListDetails['endTime']))} at ${DateFormat("hh:mm a").format(DateFormat("yyyy-MM-ddTHH:mm:ssZ").parseUTC("${widget.eventsListDetails['endTime']}").toLocal())} PT",

                                style: GoogleFonts.poppins(
                                  fontSize: 14,
                                  color: Color(0xFF444444),
                                ),
                              ),
                              Padding(
                                padding: const EdgeInsets.fromLTRB(0, 5, 10, 2),
                                child: Row(
                                  children: [
                                    Row(
                                      children: [
                                        Icon(
                                          Icons.schedule,
                                          color: Color(0xFFC691D3),
                                        ),
                                        SizedBox(
                                          width: 2,
                                        ),
                                        Text(
                                          '${widget.eventsListDetails['duration']} mins',
                                          style: GoogleFonts.poppins(
                                              fontWeight: FontWeight.normal,
                                              fontSize: 14,
                                              color: Color(0xFFC691D3)),
                                        ),
                                      ],
                                    ),
                                    SizedBox(
                                      width: 5,
                                    ),
                                    Row(
                                      children: [
                                        Icon(
                                          Icons.online_prediction,
                                          color: Color(0xFFC691D3),
                                        ),
                                        SizedBox(
                                          width: 2,
                                        ),
                                        Text(
                                          '${widget.eventsListDetails['eventMode']}',
                                          style: GoogleFonts.poppins(
                                              fontWeight: FontWeight.normal,
                                              fontSize: 14,
                                              color: Color(0xFFC691D3)),
                                        ),
                                      ],
                                    ),
                                  ],
                                ),
                              ),
                            ],
                          ),
                        ],
                      ),
                      Spacer(),
                      Image.asset(
                        'assets/calender.png',
                        height: 120,
                        width: 120,
                      )
                    ],
                  ),
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
formateDat(DateTime date) {
  final DateFormat formatter = DateFormat.MMM();
  String formatted = formatter.format(date);
  formatted = "${formatted} "  "${date.day}";
  var week = DateFormat('EEEE').format(date);
  var we = week[0]   week[1]   week[2];
  return "$we, "   formatted;
}

CodePudding user response:

you can wrap row children with Flexible Widget and use flex: property

CodePudding user response:

Try below code hope its help to you. Put your Column Inside Expanded Widget:

 Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Container(
          padding:EdgeInsets.all(5),
          decoration: BoxDecoration(
            color: Colors.orange.shade200,
            border:Border.all(color:Colors.black,),
              borderRadius: BorderRadius.all(
            Radius.circular(12.0),
          ),),
          child: Row(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Image.network(
                'https://miro.medium.com/max/1400/1*-6WdIcd88w3pfphHOYln3Q.png',
                width: 100,
              ),
              SizedBox(
                width: 10,
              ),
              Expanded(
                child: Column(//put this column inside Expanded widget
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      ' {widget.eventsListDetails[index][ name ]}',
                    ),
                    Text('Cancer,Diabetes and Dental Problems'),
                    Text(
                      " {widget.eventsListDetails[index]['description']}ex]['description']}",
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
        SizedBox(height: 10),
        Text('Event Description'),
        SizedBox(height: 10),
        Text(
            'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.'),
      ],
    ),

Your result screen-> enter image description here

  •  Tags:  
  • Related