flutter_agenda 1.0.4 flutter_agenda: ^1.0.4 copied to clipboard
Agenda Widget Package for Flutter
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:flutter_agenda/flutter_agenda.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(primarySwatch: Colors.blue),
home: AgendaScreen(),
);
}
}
class AgendaScreen extends StatefulWidget {
AgendaScreen({Key? key}) : super(key: key);
@override
_AgendaScreenState createState() => _AgendaScreenState();
}
late List<Pillar> resources = <Pillar>[];
class _AgendaScreenState extends State<AgendaScreen> {
@override
void initState() {
super.initState();
resources = [
Pillar(
head: PillarHead(name: 'Resource 1'.toUpperCase(), object: 1),
events: [
AgendaEvent(
title: 'Meeting D',
subtitle: 'MD',
start: EventTime(hour: 8, minute: 0),
end: EventTime(hour: 8, minute: 30),
),
AgendaEvent(
title: 'Meeting Z',
subtitle: 'MZ',
start: EventTime(hour: 12, minute: 0),
end: EventTime(hour: 13, minute: 20),
),
],
),
Pillar(
head: PillarHead(name: 'Resource 2'.toUpperCase(), object: 2),
events: [
AgendaEvent(
title: 'Meeting G',
subtitle: 'MG',
start: EventTime(hour: 9, minute: 10),
end: EventTime(hour: 11, minute: 45),
),
],
),
Pillar(
head: PillarHead(
name: 'Resource 3'.toUpperCase(), object: 3, textColor: Colors.red),
events: [
AgendaEvent(
title: 'Meeting A',
subtitle: 'MA',
start: EventTime(hour: 10, minute: 10),
end: EventTime(hour: 11, minute: 45),
onTap: () {
print("meeting A Details");
},
),
],
),
];
}
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: AgendaView(
agendaStyle: AgendaStyle(timeItemHeight: 80),
pillarList: resources,
onClick: (eventTime, object) {
print("Clicked time: ${eventTime.hour}:${eventTime.minute}");
print("Head Object related to the resource: $object");
},
),
),
);
}
}