style: fix apply

This commit is contained in:
Rongjian Zhang 2022-09-24 13:41:46 +08:00
parent 9b914ff1f1
commit d8f38d34aa
28 changed files with 89 additions and 86 deletions

View File

@ -26,6 +26,10 @@ linter:
always_use_package_imports: true always_use_package_imports: true
sort_constructors_first: true sort_constructors_first: true
sort_unnamed_constructors_first: true sort_unnamed_constructors_first: true
avoid_types_on_closure_parameters: true
omit_local_variable_types: true
prefer_final_in_for_each: true
prefer_final_locals: true
analyzer: analyzer:
exclude: exclude:

View File

@ -143,7 +143,7 @@ class _HomeState extends State<Home> {
Widget _buildNotificationIcon(BuildContext context, IconData iconData) { Widget _buildNotificationIcon(BuildContext context, IconData iconData) {
final theme = Provider.of<ThemeModel>(context); final theme = Provider.of<ThemeModel>(context);
int count = Provider.of<NotificationModel>(context).count; final count = Provider.of<NotificationModel>(context).count;
if (count == 0) { if (count == 0) {
return Icon(iconData); return Icon(iconData);
} }

View File

@ -42,7 +42,7 @@ void main() async {
ChangeNotifierProvider(create: (context) => authModel), ChangeNotifierProvider(create: (context) => authModel),
ChangeNotifierProvider(create: (context) => codeModel), ChangeNotifierProvider(create: (context) => codeModel),
], ],
child: MyApp(), child: const MyApp(),
)); ));
}, },
); );

View File

