refactor: Added and applied require_trailing_commas linter rule

This commit is contained in:
Malin Errenst 2023-03-02 10:57:52 +01:00
commit ec7acc5385
112 changed files with 3466 additions and 2855 deletions

View file

@ -21,52 +21,54 @@ class HomeserverBottomSheet extends StatelessWidget {
appBar: AppBar(
title: Text(homeserver.homeserver.baseUrl.host),
),
body: ListView(children: [
if (description != null && description.isNotEmpty)
body: ListView(
children: [
if (description != null && description.isNotEmpty)
ListTile(
leading: const Icon(Icons.info_outlined),
title: Text(description),
),
if (jurisdiction != null && jurisdiction.isNotEmpty)
ListTile(
leading: const Icon(Icons.location_city_outlined),
title: Text(jurisdiction),
),
if (homeserverSoftware != null && homeserverSoftware.isNotEmpty)
ListTile(
leading: const Icon(Icons.domain_outlined),
title: Text(homeserverSoftware),
),
ListTile(
leading: const Icon(Icons.info_outlined),
title: Text(description),
onTap: () =>
launchUrlString(homeserver.homeserver.baseUrl.toString()),
leading: const Icon(Icons.link_outlined),
title: Text(homeserver.homeserver.baseUrl.toString()),
),
if (jurisdiction != null && jurisdiction.isNotEmpty)
ListTile(
leading: const Icon(Icons.location_city_outlined),
title: Text(jurisdiction),
),
if (homeserverSoftware != null && homeserverSoftware.isNotEmpty)
ListTile(
leading: const Icon(Icons.domain_outlined),
title: Text(homeserverSoftware),
),
ListTile(
onTap: () =>
launchUrlString(homeserver.homeserver.baseUrl.toString()),
leading: const Icon(Icons.link_outlined),
title: Text(homeserver.homeserver.baseUrl.toString()),
),
if (registration != null)
ListTile(
onTap: () => launchUrlString(registration.toString()),
leading: const Icon(Icons.person_add_outlined),
title: Text(registration.toString()),
),
if (rules != null)
ListTile(
onTap: () => launchUrlString(rules.toString()),
leading: const Icon(Icons.visibility_outlined),
title: Text(rules.toString()),
),
if (privacy != null)
ListTile(
onTap: () => launchUrlString(privacy.toString()),
leading: const Icon(Icons.shield_outlined),
title: Text(privacy.toString()),
),
if (responseTime != null)
ListTile(
leading: const Icon(Icons.timer_outlined),
title: Text('${responseTime.inMilliseconds}ms'),
),
]),
if (registration != null)
ListTile(
onTap: () => launchUrlString(registration.toString()),
leading: const Icon(Icons.person_add_outlined),
title: Text(registration.toString()),
),
if (rules != null)
ListTile(
onTap: () => launchUrlString(rules.toString()),
leading: const Icon(Icons.visibility_outlined),
title: Text(rules.toString()),
),
if (privacy != null)
ListTile(
onTap: () => launchUrlString(privacy.toString()),
leading: const Icon(Icons.shield_outlined),
title: Text(privacy.toString()),
),
if (responseTime != null)
ListTile(
leading: const Icon(Icons.timer_outlined),
title: Text('${responseTime.inMilliseconds}ms'),
),
],
),
);
}
}

View file

@ -51,10 +51,11 @@ class HomeserverPickerController extends State<HomeserverPicker> {
Hive.openBox('test').then((value) => null).catchError(
(e, s) async {
await showOkAlertDialog(
context: context,
title: L10n.of(context)!.indexedDbErrorTitle,
message: L10n.of(context)!.indexedDbErrorLong,
onWillPop: () async => false);
context: context,
title: L10n.of(context)!.indexedDbErrorTitle,
message: L10n.of(context)!.indexedDbErrorLong,
onWillPop: () async => false,
);
_checkTorBrowser();
},
);
@ -85,9 +86,11 @@ class HomeserverPickerController extends State<HomeserverPicker> {
});
List<HomeserverBenchmarkResult> get filteredHomeservers => benchmarkResults!
.where((element) =>
element.homeserver.baseUrl.host.contains(searchTerm) ||
(element.homeserver.description?.contains(searchTerm) ?? false))
.where(
(element) =>
element.homeserver.baseUrl.host.contains(searchTerm) ||
(element.homeserver.description?.contains(searchTerm) ?? false),
)
.toList();
void _loadHomeserverList() async {
@ -186,15 +189,16 @@ class HomeserverPickerController extends State<HomeserverPicker> {
final file = await FilePickerCross.importFromStorage();
if (file.fileName == null) return;
await showFutureLoadingDialog(
context: context,
future: () async {
try {
final client = Matrix.of(context).getLoginClient();
await client.importDump(file.toString());
Matrix.of(context).initMatrix();
} catch (e, s) {
Logs().e('Future error:', e, s);
}
});
context: context,
future: () async {
try {
final client = Matrix.of(context).getLoginClient();
await client.importDump(file.toString());
Matrix.of(context).initMatrix();
} catch (e, s) {
Logs().e('Future error:', e, s);
}
},
);
}
}

View file

@ -65,10 +65,11 @@ class HomeserverPickerView extends StatelessWidget {
child: benchmarkResults == null
? const Center(
child: Padding(
padding: EdgeInsets.all(12.0),
child:
CircularProgressIndicator.adaptive(),
))
padding: EdgeInsets.all(12.0),
child: CircularProgressIndicator
.adaptive(),
),
)
: Column(
children: controller.filteredHomeservers
.map(
@ -82,19 +83,20 @@ class HomeserverPickerView extends StatelessWidget {
.showServerInfo(server),
),
onTap: () => controller.setServer(
server
.homeserver.baseUrl.host),
server.homeserver.baseUrl.host,
),
title: Text(
server.homeserver.baseUrl.host,
style: const TextStyle(
color: Colors.black),
color: Colors.black,
),
),
subtitle: Text(
server.homeserver.description ??
'',
style: TextStyle(
color:
Colors.grey.shade700),
color: Colors.grey.shade700,
),
),
),
)