refactor: moved global formatters to static members of classes which use them
parent
6fbef0c64c
commit
b40b872940
|
@ -1,8 +1,7 @@
|
|||
import 'package:graphql/client.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
final DateFormat formatter = DateFormat('hh:mm');
|
||||
|
||||
/// TODO(misterfourtytwo): add equality override
|
||||
class Message {
|
||||
Message({this.text, this.severity = MessageSeverity.normal})
|
||||
: time = DateTime.now();
|
||||
|
@ -13,7 +12,9 @@ class Message {
|
|||
final String? text;
|
||||
final DateTime time;
|
||||
final MessageSeverity severity;
|
||||
String get timeString => formatter.format(time);
|
||||
|
||||
static final DateFormat _formatter = DateFormat('hh:mm');
|
||||
String get timeString => _formatter.format(time);
|
||||
}
|
||||
|
||||
enum MessageSeverity {
|
||||
|
|
|
@ -7,13 +7,13 @@ class UiHelpers {
|
|||
static String getDomainName(final ServerInstallationState config) =>
|
||||
config.isDomainSelected ? config.serverDomain!.domainName : 'example.com';
|
||||
|
||||
static final _formatter = NumberFormat()..minimumFractionDigits = 0;
|
||||
|
||||
static String formatWithPrecision(
|
||||
final double value, {
|
||||
final int fraction = 2,
|
||||
}) {
|
||||
final NumberFormat formatter = NumberFormat();
|
||||
formatter.minimumFractionDigits = 0;
|
||||
formatter.maximumFractionDigits = fraction;
|
||||
return formatter.format(value);
|
||||
_formatter.maximumFractionDigits = fraction;
|
||||
return _formatter.format(value);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue