如何获得RenderFlex溢出值

时间:2019-09-17 15:24:34

标签: flutter dart flutter-layout

我正在构建一个带有抖动的应用程序,并且在我的一个屏幕上,我有一个带有列的页面。我想在RenderFlex溢出的任何时候将列更改为ListView,是否有任何方法可以监听RenderFlex溢出或任何其他解决此问题的方法。

我已经能够实现与设备定向类似的代码:

class MightScrollBaseScaffold extends StatefulWidget {
  const MightScrollBaseScaffold({
    Key key,
    this.appBar,
    this.children,
    this.selectedIndex,
    this.hasBottomNavBar,
  }) : super(key: key);
  final AppBar appBar;
  final List<Widget> children;
  final int selectedIndex;
  final bool hasBottomNavBar;

  @override
  _MightScrollBaseScaffoldState createState() =>
      _MightScrollBaseScaffoldState();
}

class _MightScrollBaseScaffoldState extends State<MightScrollBaseScaffold> {
  @override
  Widget build(BuildContext context) {
    final Orientation orientation = MediaQuery.of(context).orientation;

    final Widget body = SafeArea(
      child: orientation == Orientation.portrait
          ? Column(
              children: widget.children,
            )
          : ListView(
              children: widget.children,
            ),
    );

    return LayoutBuilder(
        builder: (BuildContext context, BoxConstraints constraints) {
      print(constraints);
      print(kDeviceDimensions(context));
      return widget.hasBottomNavBar
          ? BaseScaffold(
              selectedIndex: widget.selectedIndex,
              appBar: widget.appBar,
              body: body,
            )
          : Scaffold(
              extendBody: true,
              appBar: widget.appBar,
              body: body,
            );
    });
  }
}

我想要RenderFlex问题。

0 个答案:

没有答案