1
0
mirror of https://github.com/h7x4/Jisho-Study-Tool.git synced 2024-12-23 06:17:29 +01:00
Jisho-Study-Tool/lib/components/search/search_results_body/parts/jlpt_badge.dart

26 lines
586 B
Dart
Raw Normal View History

2021-04-11 01:48:43 +02:00
import 'package:flutter/material.dart';
import './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) {
return Badge(
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
}