0

I'm trying to create a fully responsive design. I'm facing the overflow issue when I resize my screen from bottom to top(Vertically) or top to bottom in desktop view. And I face horizontal responsiveness overflow from right and bottom sides, if I shrink the window size to much. There are two things 1rst I think the issue will be resolve with scrollbars, but I'm not able to add scrollbars. 2nd I would like to have a solution(or method, or widgets) for all type of responsiveness(horizontal and vertical) ,as soon as possible.

Normal Desktop View

enter image description here

Bottom Over Flow Issue when I resize Vertically enter image description here

Normal Mobile View

enter image description here

Vertical and Horizontal Over Flow Issue after Resizing

enter image description here

Flutter Doctor

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.10.0, on Microsoft Windows [Version 10.0.22000.318], locale en-PK)
[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Professional 2022 17.0.5)
[√] Android Studio (version 2021.1)
[√] VS Code (version 1.64.0)
[√] Connected device (3 available)
[√] HTTP Host Availability

• No issues found!

Web_Screen Code

import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:g_res_p/colors/colors.dart';
import 'package:g_res_p/widgets/search.dart';
import 'package:g_res_p/widgets/webButtons/search_button1.dart';
import 'package:g_res_p/widgets/webButtons/translation_btn.dart';
import 'package:g_res_p/widgets/webButtons/upper_web_footer.dart';
import 'package:g_res_p/widgets/webButtons/web_footer.dart';

