title: How to disable future dates in Android MaterialDatePicker?
body: <p>I am trying to create a simple DatePicker using MaterialDatePicker where future dates are disabled. I tried few answers from other similar StackOverflow questions but it didn't work. This is my code so far:-</p>
  <pre><code>val datePicker = MaterialDatePicker.Builder.datePicker().apply {
          setTitleText(getString(R.string.label_select_dob))
          setCalendarConstraints(limitRange().build())
      }.build()
  
   private fun limitRange(): CalendarConstraints.Builder {
      val calendarStart: Calendar = Calendar.getInstance()
      val calendarEnd: Calendar = Calendar.getInstance()
      val year = 1900
      val startMonth = 1
      val startDate = 1
      calendarStart.set(year, startMonth, startDate)
      calendarEnd.set(2021, 3, 27)
      val minDate: Long = calendarStart.timeInMillis
      val maxDate: Long = calendarEnd.timeInMillis
  
      val constraintsBuilder = CalendarConstraints.Builder()
      val validators: ArrayList&lt;CalendarConstraints.DateValidator&gt; = ArrayList()
      validators.add(DateValidatorPointForward.from(minDate))
      validators.add(DateValidatorPointBackward.before(maxDate))
      constraintsBuilder.setValidator(CompositeDateValidator.allOf(validators))
  
      return constraintsBuilder
  }
  </code></pre>