Comments (7)
Try something along these lines:
singleMarkerBuilder: (context, date, event) {
final color = (event as YourEventClass).type == YourEventType.available ? Colors.indigo : Colors.red[700];
return Container(
width: 10.0,
height: 10.0,
color: color,
margin: const EdgeInsets.symmetric(horizontal: 1.5),
);
},
from table_calendar.
Try something along these lines:
singleMarkerBuilder: (context, date, event) { final color = (event as YourEventClass).type == YourEventType.available ? Colors.indigo : Colors.red[700]; return Container( width: 10.0, height: 10.0, color: color, margin: const EdgeInsets.symmetric(horizontal: 1.5), ); },
is posible to have this implemented in example calendar?
i dont know how i can implement in calendar for diferents events
thank you
from table_calendar.
There you go guys.
Step 1 - Event class:
class Event {
final String text;
final EventStatus status;
const Event({
@required this.text,
this.status = EventStatus.idle,
});
}
enum EventStatus {
idle,
active,
important,
}
Step 2 - Prepare events map using Event class:
_events = {
DateTime(2019, 8, 20): [
Event(text: 'Event A0', status: EventStatus.active),
Event(text: 'Event B0'),
Event(text: 'Event C0'),
],
DateTime(2019, 8, 21): [
Event(text: 'Event A1', status: EventStatus.important),
],
DateTime(2019, 8, 22): [
Event(text: 'Event A2', status: EventStatus.important),
Event(text: 'Event B2', status: EventStatus.active),
],
};
Step 3 - Retrieve data in singleMarkerBuilder:
singleMarkerBuilder: (context, date, event) {
final color = (event as Event).status == EventStatus.important ? Colors.red[700] : Colors.indigo;
return Container(
width: 10.0,
height: 10.0,
color: color,
margin: const EdgeInsets.symmetric(horizontal: 1.5),
);
},
Of course adapt this short example to your needs.
from table_calendar.
I also need an example, it was hard to understand for me.
from table_calendar.
I did it! I passed a template of my calendar item, containing color ... in the event I can redeem the color.
builders: CalendarBuilders(
singleMarkerBuilder: (context, date, event) {
Color cor = Color.fromRGBO(event.color);
return Container(
decoration: BoxDecoration(shape: BoxShape.circle, color: cor),
width: 7.0,
height: 7.0,
margin: const EdgeInsets.symmetric(horizontal: 1.5),
);
},
),
from table_calendar.
@aleksanderwozniak if i want that every days of table_calendar be marked with diferents color how can i do ?
from table_calendar.
@FranciscoJose00MF
You can use DayBuilder
for that:
dayBuilder: (context, date, events) {
final random = Random();
final color = Color.fromRGBO(random.nextInt(255), random.nextInt(255), random.nextInt(255), 1.0);
return Container(
margin: const EdgeInsets.all(4.0),
color: color,
width: 100,
height: 100,
child: Text('${date.day}'),
);
},
from table_calendar.
Related Issues (20)
- show grid line of each cell(weekdays dow and date) HOT 1
- Feature Request: Semantics support
- Personalize text language
- Allow Removable of a Day in the Calendar
- We should support vertical scroll also.
- Add Month and year picker on header when pick date
- Today style is not applied if the tile is disabled HOT 1
- missing onVisibleDaysChanged HOT 1
- TableCalendar inside CustomScrollView HOT 1
- Not compatible with intl 0.19.0 HOT 2
- Incorrect behavior when firstDay parameter changes HOT 1
- How to add 29 days in February every year? HOT 1
- Responsive layout for both Width and Height
- How to get visible first day and last day on format change?
- Timezone issue HOT 2
- Line separator between month name and daysOfWeek HOT 1
- How to drag and select range?Is that supported. HOT 1
- The following assertion was thrown building AnimatedContainer(duration: 250ms, Alignment.center, padding: EdgeInsets.zero, bg: BoxDecoration(color: Color(0xff6262d5), borderRadius: BorderRadius.circular(10.0)), margin: EdgeInsets.all(6.0), clipBehavior: Clip.none, dirty, state: _AnimatedContainerState#d3f3a(ticker active, AlignmentGeometryTween(Alignment.center → Alignment.center), padding: EdgeInsetsGeometryTween(EdgeInsets.zero → EdgeInsets.zero), bg: DecorationTween(BoxDecoration(shape: circle) → BoxDecoration(color: Color(0xff6262d5), borderRadius: BorderRadius.circular(10.0))), margin: EdgeInsetsGeometryTween(EdgeInsets.all(6.0) → EdgeInsets.all(6.0)))): 'package:flutter/src/painting/box_decoration.dart': Failed assertion: line 128 pos 12: 'shape != BoxShape.circle || borderRadius == null': is not true. HOT 2
- Please upgrade intl HOT 1
- Is this repo abandoned? Recommended alternatives? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from table_calendar.