This Dart package offers developers a streamlined library of Flutter widgets, useful for expanding widgets and text views, when users interact with them.

Related tags

UI expand_widget
Overview

Expand Widget

Package Build Patreon License

This Dart package offers developers a streamlined library of Flutter widgets, useful for expanding widgets and text views, when users interact with them.

There are two main 'expand' widgets:

  • Expand Child: Useful to show more widgets related to the content already visible by the user.
  • Expand Text: Useful when texts can be quite big for a certain screen. It adds the ability to show the full content when the user wants to.

Features

  • The ExpandArrowStyle parameter allows you to select various render options, related to the expand arrow itself.

  • Hide the arrow widget when the view is being expanded, using the hideArrowOnExpanded parameter.

  • Custimze the arrow widget itself: color, size, padding, icon...

  • You can also provide your own widget for the expand indicator, using the indicatorBuilder for both expaning widgets.

  • Use custom expanding hint strings! By default, it will use the ones provided by MaterialLocalizations.

  • Expand text view with swipe-down gestures, using the expandOnGesture, which by default is set to false.

  • You can also customize expand animation duration and curve easilly.

Example

Here is an example of a simple use of this package, featuring the ExpandChild & ExpandText widgets.

If you want to take a deeper look at the example, take a look at the example folder provided with the project.

  • ExpandChild
ExpandChild(
  child: Column(
    children: [
      OutlineButton(
        child: Text('Button1'),
        onPressed: () => print('Pressed button1'),
      ),
      OutlineButton(
        child: Text('Button2'),
        onPressed: () => print('Pressed button2'),
      ),
      OutlineButton(
        child: Text('Button3'),
        onPressed: () => print('Pressed button3'),
      ),
    ],
  ),
),
  • ExpandText
ExpandText(
  'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
  textAlign: TextAlign.justify,
),

Getting Started

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Built with

Authors

License

This project is licensed under the GNU GPL v3 License - see the LICENSE file for details.

