46 lines
1.3 KiB
Dart
46 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:injector/injector.dart';
|
|
import 'package:score_repository/score_repository.dart';
|
|
|
|
class GeneralReputation extends StatefulWidget {
|
|
final String userId;
|
|
final Widget Function(BuildContext, ReputationEntity) builder;
|
|
|
|
const GeneralReputation({
|
|
super.key,
|
|
required this.userId,
|
|
required this.builder,
|
|
});
|
|
|
|
@override
|
|
State<GeneralReputation> createState() => _GeneralReputationState();
|
|
}
|
|
|
|
class _GeneralReputationState extends State<GeneralReputation> {
|
|
late Future<ReputationEntity> reputation;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
|
|
final repository = Injector.appInstance.get<FirebaseScoreRepository>();
|
|
reputation = repository.getReputationByUserId(widget.userId);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return FutureBuilder(
|
|
future: reputation,
|
|
builder: (context, snapshot) {
|
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
} else if (snapshot.hasError) {
|
|
return Text('Error: ${snapshot.error}');
|
|
} else {
|
|
final reputation = snapshot.data!;
|
|
return widget.builder(context, reputation);
|
|
}
|
|
});
|
|
}
|
|
}
|