32 lines
1009 B
Dart
32 lines
1009 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:injector/injector.dart';
|
|
import 'package:score_repository/score_repository.dart';
|
|
|
|
class GeneralReputation extends StatelessWidget {
|
|
final String userId;
|
|
final Widget Function(BuildContext, ReputationEntity) builder;
|
|
|
|
const GeneralReputation({
|
|
super.key,
|
|
required this.userId,
|
|
required this.builder,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final repository = Injector.appInstance.get<FirebaseScoreRepository>();
|
|
return FutureBuilder(
|
|
future: repository.getReputationByUserId(userId),
|
|
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 builder(context, reputation);
|
|
}
|
|
});
|
|
}
|
|
}
|