[the external chain picture transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the picture and upload it directly (img-sge0hdn1-1628218026745)( https://ducafecat.tech/2021/08/06/translation/explore-customizable-time-planner-in-flutter/2021-08-06-06-28-32.png )]
Old iron remember to forward, brother old fellow will show more Flutter good text ~ ~ ~
Wechat group ducafecat
Station b https://space.bilibili.com/404904528
original text
https://medium.com/flutterdevs/explore-customizable-time-planner-in-flutter-c8108218b52c
reference resources
- https://pub.dev/packages/time_planner
text
[external chain picture transfer failed. The source station may have anti-theft chain mechanism. It is recommended to save the picture and upload it directly (img-kgg3guid-1628218026747)( https://ducafecat.tech/2021/08/06/translation/explore-customizable-time-planner-in-flutter/2021-08-06-06-05-41.png )]
From the beginning, Flutter was a great encounter. Building an engaging user interface has never been faster. Whether you are an amateur or an educated developer, it's not difficult to be hopelessly infatuated with fluent. All software developers understand that dates are the toughest thing. Similarly, the timetable is not an exception.
In mobile applications, there are many cases where users need to enter a date of birth, book air tickets, arrange meetings, and so on.
In this article, we will explore custom time planning Flutter. We will also implement a demo program and create a customizable time plan using the time planner package in your Flutter application.
https://pub.dev/packages/time_planner
Introduction
A pleasant, simple use, customized time planning for Flutter mobile, desktop and network. This is a widget that displays tasks to customers on a schedule. Each row displays an hour and each column displays a day, but you can change the title of the section and display anything else you need.
[the external chain picture transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the picture and upload it directly (IMG sipxggfa-1628218026748)( https://ducafecat.tech/2021/08/06/translation/explore-customizable-time-planner-in-flutter/2021-08-06-06-08-07.png )]
[external chain picture transfer failed. The source station may have anti-theft chain mechanism. It is recommended to save the picture and upload it directly (img-ybatapyj-1628218026749)( https://ducafecat.tech/2021/08/06/translation/explore-customizable-time-planner-in-flutter/2021-08-06-06-07-08.png )]
[the external chain picture transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the picture and upload it directly (img-cg4binfo-1628218026749)( https://ducafecat.tech/2021/08/06/translation/explore-customizable-time-planner-in-flutter/2021-08-06-06-07-33.png )]
[the external chain picture transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the picture and upload it directly (img-6dtwthct-1628218026750)( https://ducafecat.tech/2021/08/06/translation/explore-customizable-time-planner-in-flutter/2021-08-06-06-08-23.png )]
This demo video shows how to create a customizable schedule in fluent. It shows how a customized schedule will work using your Flutter application's schedule package. It shows that a random time planner will be created when the user clicks on any row or column. Animated. It will be displayed on your device.
attribute
The time planner has the following properties:
- startHour: this attribute is used to start the time from this. It will start from 1
- endHour: this property is used for the end of this time. The maximum value is 24
- headers: this attribute is used to create days. Every day is a timeplanertitle. You should create at least one day
- tasks: this attribute is used to list widgets on the time planner
- Style: this attribute is used for the style of the scheduler
- currentTimeAnimation: this property is used to scroll the widget load to the current time of the animation. The default value is true
Implementation
- Step 1: add dependencies
Add dependencies to the pubspec(yaml file.
time_planner: ^0.0.3
- Step 2: Import
import 'package:time_planner/time_planner.dart';
- Step 3: run the fluent package in the root directory of the application.
flutter packages get
code
You need to implement it in your code:
In the lib folder, create a file named main New dart file for dart.
First, we create a timeplanner task list called variable task.
List<TimePlannerTask> tasks = [];
We will create a_ addobject() method.
void _addObject(BuildContext context) { List<Color?> colors = [ Colors.purple, Colors.blue, Colors.green, Colors.orange, Colors.cyan ]; setState(() { tasks.add( TimePlannerTask( color: colors[Random().nextInt(colors.length)], dateTime: TimePlannerDateTime( day: Random().nextInt(10), hour: Random().nextInt(14) + 6, minutes: Random().nextInt(60)), minutesDuration: Random().nextInt(90) + 30, daysDuration: Random().nextInt(4) + 1, onTap: () { ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text('You click on time planner object'))); }, child: Text( 'this is a demo', style: TextStyle(color: Colors.grey[350], fontSize: 12), ), ), ); }); ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text('Random task added to time planner!'))); }
In the function, we will add tasks Add() method. Internally, we will add the timeplanertask () widget. In this widget, we will add color, date time, minutesDuration and daysDuration. We will also display the snapbar message when the user clicks on the time planner.
In the body, we will add the TimePlanner () widget. Internally, we will add startHour, endHour, and header. In the header file, we will add some timeplanertitle (). In addition, we will add tasks and styles.
TimePlanner( startHour: 2, endHour: 24, headers: [ TimePlannerTitle( date: "7/20/2021", title: "tuesday", ), TimePlannerTitle( date: "7/21/2021", title: "wednesday", ), TimePlannerTitle( date: "7/22/2021", title: "thursday", ), TimePlannerTitle( date: "7/23/2021", title: "friday", ), TimePlannerTitle( date: "7/24/2021", title: "saturday", ), TimePlannerTitle( date: "7/25/2021", title: "sunday", ), TimePlannerTitle( date: "7/26/2021", title: "monday", ), TimePlannerTitle( date: "7/27/2021", title: "tuesday", ), TimePlannerTitle( date: "7/28/2021", title: "wednesday", ), TimePlannerTitle( date: "7/29/2021", title: "thursday", ), TimePlannerTitle( date: "7/30/2021", title: "friday", ), TimePlannerTitle( date: "7/31/2021", title: "Saturday", ), ], tasks: tasks, style: TimePlannerStyle( showScrollBar: true ), ),
Now we will create a floating actionbutton ().
floatingActionButton: FloatingActionButton( onPressed: () => _addObject(context), tooltip: 'Add random task', child: Icon(Icons.add), ),
When we run the application, we should get the output of the screen, just like the screenshot below.
[the external chain picture transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the picture and upload it directly (img-uodux2cf-1628218026750)( https://ducafecat.tech/2021/08/06/translation/explore-customizable-time-planner-in-flutter/2021-08-06-06-15-06.png )]
Code File
import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_customizable_time_plan/splash_screen.dart'; import 'package:time_planner/time_planner.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData.dark(), home: Splash() ); } } 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> { List<TimePlannerTask> tasks = []; void _addObject(BuildContext context) { List<Color?> colors = [ Colors.purple, Colors.blue, Colors.green, Colors.orange, Colors.cyan ]; setState(() { tasks.add( TimePlannerTask( color: colors[Random().nextInt(colors.length)], dateTime: TimePlannerDateTime( day: Random().nextInt(10), hour: Random().nextInt(14) + 6, minutes: Random().nextInt(60)), minutesDuration: Random().nextInt(90) + 30, daysDuration: Random().nextInt(4) + 1, onTap: () { ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text('You click on time planner object'))); }, child: Text( 'this is a demo', style: TextStyle(color: Colors.grey[350], fontSize: 12), ), ), ); }); ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text('Random task added to time planner!'))); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( automaticallyImplyLeading: false, title: Text(widget.title), centerTitle: true, ), body: Center( child: TimePlanner( startHour: 2, endHour: 24, headers: [ TimePlannerTitle( date: "7/20/2021", title: "tuesday", ), TimePlannerTitle( date: "7/21/2021", title: "wednesday", ), TimePlannerTitle( date: "7/22/2021", title: "thursday", ), TimePlannerTitle( date: "7/23/2021", title: "friday", ), TimePlannerTitle( date: "7/24/2021", title: "saturday", ), TimePlannerTitle( date: "7/25/2021", title: "sunday", ), TimePlannerTitle( date: "7/26/2021", title: "monday", ), TimePlannerTitle( date: "7/27/2021", title: "tuesday", ), TimePlannerTitle( date: "7/28/2021", title: "wednesday", ), TimePlannerTitle( date: "7/29/2021", title: "thursday", ), TimePlannerTitle( date: "7/30/2021", title: "friday", ), TimePlannerTitle( date: "7/31/2021", title: "Saturday", ), ], tasks: tasks, style: TimePlannerStyle( showScrollBar: true ), ), ), floatingActionButton: FloatingActionButton( onPressed: () => _addObject(context), tooltip: 'Add random task', child: Icon(Icons.add), ), ); } }
epilogue
In this article, I have simply explained the basic structure of the Customizable Time Planner; You can modify this code according to your choice. This is a small-scale introduction to custom time planning for user interaction. From my side, it works using fluent.
© Cat brother
https://ducafecat.tech/
https://github.com/ducafecat
Previous period
Open Source
GetX Quick Start
https://github.com/ducafecat/getx_quick_start
News client
https://github.com/ducafecat/flutter_learn_news
Translation of strapi manual
https://getstrapi.cn
Wechat discussion group ducafecat
Series collection
translation
https://ducafecat.tech/categories/%E8%AF%91%E6%96%87/
Open source project
https://ducafecat.tech/categories/%E5%BC%80%E6%BA%90/
Basics of Dart programming language
https://space.bilibili.com/404904528/channel/detail?cid=111585
Introduction to Flutter zero Foundation
https://space.bilibili.com/404904528/channel/detail?cid=123470
Flutter actual combat news client from scratch
https://space.bilibili.com/404904528/channel/detail?cid=106755
Fluent component development
https://space.bilibili.com/404904528/channel/detail?cid=144262
Flutter Bloc
https://space.bilibili.com/404904528/channel/detail?cid=177519
Flutter Getx4
https://space.bilibili.com/404904528/channel/detail?cid=177514
Docker Yapi
https://space.bilibili.com/404904528/channel/detail?cid=130578