简体   繁体   中英

flutter SingleChildScrollView and Column position

I have one problem.

My app is SingleChildScrollView -> column -> children: A,B(variable height),C

I expcted

If A,B,C not overflow.
C position is bottom of screen.

If A,B,C overflow.
C position is tail of content.

but it's not work.

I can't use flexible, spacer..etc.. because SingleChildScrollView

How can do that? 在此处输入图片说明

as an option

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: SafeArea(child: SomeWidget()),
      ),
    );
  }
}

class SomeWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return CustomScrollView(
      slivers: <Widget>[
        SliverToBoxAdapter(
          child: Container(
            height: 340,
            color: Colors.red[200],
          ),
        ),
        SliverToBoxAdapter(
          child: Container(
            height: 620,
            color: Colors.orange[200],
          ),
        ),
        SliverFillRemaining(
          hasScrollBody: false,
          child: Align(
            alignment: Alignment.bottomCenter,
            child: Container(
              height: 80,
              color: Colors.green[200],
            ),
          ),
        ),
      ],
    );
  }
}

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM