Scrolling to close a Container

39 views
Skip to first unread message

Mark Valeriani

unread,
Mar 9, 2021, 10:21:31 AM3/9/21
to Flutter Development (flutter-dev)
I am working on a layout where when you scroll up you close the container you are scrolling on.  I am getting an overflow problem when the container starts to close due to the words not fitting in their space anymore. I tried wrapping my column in a fittedbox but that seemed to cause errors since I wasn't using a row, and when I shrink wrap it messes up the scrollphysics of my listview. Here is what I have. 


AnimatedSwitcher(
          duration: Duration(milliseconds: 100),
          child: aSwitch
              ? AnimatedContainer(
                  key: Key('1'),
                  alignment: Alignment.topCenter,
                  duration: Duration(milliseconds: 200),
                  width: screenWidth,
                  height: close ? 0 : (screenHeight) * .085,
                  child: groupView(context),
                )
              : AnimatedContainer(
                  key: Key('2'),
                  // color: Colors.blue[900],
                  alignment: Alignment.topCenter,
                  duration: Duration(milliseconds: 200),
                  width: screenWidth,
                  height: close ? 0 : (screenHeight) * .23,
                  child: groups(context),
                ),
        ),

Widget groups(BuildContext context) {
    return Column(
      children: <Widget>[
        Padding(
          padding: const EdgeInsets.only(left: 10, right: 1),
          child: SizedBox(
              height: 135,
              child: ListView.builder(
                physics: BouncingScrollPhysics(
                    parent: AlwaysScrollableScrollPhysics()),
                scrollDirection: Axis.horizontal,
                itemCount: 1,
                itemBuilder: (context, index) {
                  return new GestureDetector(
                    child: Container(
                      width: 130,
                      child: Card(
                        elevation: 5,
                        shape: RoundedRectangleBorder(
                            side: BorderSide(color: Colors.white70, width: 1),
                            borderRadius: BorderRadius.circular(20)),
                        child: Center(
                          child: Text("Add Groups"),
                        ),
                      ),
                    ),
                    onTap: () {
                      setState(() {
                        aSwitch = !aSwitch;
                        //GroupForm().showDialogForm(context, widget.groups);
                      });
                    },
                  );
                },
              )),
        ),
        Align(
          alignment: Alignment.topCenter,
          child: IconButton(
            color: Colors.blue[900],
            iconSize: 20,
            icon: Icon(Icons.close_fullscreen_rounded),
            onPressed: () {
              setState(() {
                aSwitch = !aSwitch;
              });
            },
          ),
        ),
      ],
    );
  }

Widget groupView(BuildContext context) {
      return Column(
        children: <Widget>[
          Padding(
            padding:
                const EdgeInsets.only(top: 12, left: 2, right: 1),
            child: SizedBox(
                height: 50,
                child: ListView.builder(
                  physics: BouncingScrollPhysics(
                      parent: AlwaysScrollableScrollPhysics()),
                  scrollDirection: Axis.horizontal,
                  itemCount: 1,
                  itemBuilder: (context, index) {
                    return new GestureDetector(
                      child: Container(
                        width: 100,
                        child: Card(
                          elevation: 5,
                          shape: RoundedRectangleBorder(
                              side: BorderSide(color: Colors.white70, width: 1),
                              borderRadius: BorderRadius.circular(20)),
                          child: Center(
                            child: Text("Add Groups"),
                          ),
                        ),
                      ),
                      onTap: () {
                        setState(() {
                          aSwitch = !aSwitch;
                       });
                      },
                    );
                  },
                )),
          ),
        ],
      );
    }


Suzuki Tomohiro

unread,
Mar 9, 2021, 10:31:01 AM3/9/21
to Mark Valeriani, Flutter Development (flutter-dev)
I don’t know which widget is causing an error. Can you share the screenshot of the error. YouTube video is even better.

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/6dbedd66-c4be-40c4-a4d2-8c07886e0b71n%40googlegroups.com.

Mark Valeriani

unread,
Mar 9, 2021, 10:34:08 AM3/9/21
to Flutter Development (flutter-dev)
This is the type of error I am getting but cannot seem to fix it the way he does - https://youtu.be/Cn6VCTaHB-k?t=358 
Reply all
Reply to author
Forward
0 new messages