refactor: Switch to flutter_lints

This commit is contained in:
Krille Fear 2021-10-14 18:09:30 +02:00
commit 13fda9458f
101 changed files with 719 additions and 653 deletions

View file

@ -132,10 +132,10 @@ class _AudioPlayerState extends State<AudioPlayerWidget> {
return Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
SizedBox(
width: 30,
child: status == AudioPlayerStatus.downloading
? CircularProgressIndicator.adaptive(strokeWidth: 2)
? const CircularProgressIndicator.adaptive(strokeWidth: 2)
: IconButton(
icon: Icon(
audioPlayer.state == PlayerState.PLAYING
@ -172,7 +172,7 @@ class _AudioPlayerState extends State<AudioPlayerWidget> {
color: widget.color,
),
),
SizedBox(width: 8),
const SizedBox(width: 8),
IconButton(
icon: Icon(
Icons.download_outlined,

View file

@ -18,13 +18,15 @@ class HtmlMessage extends StatelessWidget {
final TextStyle linkStyle;
final double emoteSize;
const HtmlMessage(
{this.html,
this.maxLines,
this.room,
this.defaultTextStyle,
this.linkStyle,
this.emoteSize});
const HtmlMessage({
Key key,
this.html,
this.maxLines,
this.room,
this.defaultTextStyle,
this.linkStyle,
this.emoteSize,
}) : super(key: key);
@override
Widget build(BuildContext context) {
@ -35,7 +37,7 @@ class HtmlMessage extends StatelessWidget {
// miss-matching tags, and this way we actually correctly identify what we want to strip and, well,
// strip it.
final renderHtml = html.replaceAll(
RegExp('<mx-reply>.*<\/mx-reply>',
RegExp('<mx-reply>.*</mx-reply>',
caseSensitive: false, multiLine: false, dotAll: true),
'');

View file

@ -205,8 +205,8 @@ class _ImageBubbleState extends State<ImageBubble> {
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.download_outlined),
SizedBox(width: 8),
const Icon(Icons.download_outlined),
const SizedBox(width: 8),
Text(
filename,
overflow: TextOverflow.fade,
@ -217,7 +217,7 @@ class _ImageBubbleState extends State<ImageBubble> {
),
),
if (widget.event.sizeString != null) Text(widget.event.sizeString),
SizedBox(height: 8),
const SizedBox(height: 8),
Text((error ?? _error).toString()),
],
),
@ -249,7 +249,7 @@ class _ImageBubbleState extends State<ImageBubble> {
children: <Widget>[
if (blurhash != null) blurhash,
Center(
child: child ?? CircularProgressIndicator.adaptive(strokeWidth: 2),
child: child ?? const CircularProgressIndicator.adaptive(strokeWidth: 2),
),
],
);
@ -412,7 +412,7 @@ class _ImageBubbleState extends State<ImageBubble> {
child: Hero(
tag: widget.event.eventId,
child: AnimatedSwitcher(
duration: Duration(milliseconds: 1000),
duration: const Duration(milliseconds: 1000),
child: Container(
key: ValueKey(key),
constraints: widget.maxSize

View file

@ -42,7 +42,7 @@ class MapBubble extends StatelessWidget {
markers: [
Marker(
point: LatLng(latitude, longitude),
builder: (context) => Icon(
builder: (context) => const Icon(
Icons.location_pin,
color: Colors.red,
),

View file

@ -33,7 +33,9 @@ class Message extends StatelessWidget {
this.scrollToEventId,
@required this.unfold,
this.selected,
this.timeline});
this.timeline,
Key key})
: super(key: key);
/// Indicates wheither the user may use a mouse instead
/// of touchscreen.
@ -99,8 +101,8 @@ class Message extends StatelessWidget {
),
padding:
const EdgeInsets.symmetric(vertical: 6, horizontal: 10),
constraints:
BoxConstraints(maxWidth: FluffyThemes.columnWidth * 1.5),
constraints: const BoxConstraints(
maxWidth: FluffyThemes.columnWidth * 1.5),
child: Stack(
children: <Widget>[
Column(
@ -134,7 +136,8 @@ class Message extends StatelessWidget {
},
child: AbsorbPointer(
child: Container(
margin: EdgeInsets.symmetric(vertical: 4.0),
margin: const EdgeInsets.symmetric(
vertical: 4.0),
child: ReplyContent(replyEvent,
lightText: ownMessage,
timeline: timeline),
@ -147,7 +150,7 @@ class Message extends StatelessWidget {
displayEvent,
textColor: textColor,
),
SizedBox(height: 3),
const SizedBox(height: 3),
Opacity(
opacity: 0,
child: _MetaRow(
@ -181,7 +184,7 @@ class Message extends StatelessWidget {
),
];
final avatarOrSizedBox = sameSender
? SizedBox(width: Avatar.defaultSize)
? const SizedBox(width: Avatar.defaultSize)
: Avatar(
event.sender.avatarUrl,
event.sender.calcDisplayname(),
@ -224,10 +227,11 @@ class Message extends StatelessWidget {
color: selected
? Theme.of(context).primaryColor.withAlpha(100)
: Theme.of(context).primaryColor.withAlpha(0),
constraints: BoxConstraints(maxWidth: FluffyThemes.columnWidth * 2.5),
constraints:
const BoxConstraints(maxWidth: FluffyThemes.columnWidth * 2.5),
child: Padding(
padding:
EdgeInsets.only(left: 8.0, right: 8.0, bottom: 4.0, top: 4.0),
padding: const EdgeInsets.only(
left: 8.0, right: 8.0, bottom: 4.0, top: 4.0),
child: container,
),
),
@ -267,7 +271,7 @@ class _MetaRow extends StatelessWidget {
.withAlpha(200),
),
),
if (showDisplayname) SizedBox(width: 4),
if (showDisplayname) const SizedBox(width: 4),
Text(
event.originServerTs.localizedTime(context),
style: TextStyle(
@ -284,7 +288,7 @@ class _MetaRow extends StatelessWidget {
color: color,
),
),
if (ownMessage) SizedBox(width: 2),
if (ownMessage) const SizedBox(width: 2),
if (ownMessage)
Icon(
displayEvent.statusIcon,

View file

@ -26,7 +26,7 @@ class MessageContent extends StatelessWidget {
final Event event;
final Color textColor;
const MessageContent(this.event, {this.textColor});
const MessageContent(this.event, {Key key,this.textColor}) : super(key: key);
void _verifyOrRequestKey(BuildContext context) async {
if (event.content['can_request_session'] != true) {
@ -50,7 +50,7 @@ class MessageContent extends StatelessWidget {
if (await client.encryption.keyManager.isCached()) {
break;
}
await Future.delayed(Duration(seconds: 1));
await Future.delayed(const Duration(seconds: 1));
}
final timeline = await event.room.getTimeline();
timeline.requestKeys();
@ -121,7 +121,7 @@ class MessageContent extends StatelessWidget {
fit: BoxFit.cover,
tapToView: false,
),
Icon(Icons.play_circle_outline,
const Icon(Icons.play_circle_outline,
size: 200, color: Colors.grey),
],
),
@ -169,7 +169,7 @@ class MessageContent extends StatelessWidget {
onPrimary: Theme.of(context).textTheme.bodyText1.color,
),
onPressed: () => _verifyOrRequestKey(context),
icon: Icon(Icons.lock_outline),
icon: const Icon(Icons.lock_outline),
label: Text(L10n.of(context).encrypted),
);
case MessageTypes.Location:
@ -194,7 +194,7 @@ class MessageContent extends StatelessWidget {
latitude: latlong.first,
longitude: latlong.last,
),
SizedBox(height: 6),
const SizedBox(height: 6),
OutlinedButton.icon(
icon: Icon(Icons.location_on_outlined, color: textColor),
onPressed:
@ -219,7 +219,7 @@ class MessageContent extends StatelessWidget {
onPrimary: Theme.of(context).textTheme.bodyText1.color,
),
onPressed: () => launch(event.body),
icon: Icon(Icons.phone_outlined, color: Colors.green),
icon: const Icon(Icons.phone_outlined, color: Colors.green),
label: Text(L10n.of(context).videoCall),
);
}
@ -228,7 +228,7 @@ class MessageContent extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.delete_forever_outlined, color: textColor),
SizedBox(width: 4),
const SizedBox(width: 4),
Text(
event.getLocalizedBody(MatrixLocals(L10n.of(context)),
hideReply: true),

View file

@ -14,42 +14,40 @@ class MessageDownloadContent extends StatelessWidget {
final String filename = event.content.containsKey('filename')
? event.content['filename']
: event.body;
return Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Theme.of(context).scaffoldBackgroundColor,
onPrimary: Theme.of(context).textTheme.bodyText1.color,
),
onPressed: () => event.saveFile(context),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.download_outlined),
SizedBox(width: 8),
Expanded(
child: Text(
filename,
overflow: TextOverflow.fade,
softWrap: false,
maxLines: 1,
),
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Theme.of(context).scaffoldBackgroundColor,
onPrimary: Theme.of(context).textTheme.bodyText1.color,
),
onPressed: () => event.saveFile(context),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.download_outlined),
const SizedBox(width: 8),
Expanded(
child: Text(
filename,
overflow: TextOverflow.fade,
softWrap: false,
maxLines: 1,
),
],
),
],
),
),
if (event.sizeString != null)
Text(
event.sizeString,
style: TextStyle(
color: textColor,
),
),
if (event.sizeString != null)
Text(
event.sizeString,
style: TextStyle(
color: textColor,
),
),
],
),
],
);
}
}

View file

@ -12,7 +12,8 @@ class MessageReactions extends StatelessWidget {
final Event event;
final Timeline timeline;
const MessageReactions(this.event, this.timeline);
const MessageReactions(this.event, this.timeline, {Key key})
: super(key: key);
@override
Widget build(BuildContext context) {

View file

@ -74,7 +74,7 @@ class ReplyContent extends StatelessWidget {
height: fontSize * 2 + 6,
color: lightText ? Colors.white : Theme.of(context).primaryColor,
),
SizedBox(width: 6),
const SizedBox(width: 6),
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,

View file

@ -8,7 +8,8 @@ import '../../config/app_config.dart';
class StateMessage extends StatelessWidget {
final Event event;
final void Function(String) unfold;
const StateMessage(this.event, {@required this.unfold});
const StateMessage(this.event, {@required this.unfold, Key key})
: super(key: key);
@override
Widget build(BuildContext context) {
@ -52,7 +53,7 @@ class StateMessage extends StatelessWidget {
if (counter != 0)
Text(
L10n.of(context).moreEvents(counter),
style: TextStyle(
style: const TextStyle(
fontWeight: FontWeight.bold,
),
),

View file

@ -8,7 +8,8 @@ class VerificationRequestContent extends StatelessWidget {
final Event event;
final Timeline timeline;
const VerificationRequestContent({this.event, this.timeline});
const VerificationRequestContent({this.event, this.timeline, Key key})
: super(key: key);
@override
Widget build(BuildContext context) {
@ -22,13 +23,13 @@ class VerificationRequestContent extends StatelessWidget {
final started = start.isNotEmpty;
final canceled = cancel.isNotEmpty;
return Padding(
padding: EdgeInsets.symmetric(
padding: const EdgeInsets.symmetric(
horizontal: 8.0,
vertical: 4.0,
),
child: Center(
child: Container(
padding: EdgeInsets.all(8),
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
border: Border.all(
color: Theme.of(context).dividerColor,
@ -44,7 +45,7 @@ class VerificationRequestContent extends StatelessWidget {
color: canceled
? Colors.red
: (fullyDone ? Colors.green : Colors.grey)),
SizedBox(width: 8),
const SizedBox(width: 8),
Text(canceled
? 'Error ${cancel.first.content.tryGet<String>('code')}: ${cancel.first.content.tryGet<String>('reason')}'
: (fullyDone