GithubHelp home page GithubHelp logo

Comments (7)

aleksanderwozniak avatar aleksanderwozniak commented on May 12, 2024 3

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.

limdnas avatar limdnas commented on May 12, 2024 1

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.

aleksanderwozniak avatar aleksanderwozniak commented on May 12, 2024 1

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.

fabianogadenz avatar fabianogadenz commented on May 12, 2024

I also need an example, it was hard to understand for me.

from table_calendar.

fabianogadenz avatar fabianogadenz commented on May 12, 2024

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.

france00mf avatar france00mf commented on May 12, 2024

@aleksanderwozniak if i want that every days of table_calendar be marked with diferents color how can i do ?

from table_calendar.

aleksanderwozniak avatar aleksanderwozniak commented on May 12, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.