Disable implicit casts

This commit is contained in:
shilangyu 2021-01-03 20:25:05 +00:00
parent d40950ac93
commit 95386635f3
5 changed files with 19 additions and 14 deletions

View File

@ -57,3 +57,6 @@ linter:
analyzer:
exclude:
- "**/*.g.dart"
strong-mode:
implicit-casts: false
# implicit-dynamic: false

View File

@ -138,7 +138,7 @@ class CommunitiesTab extends HookWidget {
),
body: ListView(
children: [
for (final i in Iterable.generate(amountOfDisplayInstances))
for (var i = 0; i < amountOfDisplayInstances; i++)
Column(
children: [
ListTile(

View File

@ -33,15 +33,13 @@ class HomeTab extends HookWidget {
final isc = useInfiniteScrollController();
final theme = Theme.of(context);
final instancesIcons = useMemoFuture(() async {
final map = <String, String>{};
final instances = accStore.instances.toList(growable: false);
final sites = await Future.wait(instances
.map((e) => LemmyApi(e).v1.getSite().catchError((e) => null)));
for (final i in Iterable.generate(sites.length)) {
map[instances[i]] = sites[i].site.icon;
}
return map;
return {
for (var i = 0; i < sites.length; i++) instances[i]: sites[i].site.icon
};
});
handleListChange() async {
@ -268,14 +266,16 @@ class InfiniteHomeList extends HookWidget {
));
final posts = await Future.wait(futures);
final newPosts = <PostView>[];
for (final i
in Iterable.generate(posts.map((e) => e.length).reduce(max))) {
final longest = posts.map((e) => e.length).reduce(max);
for (var i = 0; i < longest; i++) {
for (final el in posts) {
if (el.elementAt(i) != null) {
newPosts.add(el[i]);
}
}
}
return newPosts;
}

View File

@ -47,11 +47,13 @@ class AccountsStore extends ChangeNotifier {
);
// set saved settings or create defaults
_tokens = nestedMapsCast((json) => Jwt(json['raw']));
_tokens = nestedMapsCast((json) => Jwt(json['raw'] as String));
_defaultAccount = prefs.getString(SharedPrefKeys.defaultAccount);
_defaultAccounts = HashMap.of(Map.castFrom(
jsonDecode(prefs.getString(SharedPrefKeys.defaultAccounts) ?? 'null') ??
{}));
jsonDecode(prefs.getString(SharedPrefKeys.defaultAccounts) ?? 'null')
as Map<dynamic, dynamic> ??
{},
));
notifyListeners();
}

View File

@ -60,8 +60,8 @@ class CommentSection extends HookWidget {
children: [
for (final e in sortPairs.entries)
ListTile(
leading: Icon(e.value[0]),
title: Text(e.value[1]),
leading: Icon(e.value[0] as IconData),
title: Text(e.value[1] as String),
trailing: sorting.value == e.key
? const Icon(Icons.check)
: null,
@ -79,7 +79,7 @@ class CommentSection extends HookWidget {
),
child: Row(
children: [
Text(sortPairs[sorting.value][1]),
Text(sortPairs[sorting.value][1] as String),
const Icon(Icons.arrow_drop_down),
],
),