在這里提供一個(gè)demo
import 'package:flutter/material.dart';
class BottomButtonPage extends StatelessWidget {
const BottomButtonPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('底部滾動(dòng)按鈕示例'),
),
body: SafeArea(
child: Row(
children: [
const Expanded(
child: ScrollWidget(
count: 10,
)),
Container(
width: 1,
height: double.infinity,
color: Colors.amber,
),
const Expanded(
child: ScrollWidget(
count: 5,
))
],
),
),
);
}
}
class ScrollWidget extends StatelessWidget {
final int count;
const ScrollWidget({required this.count,super.key});
@override
Widget build(BuildContext context) {
return CustomScrollView(
slivers: [
SliverList.builder(
itemCount: count,
itemBuilder: (BuildContext context, int index) {
return const FlutterLogo(
size: 100,
);
}),
SliverFillRemaining(
hasScrollBody: false,
child: Align(
alignment: Alignment.bottomCenter,
child: Container(
padding: const EdgeInsets.fromLTRB(15, 15, 15, 0),
width: double.infinity,
child: ElevatedButton(
onPressed: () {},
style: ButtonStyle(
foregroundColor: WidgetStateProperty.all(Colors.white),
backgroundColor:
WidgetStateProperty.all(Colors.blueAccent)),
child: const Text('提交'),
)),
),
)
],
);
}
}