in Education by
I am currently working on a Flutter app, and I have the screen divided into two regions. The left region takes up about 1/3 of the screen width, while the right region takes up the other 2/3 of the width. Here is a depiction: In section "A", I have a custom "tree view" widget that is based on a DataTable. It allows the user to expand/collapse parts of the tree. The tree view is also scrollable in both the horizontal and vertical directions, just in case it consumes more screen real estate than is available in region A. Currently, if the tree view doesn't consume the entire height of region A, then the horizontal scroll bar at the bottom of the tree view simply appears at the bottom of the tree view, as depicted in the following image: However, this is not where I want the horizontal scroll bar to be placed. I want it at the bottom of the window, regardless of the size of the tree view widget, as depicted in the following image: The code for my widget tree is as follows: @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text(widget.title, style: const TextStyle(color: Colors.white))), body: Row( children: [ Expanded(flex: 1, child: Align( alignment: Alignment.topLeft, child: Container( height: double.infinity, color: Colors.white, child: Scrollbar( scrollbarOrientation: ScrollbarOrientation.right, isAlwaysShown: false, child: SingleChildScrollView( scrollDirection: Axis.vertical, child: Scrollbar( isAlwaysShown: false, scrollbarOrientation: ScrollbarOrientation.bottom, child: SingleChildScrollView( scrollDirection: Axis.horizontal, child: TreeViewWidget( model: model, dataheader_color: const Color.fromARGB(255, 230, 230, 230), tree_expander_style: TreeExpanderStyle.PlusMinusOutlined, show_header_row: true ), ) ) ) ) ) ) ), Expanded(flex: 2, child: Column( children: const [ ], ) ) ] ) ); } How can I get the horizontal scroll bar to correctly place itself at the bottom of the window, rather than immediately below the tree view widget? Thanks for any help! JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
If you want to support both horizontal and vertical scrollbars, it's probably easiest to use a library, for example cross_scroll or adaptive_scrollbar, to name a few. I recommend you check out those packages or find other packages, instead of writing your own. If you really want to do it yourself, you can try to lift up the Scrollbar to be outside of your Container, but make sure you use a ScrollController to connect them. For example (modified from the code in your question): import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: const MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({Key? key, required this.title}) : super(key: key); final String title; @override State createState() => _MyHomePageState(); } class _MyHomePageState extends State { final _controller = ScrollController(); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('demo')), body: Padding( padding: const EdgeInsets.all(20.0), child: Row( children: [ Expanded( flex: 2, child: Scrollbar( // <-- move the scroll bar here controller: _controller, // <-- controller isAlwaysShown: true, scrollbarOrientation: ScrollbarOrientation.bottom, child: Container( height: double.infinity, color: Colors.yellow, child: SingleChildScrollView( controller: _controller, // <-- controller scrollDirection: Axis.horizontal, child: Scrollbar( isAlwaysShown: true, scrollbarOrientation: ScrollbarOrientation.right, child: SingleChildScrollView( scrollDirection: Axis.vertical, child: Container( color: Colors.blue, width: 1000, height: 300, ), ), ), ), ), ), ), Expanded( flex: 1, child: Container( color: Colors.red, child: FlutterLogo(), ), ), ], ), ), ); } }

Related questions

0 votes
    Write code in HTML to divide the browser window into 3 horizontal sections and display college name in the top most frame. Select the correct answer from above options...
asked Dec 22, 2021 in Education by JackTerrance
0 votes
    tag produces a horizontal line in the browser window. C. a. b. d. Select the correct answer from above options...
asked Dec 9, 2021 in Education by JackTerrance
0 votes
    I know how to do custom drawing of a standalone Windows Forms ScrollBar because there are plenty of examples ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    I've found the following CSS code that I pasted in the child theme's css stylesheet, but it doesn ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    I've found the following CSS code that I pasted in the child theme's css stylesheet, but it doesn ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 13, 2022 in Education by JackTerrance
0 votes
    1. A bar that displays the namesof all the open windows at the bottom of the desktop Select the correct answer from above options...
asked Dec 20, 2021 in Education by JackTerrance
0 votes
    You can create your own style by clicking on the __________ button located at the bottom of style pane. * a.style ... d.none of these Select the correct answer from above options...
asked Dec 15, 2021 in Education by JackTerrance
0 votes
    To exert control, you mentioned intervening top to bottom. Is that with AAD at the top and SharePoint sites at the bottom?...
asked Mar 10, 2021 in Technology by JackTerrance
0 votes
    Here some snippet of my code. when first time RecyclerView create I have to used recyclerView.scrollToPosition( ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    write a C program to Read a number.Find sum of digit at even position in a number and multiplication of digit ... position in a number. Select the correct answer from above options...
asked Dec 13, 2021 in Education by JackTerrance
0 votes
    write a C program to Read a number . find sum of digit at even position in a number and multiplication of ... position in a number. Select the correct answer from above options...
asked Dec 13, 2021 in Education by JackTerrance
0 votes
    In the circuit shown below, switch K is moved from position to position 2 at time t = 0. At time t = ... Questions for GATE EC Exam, Network Theory MCQ (Multiple Choice Questions)...
asked Oct 16, 2021 in Education by JackTerrance
0 votes
    This question already has answers here: Order Bars in ggplot2 bar graph (14 answers) Closed 3 years ago. I ... -interventions", "Compliance", "Timing of outcome assessments" data...
asked Jun 1, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Order Bars in ggplot2 bar graph (14 answers) Closed 3 years ago. I ... -interventions", "Compliance", "Timing of outcome assessments" data...
asked May 19, 2022 in Education by JackTerrance
...