@ -238,7 +238,7 @@ class AuthModel with ChangeNotifier {
Map<String, dynamic> body = const {}, Map<String, dynamic> body = const {},
}) async { }) async {
late http.Response res; late http.Response res;
Map<String, String> headers = { final headers = <String, String>{
'Authorization': 'token $token', 'Authorization': 'token $token',
HttpHeaders.contentTypeHeader: 'application/json' HttpHeaders.contentTypeHeader: 'application/json'
}; };
@ -342,7 +342,7 @@ class AuthModel with ChangeNotifier {
Map<String, dynamic> body = const {}, Map<String, dynamic> body = const {},
}) async { }) async {
late http.Response res; late http.Response res;
Map<String, String> headers = { final headers = <String, String>{
'Authorization': 'token $token', 'Authorization': 'token $token',
HttpHeaders.contentTypeHeader: 'application/json' HttpHeaders.contentTypeHeader: 'application/json'
}; };
@ -418,7 +418,7 @@ class AuthModel with ChangeNotifier {
Map<String, dynamic> body = const {}, Map<String, dynamic> body = const {},
}) async { }) async {
http.Response res; http.Response res;
Map<String, String> headers = { final headers = <String, String>{
'Authorization': 'token $token', 'Authorization': 'token $token',
HttpHeaders.contentTypeHeader: 'application/json' HttpHeaders.contentTypeHeader: 'application/json'
}; };
@ -612,11 +612,11 @@ class AuthModel with ChangeNotifier {
Fimber.e('getUriLinksStream failed', ex: err); Fimber.e('getUriLinksStream failed', ex: err);
}); });
var prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
// Read accounts // Read accounts
try { try {
String? str = prefs.getString(StorageKeys.accounts); final str = prefs.getString(StorageKeys.accounts);
// Fimber.d('read accounts: $str'); // Fimber.d('read accounts: $str');
_accounts = (json.decode(str ?? '[]') as List) _accounts = (json.decode(str ?? '[]') as List)
.map((item) => Account.fromJson(item)) .map((item) => Account.fromJson(item))

View File

@ -39,11 +39,11 @@ class CodeModel with ChangeNotifier {
} }
Future<void> init() async { Future<void> init() async {
var prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
var vh = prefs.getString(StorageKeys.codeTheme); final vh = prefs.getString(StorageKeys.codeTheme);
var vdh = prefs.getString(StorageKeys.codeThemeDark); final vdh = prefs.getString(StorageKeys.codeThemeDark);
var vs = prefs.getInt(StorageKeys.iCodeFontSize); final vs = prefs.getInt(StorageKeys.iCodeFontSize);
var vf = prefs.getString(StorageKeys.codeFontFamily); final vf = prefs.getString(StorageKeys.codeFontFamily);
Fimber.d('read code: $vh, $vs, $vf'); Fimber.d('read code: $vh, $vs, $vf');
if (themeMap.keys.contains(vh)) { if (themeMap.keys.contains(vh)) {
@ -63,7 +63,7 @@ class CodeModel with ChangeNotifier {
} }
setTheme(String v) async { setTheme(String v) async {
var prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
await prefs.setString(StorageKeys.codeTheme, v); await prefs.setString(StorageKeys.codeTheme, v);
Fimber.d('write code theme: $v'); Fimber.d('write code theme: $v');
@ -73,7 +73,7 @@ class CodeModel with ChangeNotifier {
} }
setThemeDark(String v) async { setThemeDark(String v) async {
var prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
await prefs.setString(StorageKeys.codeThemeDark, v); await prefs.setString(StorageKeys.codeThemeDark, v);
Fimber.d('write code theme dark: $v'); Fimber.d('write code theme dark: $v');
@ -83,7 +83,7 @@ class CodeModel with ChangeNotifier {
} }
setFontSize(int v) async { setFontSize(int v) async {
var prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
await prefs.setInt(StorageKeys.iCodeFontSize, v); await prefs.setInt(StorageKeys.iCodeFontSize, v);
Fimber.d('write code font size: $v'); Fimber.d('write code font size: $v');
@ -93,7 +93,7 @@ class CodeModel with ChangeNotifier {
} }
setFontFamily(String v) async { setFontFamily(String v) async {
var prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
await prefs.setString(StorageKeys.codeFontFamily, v); await prefs.setString(StorageKeys.codeFontFamily, v);
Fimber.d('write code font family: $v'); Fimber.d('write code font family: $v');

View File

@ -353,8 +353,8 @@ class GithubGistsItem {
Map<String, GistFiles>? files; Map<String, GistFiles>? files;
GithubEventUser? owner; GithubEventUser? owner;
List<GistFiles> get fileNames { List<GistFiles> get fileNames {
List<GistFiles> filenames = []; final filenames = <GistFiles>[];
files!.forEach((String key, GistFiles value) { files!.forEach((key, value) {
filenames.add(value); filenames.add(value);
}); });
return filenames; return filenames;

View File

@ -58,14 +58,14 @@ class SelectorItem<T> {
class StaticRoute extends PageRouteBuilder { class StaticRoute extends PageRouteBuilder {
StaticRoute({this.builder}) StaticRoute({this.builder})
: super( : super(
pageBuilder: (BuildContext context, Animation<double> animation, pageBuilder: (context, animation,
Animation<double> secondaryAnimation) { secondaryAnimation) {
return builder!(context); return builder!(context);
}, },
transitionsBuilder: (BuildContext context, transitionsBuilder: (context,
Animation<double> animation, animation,
Animation<double> secondaryAnimation, secondaryAnimation,
Widget child) { child) {
return child; return child;
}, },
); );

View File

@ -65,7 +65,7 @@ class _ListStatefulScaffoldState<T, K>
loading = true; loading = true;
}); });
try { try {
final ListPayload<T, K> p = await widget.fetch(null); final p = await widget.fetch(null);
items = p.items.toList(); items = p.items.toList();
cursor = p.cursor; cursor = p.cursor;
hasMore = p.hasMore; hasMore = p.hasMore;
@ -87,7 +87,7 @@ class _ListStatefulScaffoldState<T, K>
loadingMore = true; loadingMore = true;
}); });
try { try {
ListPayload<T, K> p = await widget.fetch(cursor); final p = await widget.fetch(cursor);
items.addAll(p.items); items.addAll(p.items);
cursor = p.cursor; cursor = p.cursor;
hasMore = p.hasMore; hasMore = p.hasMore;

View File

@ -89,7 +89,7 @@ class _LongListStatefulScaffoldState<T, K>
loadingMore = true; loadingMore = true;
}); });
try { try {
LongListPayload<T?, K> p = await widget.onLoadMore(payload!.cursor); final LongListPayload<T?, K> p = await widget.onLoadMore(payload!.cursor);
payload!.totalCount = p.totalCount; payload!.totalCount = p.totalCount;
payload!.cursor = p.cursor; payload!.cursor = p.cursor;
payload!.leadingItems.addAll(p.leadingItems); payload!.leadingItems.addAll(p.leadingItems);
@ -109,12 +109,12 @@ class _LongListStatefulScaffoldState<T, K>
return CommonStyle.border; return CommonStyle.border;
} }
int realIndex = index ~/ 2; final realIndex = index ~/ 2;
if (realIndex < payload!.leadingItems.length) { if (realIndex < payload!.leadingItems.length) {
return widget.itemBuilder(payload!.leadingItems[realIndex]); return widget.itemBuilder(payload!.leadingItems[realIndex]);
} else if (realIndex == payload!.leadingItems.length) { } else if (realIndex == payload!.leadingItems.length) {
var count = payload!.totalCount - final count = payload!.totalCount -
payload!.leadingItems.length + payload!.leadingItems.length +
payload!.trailingItems!.length; payload!.trailingItems!.length;
return Container( return Container(
@ -153,7 +153,7 @@ class _LongListStatefulScaffoldState<T, K>
} }
int get _itemCount { int get _itemCount {
int count = payload!.leadingItems.length + payload!.trailingItems!.length; var count = payload!.leadingItems.length + payload!.trailingItems!.length;
if (payload!.totalCount > count) { if (payload!.totalCount > count) {
count++; count++;
} }
@ -177,7 +177,7 @@ class _LongListStatefulScaffoldState<T, K>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
List<Widget> slivers = [CupertinoSliverRefreshControl(onRefresh: _refresh)]; final slivers = <Widget>[CupertinoSliverRefreshControl(onRefresh: _refresh)];
if (payload != null) { if (payload != null) {
slivers.add( slivers.add(
SliverToBoxAdapter(child: widget.headerBuilder(payload!.header)), SliverToBoxAdapter(child: widget.headerBuilder(payload!.header)),

View File

@ -34,7 +34,7 @@ class BbIssuesScreen extends StatelessWidget {
); );
}, },
itemBuilder: (v) { itemBuilder: (v) {
int issueNumber = final issueNumber =
int.parse(v.issueLink!.replaceFirst(RegExp(r'.*\/'), '')); int.parse(v.issueLink!.replaceFirst(RegExp(r'.*\/'), ''));
return IssueItem( return IssueItem(
avatarUrl: v.reporter!.avatarUrl, avatarUrl: v.reporter!.avatarUrl,

View File

@ -29,7 +29,7 @@ class BbPullsScreen extends StatelessWidget {
); );
}, },
itemBuilder: (v) { itemBuilder: (v) {
int pullNumber = final pullNumber =
int.parse(v.pullRequestLink!.replaceFirst(RegExp(r'.*\/'), '')); int.parse(v.pullRequestLink!.replaceFirst(RegExp(r'.*\/'), ''));
return IssueItem( return IssueItem(
avatarUrl: v.author!.avatarUrl, avatarUrl: v.author!.avatarUrl,

View File

@ -35,8 +35,8 @@ class MyApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var codeProvider = Provider.of<CodeModel>(context); final codeProvider = Provider.of<CodeModel>(context);
var theme = Provider.of<ThemeModel>(context); final theme = Provider.of<ThemeModel>(context);
return SingleScaffold( return SingleScaffold(
title: AppBarTitle(AppLocalizations.of(context)!.codeTheme), title: AppBarTitle(AppLocalizations.of(context)!.codeTheme),
@ -76,7 +76,7 @@ class MyApp extends StatelessWidget {
items: CodeModel.fontFamilies items: CodeModel.fontFamilies
.map((v) => PickerItem(v, text: v)) .map((v) => PickerItem(v, text: v))
.toList(), .toList(),
onChange: (String? value) { onChange: (value) {
codeProvider.setFontFamily(value!); codeProvider.setFontFamily(value!);
}, },
), ),

View File

@ -83,7 +83,7 @@ class GePullScreen extends StatelessWidget {
final theme = context.read<ThemeModel>(); final theme = context.read<ThemeModel>();
var additions = 0; var additions = 0;
var deletions = 0; var deletions = 0;
for (var file in files) { for (final file in files) {
additions += int.parse(file.additions!); additions += int.parse(file.additions!);
deletions += int.parse(file.deletions!); deletions += int.parse(file.deletions!);
} }

View File

@ -58,14 +58,14 @@ class GeRepoScreen extends StatelessWidget {
await auth.fetchGitee('/repos/$owner/$name/branches').then((v) { await auth.fetchGitee('/repos/$owner/$name/branches').then((v) {
return [for (var branch in v) GiteeBranch.fromJson(branch)]; return [for (var branch in v) GiteeBranch.fromJson(branch)];
}); });
bool isStarred = await auth final isStarred = await auth
.fetchGitee('/user/starred/$owner/$name', requestType: 'NO CONTENT') .fetchGitee('/user/starred/$owner/$name', requestType: 'NO CONTENT')
.then((v) => v.statusCode == HttpStatus.noContent); .then((v) => v.statusCode == HttpStatus.noContent);
bool isWatching = await auth final isWatching = await auth
.fetchGitee('/user/subscriptions/$owner/$name', .fetchGitee('/user/subscriptions/$owner/$name',
requestType: 'NO CONTENT') requestType: 'NO CONTENT')
.then((v) => v.statusCode == HttpStatus.noContent); .then((v) => v.statusCode == HttpStatus.noContent);
StatusPayload statusPayload = StatusPayload(isWatching, isStarred); final statusPayload = StatusPayload(isWatching, isStarred);
return Tuple4(repo, readmeData, branches, statusPayload); return Tuple4(repo, readmeData, branches, statusPayload);
}, },
bodyBuilder: (t, setData) { bodyBuilder: (t, setData) {
@ -88,7 +88,7 @@ class GeRepoScreen extends StatelessWidget {
active: t.item4.isWatching, active: t.item4.isWatching,
text: t.item4.isWatching ? 'Ignore' : 'Watch', text: t.item4.isWatching ? 'Ignore' : 'Watch',
onTap: () async { onTap: () async {
final String watchType = final watchType =
t.item4.isWatching ? 'ignoring' : 'watching'; t.item4.isWatching ? 'ignoring' : 'watching';
await context.read<AuthModel>().fetchGitee( await context.read<AuthModel>().fetchGitee(
'/user/subscriptions/$owner/$name?watch_type=$watchType', '/user/subscriptions/$owner/$name?watch_type=$watchType',

View File

@ -41,7 +41,7 @@ class _GeSearchScreenState extends State<GeSearchScreen> {
Future<void> _query() async { Future<void> _query() async {
if (_loading || _keyword.isEmpty) return; if (_loading || _keyword.isEmpty) return;
var keyword = _controller!.text; final keyword = _controller!.text;
setState(() { setState(() {
_loading = true; _loading = true;
}); });

View File

@ -34,7 +34,7 @@ class GhContributorsScreen extends StatelessWidget {
); );
}, },
itemBuilder: (v) { itemBuilder: (v) {
final String? login = v.login; final login = v.login;
return ContributorItem( return ContributorItem(
avatarUrl: v.avatarUrl, avatarUrl: v.avatarUrl,
commits: v.contributions, commits: v.contributions,

View File

@ -95,7 +95,7 @@ class GhIssueScreen extends StatelessWidget {
b.vars.number = number; b.vars.number = number;
b.vars.cursor = cursor; b.vars.cursor = cursor;
}); });
OperationResponse<GIssueData, GIssueVars?> res = final OperationResponse<GIssueData, GIssueVars?> res =
await context.read<AuthModel>().gqlClient.request(req).first; await context.read<AuthModel>().gqlClient.request(req).first;
return res.data!.repository!; return res.data!.repository!;
} }

View File

@ -21,7 +21,7 @@ class GhNewsScreenState extends State<GhNewsScreen> {
Future.microtask(() async { Future.microtask(() async {
// Check if there are unread notification items. // Check if there are unread notification items.
// 1 item is enough since count is not displayed for now. // 1 item is enough since count is not displayed for now.
var items = await context final items = await context
.read<AuthModel>() .read<AuthModel>()
.ghClient .ghClient
.getJSON('/notifications?per_page=1'); .getJSON('/notifications?per_page=1');

View File

@ -31,9 +31,9 @@ class GhNotificationScreenState extends State<GhNotificationScreen> {
context.read<NotificationModel>().setCount(ns.length); context.read<NotificationModel>().setCount(ns.length);
} }
Map<String, NotificationGroup> groupMap = {}; final groupMap = <String, NotificationGroup>{};
for (var item in ns) { for (final item in ns) {
final repo = item.repository!.fullName ?? ''; // TODO: nullable final repo = item.repository!.fullName ?? ''; // TODO: nullable
if (groupMap[repo] == null) { if (groupMap[repo] == null) {
groupMap[repo] = NotificationGroup(repo); groupMap[repo] = NotificationGroup(repo);
@ -57,7 +57,7 @@ class GhNotificationScreenState extends State<GhNotificationScreen> {
schema += schema +=
'${group.key}: repository(owner: "${group.owner}", name: "${group.name}") {'; '${group.key}: repository(owner: "${group.owner}", name: "${group.name}") {';
for (var item in group.items) { for (final item in group.items) {
switch (item.subject!.type) { switch (item.subject!.type) {
case 'Issue': case 'Issue':
schema += ''' schema += '''
@ -83,13 +83,13 @@ ${item.key}: pullRequest(number: ${item.subject!.number}) {
if (schema == '{}') return groupMap; if (schema == '{}') return groupMap;
// Fimber.d(schema); // Fimber.d(schema);
var data = await context.read<AuthModel>().query(schema); final data = await context.read<AuthModel>().query(schema);
groupMap.forEach((repo, group) { groupMap.forEach((repo, group) {
for (var item in group.items) { for (final item in group.items) {
var groupData = data[group.key]; final groupData = data[group.key];
if (groupData == null) continue; if (groupData == null) continue;
var itemData = data[group.key][item.key]; final itemData = data[group.key][item.key];
if (itemData != null) { if (itemData != null) {
item.state = itemData['state']; item.state = itemData['state'];
} }

View File

@ -41,7 +41,7 @@ class _GhSearchScreenState extends State<GhSearchScreen> {
Future<void> _query() async { Future<void> _query() async {
if (_loading || _keyword.isEmpty) return; if (_loading || _keyword.isEmpty) return;
var keyword = _controller!.text; final keyword = _controller!.text;
setState(() { setState(() {
_loading = true; _loading = true;
}); });

View File

@ -42,7 +42,7 @@ class _GlSearchScreenState extends State<GlSearchScreen> {
Future<void> _query() async { Future<void> _query() async {
if (_loading || _keyword.isEmpty) return; if (_loading || _keyword.isEmpty) return;
var keyword = _controller!.text; final keyword = _controller!.text;
setState(() { setState(() {
_loading = true; _loading = true;
}); });

View File

@ -47,12 +47,11 @@ class GoRepoScreen extends StatelessWidget {
return utf8.decode(res.bodyBytes).normalizedHtml; return utf8.decode(res.bodyBytes).normalizedHtml;
}); });
final readmeData = MarkdownViewData(context, md: md, html: html); final readmeData = MarkdownViewData(context, md: md, html: html);
List<GogsBranch> branches = final branches =
await auth.fetchGogs('/repos/$owner/$name/branches').then((v) { await auth.fetchGogs('/repos/$owner/$name/branches').then((v) {
if (v is! List) { return [
return []; for (var branch in (v is List ? v : [])) GogsBranch.fromJson(branch)
} // Valid API Response only returned if repo contains >= 2 branches ]; // Valid API Response only returned if repo contains >= 2 branches
return [for (var branch in v) GogsBranch.fromJson(branch)];
}); });
return Tuple3(repo, readmeData, branches); return Tuple3(repo, readmeData, branches);

View File

@ -32,7 +32,7 @@ class GtUserScreen extends StatelessWidget {
final heatmapItems = [ final heatmapItems = [
for (final v in userHeatmap) GiteaHeatmapItem.fromJson(v) for (final v in userHeatmap) GiteaHeatmapItem.fromJson(v)
]; ];
List<List<ContributionDay>> heatmapWeeks = [[]]; final heatmapWeeks = <List<ContributionDay>>[[]];
for (var i = 0; i < heatmapItems.length; i++) { for (var i = 0; i < heatmapItems.length; i++) {
if (i > 0 && if (i > 0 &&
heatmapItems[i].timestamp! - heatmapItems[i - 1].timestamp! > 86400) { heatmapItems[i].timestamp! - heatmapItems[i - 1].timestamp! > 86400) {

View File

@ -48,10 +48,10 @@ class CommonStyle {
} }
Color getFontColorByBrightness(Color color) { Color getFontColorByBrightness(Color color) {
var grayscale = color.red * 0.3 + color.green * 0.59 + color.blue * 0.11; final grayscale = color.red * 0.3 + color.green * 0.59 + color.blue * 0.11;
// Fimber.d('color: $color, $grayscale'); // Fimber.d('color: $color, $grayscale');
var showWhite = grayscale < 128; final showWhite = grayscale < 128;
return showWhite ? AntTheme.white : AntTheme.text; return showWhite ? AntTheme.white : AntTheme.text;
} }
@ -90,12 +90,12 @@ class GithubPalette {
const PAGE_SIZE = 30; const PAGE_SIZE = 30;
var createWarning = var createWarning =
(String text) => Text(text, style: const TextStyle(color: AntTheme.danger)); (text) => Text(text, style: const TextStyle(color: AntTheme.danger));
var warningSpan = var warningSpan =
const TextSpan(text: 'xxx', style: TextStyle(color: AntTheme.danger)); const TextSpan(text: 'xxx', style: TextStyle(color: AntTheme.danger));
List<T> join<T>(T seperator, List<T> xs) { List<T> join<T>(T seperator, List<T> xs) {
List<T> result = []; final result = <T>[];
xs.asMap().forEach((index, x) { xs.asMap().forEach((index, x) {
if (x == null) return; if (x == null) return;
@ -109,7 +109,7 @@ List<T> join<T>(T seperator, List<T> xs) {
} }
List<T> joinAll<T>(T seperator, List<List<T>> xss) { List<T> joinAll<T>(T seperator, List<List<T>> xss) {
List<T> result = []; final result = <T>[];
xss.asMap().forEach((index, x) { xss.asMap().forEach((index, x) {
if (x.isEmpty) return; if (x.isEmpty) return;

View File

@ -33,12 +33,12 @@ class ContributionWidget extends StatelessWidget {
ContributionWidget({required this.weeks}) { ContributionWidget({required this.weeks}) {
int? maxCount; int? maxCount;
for (var week in weeks!) { for (final week in weeks!) {
for (var day in week) { for (final day in week) {
if (day.count != null) { if (day.count != null) {
if (maxCount == null) { if (maxCount == null) {
for (var week in weeks!) { for (final week in weeks!) {
for (var day in week) { for (final day in week) {
maxCount = max(day.count!, maxCount ?? 0); maxCount = max(day.count!, maxCount ?? 0);
} }
} }

View File

@ -308,7 +308,7 @@ class EventItem extends StatelessWidget {
]); ]);
case 'CheckSuiteEvent': case 'CheckSuiteEvent':
// Needs checks permission // Needs checks permission
String conclusion = ''; var conclusion = '';
switch (e.payload!.checkSuite!.conclusion) { switch (e.payload!.checkSuite!.conclusion) {
case 'success': case 'success':
case 'failure': case 'failure':
@ -387,9 +387,9 @@ class EventItem extends StatelessWidget {
], ],
); );
case 'GollumEvent': case 'GollumEvent':
String pageNamesCreated = ''; var pageNamesCreated = '';
String pageNamesEdited = ''; var pageNamesEdited = '';
for (GithubPagesItem page in e.payload!.pages!) { for (final page in e.payload!.pages!) {
if (page.action == 'edited') { if (page.action == 'edited') {
pageNamesEdited += ', ${page.pageName!}'; pageNamesEdited += ', ${page.pageName!}';
} else { } else {
@ -409,7 +409,7 @@ class EventItem extends StatelessWidget {
context: context, context: context,
spans: [TextSpan(text: ' $pageNamesCreated\n$pageNamesEdited ')]); spans: [TextSpan(text: ' $pageNamesCreated\n$pageNamesEdited ')]);
case 'InstallationEvent': case 'InstallationEvent':
String? action = e.payload!.action; var action = e.payload!.action;
if (action == 'new_permissions_accepted') { if (action == 'new_permissions_accepted') {
action = AppLocalizations.of(context)!.newPermissionsAccepted; action = AppLocalizations.of(context)!.newPermissionsAccepted;
} }
@ -422,19 +422,19 @@ class EventItem extends StatelessWidget {
], ],
); );
case 'InstallationRepositoriesEvent': case 'InstallationRepositoriesEvent':
List<GithubNotificationItemRepo> repositoriesAdded = final repositoriesAdded =
e.payload!.installation!.repositoriesAdded!; e.payload!.installation!.repositoriesAdded!;
List<GithubNotificationItemRepo> repositoriesRemoved = final repositoriesRemoved =
e.payload!.installation!.repositoriesRemoved!; e.payload!.installation!.repositoriesRemoved!;
String addedRepos = ''; var addedRepos = '';
String removedRepos = ''; var removedRepos = '';
for (GithubNotificationItemRepo repo in repositoriesAdded) { for (final repo in repositoriesAdded) {
addedRepos += '${repo.fullName!}, '; addedRepos += '${repo.fullName!}, ';
} }
for (GithubNotificationItemRepo repo in repositoriesRemoved) { for (final repo in repositoriesRemoved) {
removedRepos += '${repo.fullName!}, '; removedRepos += '${repo.fullName!}, ';
} }
String finalListOfRepos = ''; var finalListOfRepos = '';
if (addedRepos != '') { if (addedRepos != '') {
finalListOfRepos += finalListOfRepos +=
'${AppLocalizations.of(context)!.wereAddedTo(addedRepos, e.payload!.installation!.id.toString())}\n '; '${AppLocalizations.of(context)!.wereAddedTo(addedRepos, e.payload!.installation!.id.toString())}\n ';
@ -531,7 +531,7 @@ class EventItem extends StatelessWidget {
], ],
); );
case 'ProjectCardEvent': case 'ProjectCardEvent':
String? action = e.payload!.action; var action = e.payload!.action;
if (action == 'converted') { if (action == 'converted') {
action = ' ${AppLocalizations.of(context)!.convertProjectCard} '; action = ' ${AppLocalizations.of(context)!.convertProjectCard} ';
} else { } else {

View File

@ -92,7 +92,7 @@ class MarkdownFlutterView extends StatelessWidget {
final EdgeInsetsGeometry padding; final EdgeInsetsGeometry padding;
static Map<String, String?>? matchPattern(String url, String pattern) { static Map<String, String?>? matchPattern(String url, String pattern) {
var uri = Uri.parse(url); final uri = Uri.parse(url);
return UriParser(UriTemplate(pattern)).match(uri)?.parameters; return UriParser(UriTemplate(pattern)).match(uri)?.parameters;
} }
@ -145,7 +145,7 @@ class MarkdownFlutterView extends StatelessWidget {
'/{owner}/{name}', '/{owner}/{name}',
'/{login}' '/{login}'
]; ];
for (var p in matchedPaths) { for (final p in matchedPaths) {
final m = matchPattern(url, p); final m = matchPattern(url, p);
if (m != null) { if (m != null) {
context.pushUrl( context.pushUrl(

View File

@ -21,8 +21,8 @@ class TextWithAt extends StatelessWidget {
final matches = _reg.allMatches(text).map((m) => m.group(0)).toList(); final matches = _reg.allMatches(text).map((m) => m.group(0)).toList();
final chunks = text.split(_reg); final chunks = text.split(_reg);
List<TextSpan> spans = []; final spans = <TextSpan>[];
for (var index in List.generate(matches.length, (i) => (i))) { for (final index in List.generate(matches.length, (i) => (i))) {
if (chunks[index].isNotEmpty) { if (chunks[index].isNotEmpty) {
spans.add(TextSpan(text: chunks[index])); spans.add(TextSpan(text: chunks[index]));
} }