gpt4 book ai didi

Flutter - 事件/时间线预约排版问题

转载 作者:行者123 更新时间:2023-12-05 02:56:46 25 4
gpt4 key购买 nike

这里是 Flutter 新手,

我们正在尝试创建一个简单的预约应用程序以在我们的诊所中使用,如果您能提供一些有关如何进行此操作的建议,我们将不胜感激。我已经包含了我们正在努力实现的模型 here .

我们需要多个列 - 每个医生工作一列,时间线显示固定在左侧的小时数。约会从 10 分钟到 1 小时不等,我们需要能够选择它们进行编辑。除此之外,能够选择一个单元格(即:双击以添加新约会)是我们想要实现的一项功能。此外,同一列中的约会不能重叠。

我们查看了以下内容:- Flutter 表格布局- 带有卡片的单独列(相对于预订时间对齐)- 自定义画家- 网格布局

我们已经下载了一些软件包,例如 SyncFusion 日历和时间线应用程序,并将它们分开。然而,在我们陷入困境之前,任何建议都会很棒。

谢谢你的时间

最佳答案

您可以在下面复制粘贴运行完整代码
您可以使用包 https://pub.dev/packages/flutter_week_view
代码片段

    return WeekView(
dates: [date.subtract(const Duration(days: 1)), date, date.add(const Duration(days: 1))],
events: [
FlutterWeekViewEvent(
title: 'An event 1',
description: 'A description 1',
start: date.subtract(const Duration(hours: 1)),
end: date.add(const Duration(hours: 18, minutes: 30)),
),
FlutterWeekViewEvent(
title: 'An event 2',
description: 'A description 2',
start: date.add(const Duration(hours: 19)),
end: date.add(const Duration(hours: 22)),
),

工作演示

enter image description here

完整代码

import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart' as launcher;
import 'package:flutter_week_view/flutter_week_view.dart';

/// First plugin test method.
void main() => runApp(_FlutterWeekViewDemoApp());

/// The demo material app.
class _FlutterWeekViewDemoApp extends StatelessWidget {
@override
Widget build(BuildContext context) => MaterialApp(
title: 'Flutter Week View Demo',
initialRoute: '/',
routes: {
'/': (context) => inScaffold(body: _FlutterWeekViewDemoAppBody()),
'/day-view': (context) => inScaffold(
title: 'Demo day view',
body: _DemoDayView(),
),
'/week-view': (context) => inScaffold(
title: 'Demo week view',
body: _DemoWeekView(),
),
},
);

static Widget inScaffold({
String title = 'Flutter Week View',
@required Widget body,
}) =>
Scaffold(
appBar: AppBar(
title: Text(title),
),
body: body,
);
}

/// The demo app body widget.
class _FlutterWeekViewDemoAppBody extends StatelessWidget {
@override
Widget build(BuildContext context) {
String github = 'https://github.com/Skyost/FlutterWeekView';
return Padding(
padding: const EdgeInsets.all(30),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 40),
child: Text(
'Flutter Week View demo',
style: Theme.of(context).textTheme.display1,
textAlign: TextAlign.center,
),
),
RaisedButton(
child: const Text('Demo day view'),
onPressed: () => Navigator.pushNamed(context, '/day-view'),
),
RaisedButton(
child: const Text('Demo week view'),
onPressed: () => Navigator.pushNamed(context, '/week-view'),
),
const Expanded(
child: SizedBox.expand(),
),
GestureDetector(
onTap: () async {
if (await launcher.canLaunch(github)) {
await launcher.launch(github);
}
},
child: Text(
github,
style: TextStyle(
decoration: TextDecoration.underline,
color: Colors.blue[800],
),
textAlign: TextAlign.center,
),
),
],
),
),
);
}
}

/// The demo day view widget.
class _DemoDayView extends StatelessWidget {
@override
Widget build(BuildContext context) {
DateTime now = DateTime.now();
DateTime date = DateTime(now.year, now.month, now.day);
return DayView(
date: now,
events: [
FlutterWeekViewEvent(
title: 'An event 1',
description: 'A description 1',
start: date.subtract(const Duration(hours: 1)),
end: date.add(const Duration(hours: 18, minutes: 30)),
),
FlutterWeekViewEvent(
title: 'An event 2',
description: 'A description 2',
start: date.add(const Duration(hours: 19)),
end: date.add(const Duration(hours: 22)),
),
FlutterWeekViewEvent(
title: 'An event 3',
description: 'A description 3',
start: date.add(const Duration(hours: 23, minutes: 30)),
end: date.add(const Duration(hours: 25, minutes: 30)),
),
FlutterWeekViewEvent(
title: 'An event 4',
description: 'A description 4',
start: date.add(const Duration(hours: 20)),
end: date.add(const Duration(hours: 21)),
),
FlutterWeekViewEvent(
title: 'An event 5',
description: 'A description 5',
start: date.add(const Duration(hours: 20)),
end: date.add(const Duration(hours: 21)),
),
],
currentTimeCircleColor: Colors.pink,
);
}
}

/// The demo week view widget.
class _DemoWeekView extends StatelessWidget {
@override
Widget build(BuildContext context) {
DateTime now = DateTime.now();
DateTime date = DateTime(now.year, now.month, now.day);
return WeekView(
dates: [date.subtract(const Duration(days: 1)), date, date.add(const Duration(days: 1))],
events: [
FlutterWeekViewEvent(
title: 'An event 1',
description: 'A description 1',
start: date.subtract(const Duration(hours: 1)),
end: date.add(const Duration(hours: 18, minutes: 30)),
),
FlutterWeekViewEvent(
title: 'An event 2',
description: 'A description 2',
start: date.add(const Duration(hours: 19)),
end: date.add(const Duration(hours: 22)),
),
FlutterWeekViewEvent(
title: 'An event 3',
description: 'A description 3',
start: date.add(const Duration(hours: 23, minutes: 30)),
end: date.add(const Duration(hours: 25, minutes: 30)),
),
FlutterWeekViewEvent(
title: 'An event 4',
description: 'A description 4',
start: date.add(const Duration(hours: 20)),
end: date.add(const Duration(hours: 21)),
),
FlutterWeekViewEvent(
title: 'An event 5',
description: 'A description 5',
start: date.add(const Duration(hours: 20)),
end: date.add(const Duration(hours: 21)),
),
],
);
}
}

关于Flutter - 事件/时间线预约排版问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60198743/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com