import 'package:flutter/foundation.dart';


class CarouselIndexController with ChangeNotifier {
  int _index = 0;

  int get index => _index;

  void setIndex(int value, int max) {
    final next = value.clamp(0, max > 0 ? max - 1 : 0);
    if (next == _index) return;
    _index = next;
    notifyListeners();
  }

  void reset() {
    if (_index == 0) return;
    _index = 0;
    notifyListeners();
  }
}