Comments
  • [Feature list] v1.0

    [Feature list] v1.0

    I'm going to lay down most of the new features & enhancements that will be implemented in the v1.0 update. All chages will reside inside the dev branch.

    • Fix #10
    • Implement #7 and resolve #8
    • Add testing
    • Add CI to the project
    • More things comming soon...

    Write a comment if you want your idea to be included in this new update! Thanks for your collaboration :)

    enhancement 
    opened by jesusrp98 6
  • [BUG] Too much white space?

    [BUG] Too much white space?

    If i enter text such as : "asddasdd asdsadasda vxcvxcvxcv nmbvlkbm mlcmvcxnvxcmvn nmnmnmcnmsa vncmnvmcvnmcn mnvcmnvcmnvmc mcnvmnvmcnv dskqjdksdd" it will auto generate more white space than i entered.

    bug help wanted 
    opened by mdat31 3
  • ExpandChild suggestions

    ExpandChild suggestions

    Currently, if you set expandArrowStyle to ExpandArrowStyle.text, a Tootltip is still shown on long press (with the same text as the button). Also, tooltipMessage is forced to upper case on the button: https://github.com/jesusrp98/expand_widget/blob/master/lib/src/expand_arrow.dart#L109, so setting collapsedHint to Test will result in a button with TEST text and a Test Tooltip.

    bug enhancement 
    opened by Zazo032 3
  • Not working on web

    Not working on web

    ExpandText behaves as expected on mobile, but the expand arrow does not appear on web. It is therefore impossible to expand the text on web. I'm using the widget like this:

    ExpandText(
            """Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia,
          molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum
        numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium
        optio, eaque rerum! Provident similique accusantium nemo autem. Veritatis
        obcaecati tenetur iure eius earum ut molestias architecto voluptate aliquam
          nihil, eveniet aliquid culpa officia aut! Impedit sit sunt quaerat, odit,
          tenetur error, harum nesciunt ipsum debitis quas aliquid. Reprehenderit,
          quia. Quo neque error repudiandae fuga? Ipsa laudantium molestias eos
        sapiente officiis modi at sunt excepturi expedita sint? Sed quibusdam
        recusandae alias error harum maxime adipisci amet laborum. Perspiciatis
        minima nesciunt dolorem! Officiis iure rerum voluptates a cumque velit
          quibusdam sed amet tempora. Sit laborum ab, eius fugit doloribus tenetur
          fugiat, temporibus enim commodi iusto libero magni deleniti quod quam
        consequuntur! Commodi minima excepturi repudiandae velit hic maxime
        doloremque. Quaerat provident commodi consectetur veniam similique ad
          earum omnis ipsum saepe, voluptas, hic voluptates pariatur est explicabo
          fugiat, dolorum eligendi quam cupiditate excepturi mollitia maiores labore
        suscipit quas? Nulla, placeat. Voluptatem quaerat non architecto ab laudantium
        modi minima sunt esse temporibus sint culpa, recusandae aliquam numquam
        totam ratione voluptas quod exercitationem fuga. Possimus quis earum veniam
          quasi aliquam eligendi, placeat qui corporis!""",
            style: regularTextStyle,
            maxLines: 5,
            hintTextStyle: regularTextStyle.copyWith(color: themeOrangeColor),
            collapsedHint: S.of(context).showMoreText,
            expandedHint: S.of(context).showLessText,
            textAlign: TextAlign.start,
    
          )
    

    inside the Scaffold's body. I'm using version 2.1.0 of this package and this is my flutter doctor for version context:

    [√] Flutter (Channel stable, 2.8.1, on Microsoft Windows [Version 10.0.19043.1348], locale en-US)
    [√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    [√] Chrome - develop for the web
    [√] Android Studio (version 2020.3)
    [√] IntelliJ IDEA Ultimate Edition (version 2021.2)
    [√] Connected device (2 available)
    
    • No issues found!
    
    
    opened by SeriousMonk 2
  • Minimum height for ExpandChild

    Minimum height for ExpandChild

    I want to wrap my ExpandChild to Html widget, Html is similar as Text but render html and look better.

       ExpandChild(
                            arrowColor: Colors.red,
                            arrowSize: 16,
                            expandArrowStyle: ExpandArrowStyle.icon,
                            child: Html(
                                htmlString,
                                onLinkTap: (
                                  String? url,
                                  RenderContext context,
                                  Map<String, String> attributes,
                                  element,
                                ) =>  launchUrl(url)),
                          ),
    

    Right now it show no content until user tap expand arrow, then it will display full content. I would like to set it to a minimum height so user can preview the content. If possible, I hope it can also detect childs height so only show expand button if child.height > minimum height

    opened by ChauCM 2
  • Inherit theme text style

    Inherit theme text style

    Fixes #11

    Both suggested fixes are brittle as the implementation of Text.build may change at any time. I chose this method to fix the Theme not inheriting as it does not make any firm assumptions about the returned widget structure thus negates the need for casting too.

    opened by JamesMcIntosh 2
  • How to manage arrow position as text?

    How to manage arrow position as text?

    I want to manage arrow position, but i didn't deal with it. Can u help for this? I try to do arrow position like sample image. But its position is always center. expandedtext

    Thank you for help

    opened by kseyko35 1
  • automatically centers text if first line doesnt take up full width

    automatically centers text if first line doesnt take up full width

    Really love this package but having a problem where it is impossible to align the text left when the first line of text doesnt take up the full width of the container. It will center no matter what i set the textAlign property to. Screen Shot 2021-04-27 at 2 48 15 PM Screen Shot 2021-04-27 at 2 48 52 PM

    opened by eliezerp3 1
  • Making expandable text scrollable in case screen size is maxed.

    Making expandable text scrollable in case screen size is maxed.

    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,
                  ),
                ),
              )
            ],
          ),
        );
      }
    }
    
    question 
    opened by mingenbache 1
  • Vertical drag to expand/collapse behaviour

    Vertical drag to expand/collapse behaviour

    The vertical drag to expand and collapse behaviour is a little bit unexpected.

    1. When expanded text is in a scrollable list sometimes when you are trying to scroll the list then it expands the text.

    2. Swiping to open / close the text ignores the direction you are swiping, i.e. if collapsed you can swipe up to expand, where I would expect swipe down only.

    bug 
    opened by JamesMcIntosh 1
Owner
Jesús Rodríguez
@flutter developer, #design enthusiast.
Jesús Rodríguez
A Flutter package that enables users to resize the internal widgets by dragging.

resizable_widget ResizableWidget enables users to resize the internal widgets by dragging. This package contains simple APIs, but if needed, you can c

null 35 Dec 2, 2022
A better way for new feature introduction and step-by-step users guide for your Flutter project.

