33 lines
964 B
Dart
33 lines
964 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:taafee_mobile/features/card/presentation_layer/widgets/first_card.dart';
|
|
import 'package:taafee_mobile/features/card/presentation_layer/widgets/my_card.dart';
|
|
import 'package:taafee_mobile/features/card/presentation_layer/widgets/second_card.dart';
|
|
import 'dart:math';
|
|
|
|
import '../../data_layer/model/card_model.dart';
|
|
|
|
class RandomCardWidget extends StatelessWidget {
|
|
RandomCardWidget(this.cardModel, {super.key});
|
|
final Random random = Random(5);
|
|
final CardModel cardModel;
|
|
|
|
int getRandomInt(int max) {
|
|
return random.nextInt(max);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
int randomResult = getRandomInt(10);
|
|
|
|
if (cardModel.cardImages.isEmpty) {
|
|
return MyCardWidget(cardModel);
|
|
} else {
|
|
if (randomResult >= 0 && randomResult <= 2) {
|
|
return FirstCardWidget(cardModel);
|
|
} else {
|
|
return SecondCardWidget(cardModel);
|
|
}
|
|
}
|
|
}
|
|
}
|