jesusrp98 / expand_widget

Ability to easily expand and retract a widget collection or text
https://pub.dev/packages/expand_widget
GNU General Public License v3.0
45 stars 22 forks source link

Making expandable text scrollable in case screen size is maxed. #24

Closed mingenbache closed 3 years ago

mingenbache commented 3 years ago

Hi,

I'm having a problem enabling scrolling functionality within a screen that has this widget. I'm not sure what i'm doing wrong, but it will not scroll so far, here is my code..... I would like to make the text widget scrollable, or make the entire screen scrollable, BUT show the add to cart button on load, which is where your widget comes in.

import 'package:Swara/colors.dart';
import 'package:flutter/material.dart';
import 'package:Swara/constants.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'components/body.dart';
import 'package:Swara/model/product.dart';

class DetailsScreen extends StatelessWidget {
  final Product product;

  const DetailsScreen({Key key, this.product}) : super(key: key);
  @override
  Widget build(BuildContext context) {
   return Scaffold(
      backgroundColor: DMLGreenLight,
      appBar: buildAppBar(context),
      body: Body(product: product,),
     );
  }

  AppBar buildAppBar(BuildContext context) {
    return AppBar(
      backgroundColor: DMLGreen,
      elevation: 0,
      leading: IconButton(
        padding: EdgeInsets.only(left: kDefaultPadding),
        icon: SvgPicture.asset(
          "assets/icons/back.svg",
          color: DMLSurfaceWhite,
        ),
        onPressed: (){
          Navigator.pop(context);
        }
        ),
      title: Text('Back'.toUpperCase(),
        style:
            TextStyle(color: DMLSurfaceWhite,),
      ),
      actions: <Widget>[
        IconButton(
          icon: SvgPicture.asset('assets/icons/cart_with_item.svg',
            color: DMLSurfaceWhite,
          ),
          onPressed: () {

          },
        )
      ],
    );
  }

}
import 'package:flutter/material.dart';
import 'package:Swara/colors.dart';
import 'package:Swara/constants.dart';
import 'package:Swara/model/product.dart';
import 'package:Swara/screens/product/components/category_list.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:sliding_sheet/sliding_sheet.dart';
import 'package:expand_widget/expand_widget.dart';
import 'package:Swara/screens/details/components/chat_and_add_to_cart.dart';
class Body extends StatelessWidget {
  final Product product;
  final String category;
  const Body({Key key, this.product, this.category}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    Size size = MediaQuery.of(context).size;
   return  SingleChildScrollView(
     child: Column(
          children: <Widget>[
            Container(
              padding: EdgeInsets.only(left: 20, right:20, bottom: 30),
              //height: size.width *0.9,
              decoration: BoxDecoration(
                color: DMLGreen,
                borderRadius: BorderRadius.only(
                  bottomLeft: Radius.circular(50),
                  bottomRight: Radius.circular(50),
                ),
              ),
              child: Column(
                children: [
                  Align(
                      alignment: Alignment.topLeft,
                        child: Text(
                          product.title.toUpperCase() ,
                          style: TextStyle(
                            color: DMLSurfaceWhite,
                            fontSize: 22),
                        ),
                      ),
                  SizedBox(height: kDefaultPadding),
                  Container(
                    //constraints: BoxConstraints(maxHeight: size.height/1.8),
                      child: Container(
                        child: ExpandText(
                          product.description,
                          textAlign: TextAlign.justify,
                            style: TextStyle(
                              fontSize: 18,
                              fontWeight: FontWeight.w300,
                              color: DMLSurfaceWhite,
                            )
                        ),
                      ),
                    ),

                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Column(
                        children: [
                          Text(
                            product.price.toString(),
                            style: TextStyle(
                              fontSize: 18,
                              fontWeight: FontWeight.w600,
                              color: DMLSurfaceWhite,
                            ),
                          ),
                        ],
                      ),
                      Column(
                        crossAxisAlignment: CrossAxisAlignment.end,
                        children: [
                          Container(
                            alignment: Alignment.centerRight,
                            padding: EdgeInsets.only(top:3,left:6,right:6,bottom:3,),
                            margin: EdgeInsets.only(left:20),
                            decoration: BoxDecoration(
                              color: DMLSurfaceWhite,
                              borderRadius: BorderRadius.circular(13),
                            ),
                            child: Text(getCategory(product.category),
                              style: TextStyle(
                                fontSize: 18,
                                fontWeight: FontWeight.w400,
                                color: DMLGrey,
                              ),
                            ),
                          ),
                        ],
                      ),
                    ],
                  ),
                ],
              ),

            ),
            Column(
              children: <Widget>[
                        Container(
                          padding: EdgeInsets.symmetric(horizontal: kDefaultPadding),

                          decoration: BoxDecoration(
                            color: DMLGreen,
                            borderRadius: BorderRadius.only(
                              bottomLeft: Radius.circular(50),
                              bottomRight: Radius.circular(50),
                            ),
                          ),
                          child: Column(

                        ),
                       ),
                      ],
                      ),
            ChatAndAddToCart(),
          ]

      ),
   );
  }

  String getCategory(int id) {
  return showCategory(id);
  }
}

import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';

import '../../../colors.dart';
import '../../../constants.dart';

class ChatAndAddToCart extends StatelessWidget {
  const ChatAndAddToCart({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.all(kDefaultPadding),
      padding: EdgeInsets.symmetric(
        horizontal: kDefaultPadding,
        vertical: kDefaultPadding,
      ),
      decoration: BoxDecoration(
        color: DMLGrey,
        borderRadius: BorderRadius.circular(30),
      ),
      child: Row(
        children: <Widget>[
          SvgPicture.asset("assets/icons/chat.svg",
            height: 15,

          ),
          SizedBox(width: kDefaultPadding / 2),
          Text(
            "Chat",
            style: TextStyle(color: DMLSurfaceWhite,
            ),
          ),
          Spacer(),
          FlatButton.icon(
            onPressed:() {},
            icon: SvgPicture.asset(
              "assets/icons/shopping-bag.svg",
              height: 18,
              color: DMLGreenLight,
            ),
            label: Text(
              "Add to Cart",
              style: TextStyle(
                color: DMLGreenLight,
              ),
            ),
          )
        ],
      ),
    );
  }
}
jesusrp98 commented 3 years ago

Could you please show me how is this failing? Maybe with some images or videos?