A better way for new feature introduction and step-by-step users guide for your Flutter project.

好未来技术 139 Oct 26, 2022
A TypeAhead widget for Flutter, where you can show suggestions to users as they type

Flutter TypeAhead A TypeAhead (autocomplete) widget for Flutter, where you can show suggestions to users as they type Features Shows suggestions in an

null 661 Jan 5, 2023
Native text input from iOS for Flutter

Native Text Input for Flutter A text input widget built using the native UITextView on iOS (this package only supports iOS for now). Installation Foll

Henry Leung 55 Dec 24, 2022
A simple package that provides you with some widgets and cutom clippers which implements the shape of a coupon card.

Coupon UI Kit A simple package that provides you with some widgets and cutom clippers which implements the shape of a coupon card. The example contain

AbdulMuaz Aqeel 15 Dec 20, 2022
This package provides some widgets you can use to create a smooshy UI.

Dough Library Squishy widgets for Flutter. Quick Links Dough Demos Here are a few samples of the different widgets provided by this repo. You can find

Josiah Saunders 530 Dec 23, 2022
A Dart package that detects credit card types based on their prefixes

credit_card_type_detector | Credit Card Type Detector A Dart package that detects credit card types based on the current credit card number patterns T

Tanner Davis 22 Jan 4, 2023
Lightweight Flutter form library

LoForm ?? LoForm is still experimental, missing features and bugs are to be expected. LoForm is a low-code and lightweight Flutter form library, inspi

Youssef Raafat 78 Dec 30, 2022
Toast Library for Flutter

A Powerful Toast Library for Flutter. Easily create toast messages in single line of code with leading image options.

Sanket Vekariya 8 Apr 25, 2022
A small library for creating snapping lists.

snaplist A small cozy library that allows you to make snappable list views. Issues and Pull Requests are really appreciated! Snaplist supports differe

David Leibovych 420 Jan 3, 2023
Flutter Widgets that you can touch and feel

Flutter widgets you haven't used yet. Problems that proximity solves Currently, Flutter has a lot of useful pre-built widgets, no, too many widgets. T

Masahiro Aoki 32 Nov 8, 2022
A set of high-level Flutter UI components and stand-alone widgets for easier implementation of most used UI features

A set of high-level Flutter UI components and stand-alone widgets for easier implementation of most used UI features

Evgeny Cherkasov 37 Jul 25, 2022
Responsive Sizer helps implement are responsive layout by providing helper widgets and extensions

Responsive Sizer Responsive Sizer helps implement a responsive layout by providing helper widgets and extensions Content Installation Parameters Take

CoderUni 71 Jan 3, 2023
Allows widgets to be zoomed in and out by inserting a OverlayEntry which allows the widget to be on the front at all times.

zoom_pinch_overlay An instagram style pinch and zoom widget for all platform completely written in pure dart! All other "zoom_pinch" package doesnt di

Samuel 18 Nov 29, 2022
A flutter package to display a country, states, and cities. In addition it gives the possibility to select a list of countries, States and Cities depends on Selected, also you can search country, state, and city all around the world.

A flutter package to display a country, states, and cities. In addition it gives the possibility to select a list of countries, States and Cities depends on Selected, also you can search country, state, and city all around the world.

Altaf Razzaque 25 Dec 20, 2022
Movies App UI in Flutter using Simple Widgets without Using API's in Flutter.

Movies App UI in Flutter using Simple Widgets without Using API's in Flutter.

Habib ullah 3 May 15, 2022
🔥 Flutter Widgets 掘金对应专栏,欢迎关注

Flutter Widgets 示例集合 本项目基于 Flutter 2.2.1 版本,是系列 Flutter Widget 示例源码,有对应的文章详细讲解,持续更新敬请关注。 在线预览 全景脑图 持续更新中 掘金专栏 欢迎关注 已完成文章 AnimatedContainer ClipRRect、C

Zero 12 Dec 14, 2022
Code generation for Flutter Padding widgets based on your constants

Paddinger Paddinger is a Flutter package to generate Padding widgets. Given a set of constants like: @paddinger const double PADDING_NORMAL = 8; A set

Emanuele 14 Oct 20, 2022
Build Beautiful UIs with Flutter Widgets

I learnt this following thing from this project How to create Stateless Widgets What is the difference between hot reload and hot refresh and running

Chitraarasu.k 2 Dec 31, 2021