【发布时间】:2021-06-03 14:48:28
【问题描述】:
我正在 Flutter 中尝试预约视图。所有小部件最初放置正常,但是当我滚动列表视图(可用时间列表)时,滚动动画会干扰放置在其顶部的元素(日历)。我知道我可以使用下拉列表,但我更喜欢列表。我已经尝试了 StackOverflow 的几个想法,但仍然无法使其正常工作
图片供参考:
//simple calender
import 'package:flutter/material.dart';
import 'package:hswebapp/days.dart';
import 'package:hswebapp/hours.dart';
import 'package:table_calendar/table_calendar.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Appointment view',
theme: ThemeData(
primarySwatch: Colors.purple,
),
home: MyHomePage(title: 'Appointment view'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
CalendarFormat _calendarFormat = CalendarFormat.twoWeeks;
DateTime _focusedDay = DateTime.now();
DateTime? _selectedDay;
DateTime kFirstDay = DateTime.utc(2021, 1, 15);
DateTime kLastDay = DateTime.utc(2022, 1, 20);
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(
title: Text('TableCalendar - Basics'),
),
body: SafeArea(
child: Column(
children: <Widget>[
daysCalender(),
Text("Available Hours"),
const SizedBox(
height: 10,
),
SingleChildScrollView(
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(
height: 150,
child:
AvailableHours(),
)
],
) // your column1
),
),
TextFormField(
decoration: InputDecoration(
border: UnderlineInputBorder(), labelText: 'Name'),
),
TextFormField(
decoration: InputDecoration(
border: UnderlineInputBorder(), labelText: 'Phone'),
),
TextButton(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.all<Color>(Colors.blue),
),
onPressed: () {},
child: Text('Confirm'),
)
],
),
)
);
}
}
【问题讨论】: