Jisho-Study-Tool/lib/components/search/search_results_body/parts/jlpt_badge.dart

26 lines
597 B
Dart
Raw Permalink Normal View History

2021-04-11 01:48:43 +02:00
import 'package:flutter/material.dart';
2024-11-13 22:43:44 +01:00
import 'circle_badge.dart';
2021-04-11 01:48:43 +02:00
class JLPTBadge extends StatelessWidget {
final String? jlptLevel;
2021-04-11 01:48:43 +02:00
2021-12-01 23:09:53 +01:00
const JLPTBadge({
required this.jlptLevel,
Key? key,
}) : super(key: key);
2021-04-11 01:48:43 +02:00
2021-12-01 23:09:53 +01:00
String get formattedJlptLevel =>
jlptLevel != null ? jlptLevel!.substring(5).toUpperCase() : '';
2021-04-11 01:48:43 +02:00
@override
Widget build(BuildContext context) {
2024-11-13 22:43:44 +01:00
return CircleBadge(
color: jlptLevel != null ? Colors.blue : Colors.transparent,
2021-12-01 23:09:53 +01:00
child: Text(
formattedJlptLevel,
style: const TextStyle(color: Colors.white),
2021-04-11 01:48:43 +02:00
),
);
}
2021-12-01 23:09:53 +01:00
}