class WebScreenLayout extends StatelessWidget {
  const WebScreenLayout({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final size = MediaQuery.of(context).size;
    return Scaffold(
      appBar: AppBar(
        backgroundColor: backgroundColor,
        elevation: 0,
        actions: [
          TextButton(
            onPressed: () {},
            child: const Text(
              'Gmail',
              style: TextStyle(
                color: primaryColor,
                fontWeight: FontWeight.w400,
              ),
            ),
          ),
          const SizedBox(
            width: 10,
          ),
          TextButton(
            onPressed: () {},
            child: const Text(
              'Images',
              style: TextStyle(
                color: primaryColor,
                fontWeight: FontWeight.w400,
              ),
            ),
          ),
          const SizedBox(
            width: 10,
          ),
          IconButton(
            onPressed: () {},
            icon: SvgPicture.asset(
              'assets/images/more-apps.svg',
              color: primaryColor,
            ),
          ),
          const SizedBox(
            width: 10,
          ),
          Padding(
            padding: const EdgeInsets.symmetric(vertical: 10.0).copyWith(
              right: 10,
            ),
            child: MaterialButton(
              onPressed: () {},
              color: const Color(
                0xff1A73EB,
              ),
              child: const Text(
                'Sign in',
                style: TextStyle(
                  color: Colors.white,
                ),
              ),
            ),
          ),
        ],
      ),
      body: Padding(
        padding: const EdgeInsets.only(),
        child: Column(
          children: [
            SizedBox(
              height: size.height * 0.25,
            ),
            Expanded(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Column(
                    children: const [
                      Search(),
                      SizedBox(
                        height: 20,
                      ),
                      SearchButton1(),
                      SizedBox(
                        height: 20,
                      ),
                      TranslationButtons(),
                    ],
                  ),
                  Column(
                    children: const [
                      UpperWebFooter(),
                      Divider(
                        height: 1,
                        color: dividerColor,
                      ),
                      WebFooter(),
                    ],
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Mobile_Screen Code

import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:g_res_p/colors/colors.dart';
import 'package:g_res_p/widgets/mobile/mobiel_footer.dart';
import 'package:g_res_p/widgets/search.dart';
import 'package:g_res_p/widgets/webButtons/search_button1.dart';
import 'package:g_res_p/widgets/webButtons/translation_btn.dart';
import 'package:g_res_p/widgets/webButtons/upper_web_footer.dart';

class MobileScreenLayout extends StatelessWidget {
  const MobileScreenLayout({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final size = MediaQuery.of(context).size;
    return Scaffold(
      appBar: AppBar(
        backgroundColor: backgroundColor,
        elevation: 0,
        leading: IconButton(
          onPressed: () {},
          icon: const Icon(
            Icons.menu,
            color: Colors.grey,
          ),
        ),
        title: SizedBox(
          width: size.width * 0.34,
          child: const DefaultTabController(
            length: 2,
            child: TabBar(
              indicatorColor: blueColor,
              unselectedLabelColor: Colors.grey,
              labelColor: blueColor,
              indicatorSize: TabBarIndicatorSize.label,
              tabs: [
                Tab(
                  text: 'All',
                ),
                Tab(
                  text: 'Images',
                ),
              ],
            ),
          ),
        ),
        actions: [
          IconButton(
            onPressed: () {},
            icon: SvgPicture.asset(
              'assets/images/more-apps.svg',
              color: primaryColor,
            ),
          ),
          const SizedBox(
            width: 10,
          ),
          Padding(
            padding: const EdgeInsets.symmetric(vertical: 10.0).copyWith(
              right: 10,
            ),
            child: MaterialButton(
              onPressed: () {},
              color: const Color(
                0xff1A73EB,
              ),
              child: const Text(
                'Sign in',
                style: TextStyle(
                  color: Colors.white,
                ),
              ),
            ),
          ),
        ],
      ),
      body: Padding(
        padding: const EdgeInsets.only(),
        child: Column(
          children: [
            SizedBox(
              height: size.height * 0.25,
            ),
            Expanded(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Column(
                    children: const [
                      Search(),
                      SizedBox(
                        height: 20,
                      ),
                      SearchButton1(),
                      SizedBox(
                        height: 20,
                      ),
                      TranslationButtons(),
                    ],
                  ),
                  Column(
                    children: const [
                      UpperWebFooter(),
                      Divider(
                        height: 1,
                        color: dividerColor,
                      ),
                      MobileFooter(),
                    ],
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
M Nouman
  • 437
  • 1
  • 5
  • 22
  • You can use Scrollable widget for `Desktop View`, and for MobileView, you can use `Wrap` widget. – Md. Yeasin Sheikh Feb 09 '22 at 14:48
  • I tried but I failed to implement Scrollable widget. I don't know the right place and way to implement Scrollable widget with conditions. It would be very helpful if you can implement those widgets in the code. And footer and text buttons are already Wraped by Wrap widget. – M Nouman Feb 09 '22 at 14:50
  • If you get horizontal overflow error then refer my answer [here](https://stackoverflow.com/a/68646487/13997210) and if you get Vertical overflow error then Try to add your Inside Row widgets wrap it with `Expanded` or `Flexible` refer my answer [here](https://stackoverflow.com/a/68463935/13997210) or [here](https://stackoverflow.com/a/68559619/13997210) or [here](https://stackoverflow.com/a/68444861/13997210) or [here](https://stackoverflow.com/a/70743585/13997210) or [here](https://stackoverflow.com/a/70743585/13997210) hope its helpful to you – Ravindra S. Patil Feb 09 '22 at 16:09

1 Answers1

0

use SingleChildScrollView:

body: SingleChildScrollView(
        child:...
      )
Ma Jeed
  • 832
  • 1
  • 4
  • 12
  • when I use "SingleChildScrollView(child:Column...)" the screen goes blank and the terminal goes infinitely error loop... – M Nouman Feb 09 '22 at 15:02
  • what error message exactly? – Ma Jeed Feb 09 '22 at 15:14
  • `Another exception was thrown: 'package:flutter/src/rendering/mouse_tracker.dart': Failed assertion: line 201 pos 12: '!_debugDuringDeviceUpdate': is not true.` – M Nouman Feb 09 '22 at 15:18
  • `[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Cannot hit test a render box with no size.` – M Nouman Feb 09 '22 at 15:20
  • I used the same code but it didn't show me any error !!! have you used hot reload or hot restart? – Ma Jeed Feb 09 '22 at 15:30
  • Yes I even restarted vscode. But the errors are same. `Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#aa260 relayoutBoundary=up1 NEEDS-PAINT The Flutter DevTools debugger and profiler on Windows is available at: http://127.0.0.1:9101?uri=http://127.0.0.1:57673/6nThFfRHX0o=/` – M Nouman Feb 09 '22 at 15:33
  • btw Ma Jeed, the code that I provided here ,are only 2 dart files, and there are almost 10,12 dart files in my project. Also I'm running the code on windows, did you run the code on windows or chrome? – M Nouman Feb 09 '22 at 15:38
  • I used chrome, instead of SingleChildScrollView I used a ListView like this : ListView( children: [ SizedBox(...) , Column(...)]) – Ma Jeed Feb 09 '22 at 15:40
  • did u used `shrinkwrap:true` in listview? – M Nouman Feb 09 '22 at 15:41
  • yes i did : shrinkWrap : true, – Ma Jeed Feb 09 '22 at 15:43
  • let me try this ass well – M Nouman Feb 09 '22 at 15:43
  • `[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Null check operator used on a null value`. This the error after using `ListView(childeren:[SizedBox(),Column()])`.And on web screen the body has gone blank. Same for chrome and windows. – M Nouman Feb 09 '22 at 15:48
  • I guess the problem is in one of your files – Ma Jeed Feb 09 '22 at 15:54
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/241872/discussion-between-ma-jeed-and-m-nouman). – Ma Jeed Feb 09 '22 at 15:54
  • which files you didn't use from my code when you run on your side? – M Nouman Feb 09 '22 at 15:55
  • I didn't use any of your files except the Web_Screen Code and I replace all the widget with Icons – Ma Jeed Feb 09 '22 at 15:58