简体   繁体   English

如何在 Flutter 的 SingleChildScrollView 内滚动小部件?

[英]How to scroll a widget inside a SingleChildScrollView in Flutter?

I have pdf viewer inside the SingleChildScrollView.我在 SingleChildScrollView 中有 pdf 查看器。 Pdf viewer does not scroll only Column does. Pdf 查看器不会仅滚动列。 How do I make it that Column will be able to scroll and also the pdf will be able to scroll?如何使 Column 能够滚动并且 pdf 也能够滚动?

return Scaffold(
        appBar: AppBar(
          title: const Text('Nahranie súboru'),
          automaticallyImplyLeading: false,
        ),
        body: SingleChildScrollView(
          physics: const NeverScrollableScrollPhysics(),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
              SizedBox(
               child: SfPdfViewer.file(file), 
               height: 200, 
               width: double.infinity
              ),
              const SizedBox(height: 10),
              const PayRadioGroup(),
              const SizedBox(height: 10),
              const PayList(),
              const SizedBox(height: 10),
              ElevatedButton(
                  onPressed: () => uploadData(),
                  child: const Text('Odoslať Dáta'),
              ),
            ],
          ),
        ),
      );

Try without a sized box for the pdf.尝试不使用 pdf 的大小盒。

return Scaffold(
        appBar: AppBar(
          title: const Text('Nahranie súboru'),
          automaticallyImplyLeading: false,
        ),
        body: SingleChildScrollView(
          child: Column(
            mainAxisSize : MainAxisSize.min
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
               SfPdfViewer.file(file), 
              const SizedBox(height: 10),
              const PayRadioGroup(),
              const SizedBox(height: 10),
              const PayList(),
              const SizedBox(height: 10),
              ElevatedButton(
                  onPressed: () => uploadData(),
                  child: const Text('Odoslať Dáta'),
              ),
            ],
          ),
        ),
      );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何滚动到 flutter web 中 SingleChildScrollView 内的小部件? - How to scroll to a widget inside the SingleChildScrollView in flutter web? 如何使用 SingleChildScrollView 在 Flutter 中滚动到特定的 Widget - How To Scroll To A Specific Widget in Flutter Using SingleChildScrollView 如何在 Flutter 中的 SingleChildScrollView 内自动滚动到 position - How to Automaticallly scroll to a position of a Row inside SingleChildScrollView in Flutter Flutter SingleChildScrollView 内的列不滚动 - Flutter Column inside SingleChildScrollView doesn't scroll 如何在 SingleChildScrollView 内的列内居中小部件 - How to center a widget inside a column inside of a SingleChildScrollView 如何使用 flutter 中的“SingleChildScrollView”小部件在“DataTable”中应用水平和垂直滚动? - How to apply both horizontal and vertical scroll in `DataTable` using `SingleChildScrollView` widget in flutter? AlignParentBottom 在 SingleChildScrollView flutter 中的小部件 - AlignParentBottom a widget in SingleChildScrollView flutter 扑。 SingleChildScrollView 不会滚动到定位小部件中 - Flutter. SingleChildScrollView doesn't scroll into Positioned widget Flutter - SingleChildScrollView 固定小部件 - Flutter - SingleChildScrollView fixed widget Flutter:如何自动滚动到 SingleChildScrollView 的末尾 - Flutter : How to Automaticallly scroll to end of SingleChildScrollView
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM