Config constructor

Config({
  1. bool? bloc,
  2. bool? riverpod,
  3. bool? getx,
})

Implementation

Config({this.bloc, this.riverpod, this.getx}) {
  if (bloc == null && riverpod == null && getx == null) {
    return;
  }
  // Only one of them should be true, handle it by converting true to 1 and false/null to 0
  final sum = (bloc == true ? 1 : 0) + (riverpod == true ? 1 : 0) + (getx == true ? 1 : 0);
  if (sum != 1) {
    throw ArgumentError(
      'Exactly one of "bloc", "riverpod", or "getx" must be true in the config section.',
    );
  }
}