From 45f3af5646382d42c5fdfb8e62e73a8a26e89225 Mon Sep 17 00:00:00 2001 From: Caleb Jasik Date: Thu, 13 Feb 2025 11:15:40 -0600 Subject: [PATCH] `dart fix --apply --code=unnecessary_this` --- lib/components/IPField.dart | 2 +- lib/components/SimplePage.dart | 4 +- lib/components/config/ConfigPageItem.dart | 4 +- lib/main.dart | 4 +- lib/models/Certificate.dart | 10 ++--- lib/models/Site.dart | 40 +++++++++---------- lib/screens/EnrollmentScreen.dart | 6 +-- lib/screens/SettingsScreen.dart | 2 +- .../siteConfig/StaticHostmapScreen.dart | 2 +- 9 files changed, 37 insertions(+), 37 deletions(-) diff --git a/lib/components/IPField.dart b/lib/components/IPField.dart index 8eb15c7..1c2a05b 100644 --- a/lib/components/IPField.dart +++ b/lib/components/IPField.dart @@ -48,7 +48,7 @@ class IPField extends StatelessWidget { maxLength: ipOnly ? 15 : null, maxLengthEnforcement: ipOnly ? MaxLengthEnforcement.enforced : MaxLengthEnforcement.none, inputFormatters: ipOnly ? [IPTextInputFormatter()] : [FilteringTextInputFormatter.allow(RegExp(r'[^\s]+'))], - textInputAction: this.textInputAction, + textInputAction: textInputAction, placeholder: help, ), ); diff --git a/lib/components/SimplePage.dart b/lib/components/SimplePage.dart index f1cc6d4..749e591 100644 --- a/lib/components/SimplePage.dart +++ b/lib/components/SimplePage.dart @@ -43,7 +43,7 @@ class SimplePage extends StatelessWidget { @override Widget build(BuildContext context) { Widget realChild = child; - var addScrollbar = this.scrollbar; + var addScrollbar = scrollbar; if (scrollable == SimpleScrollable.vertical || scrollable == SimpleScrollable.both) { realChild = SingleChildScrollView( @@ -83,7 +83,7 @@ class SimplePage extends StatelessWidget { } if (alignment != null) { - realChild = Align(alignment: this.alignment!, child: realChild); + realChild = Align(alignment: alignment!, child: realChild); } if (bottomBar != null) { diff --git a/lib/components/config/ConfigPageItem.dart b/lib/components/config/ConfigPageItem.dart index 0e29760..f51afee 100644 --- a/lib/components/config/ConfigPageItem.dart +++ b/lib/components/config/ConfigPageItem.dart @@ -44,7 +44,7 @@ class ConfigPageItem extends StatelessWidget { Widget _buildContent(BuildContext context) { return SpecialButton( - onPressed: this.disabled ? null : onPressed, + onPressed: disabled ? null : onPressed, color: Utils.configItemBackground(context), child: Container( padding: EdgeInsets.symmetric(vertical: 6, horizontal: 15), @@ -54,7 +54,7 @@ class ConfigPageItem extends StatelessWidget { children: [ label != null ? Container(width: labelWidth, child: label) : Container(), Expanded(child: Container(child: content, padding: EdgeInsets.only(right: 10))), - this.disabled + disabled ? Container() : Icon(CupertinoIcons.forward, color: CupertinoColors.placeholderText.resolveFrom(context), size: 18), ], diff --git a/lib/main.dart b/lib/main.dart index dd68054..83d14d9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -107,7 +107,7 @@ class _AppState extends State { cupertino: (_, __) => CupertinoAppData(theme: CupertinoThemeData(brightness: brightness)), onGenerateRoute: (settings) { if (settings.name == '/') { - return platformPageRoute(context: context, builder: (context) => MainScreen(this.dnEnrolled)); + return platformPageRoute(context: context, builder: (context) => MainScreen(dnEnrolled)); } final uri = Uri.parse(settings.name!); @@ -117,7 +117,7 @@ class _AppState extends State { context: context, builder: (context) => - EnrollmentScreen(code: EnrollmentScreen.parseCode(settings.name!), stream: this.dnEnrolled), + EnrollmentScreen(code: EnrollmentScreen.parseCode(settings.name!), stream: dnEnrolled), ); } diff --git a/lib/models/Certificate.dart b/lib/models/Certificate.dart index 7d9a2a0..134d3c8 100644 --- a/lib/models/Certificate.dart +++ b/lib/models/Certificate.dart @@ -4,8 +4,8 @@ class CertificateInfo { CertificateValidity? validity; CertificateInfo.debug({this.rawCert = ""}) - : this.cert = Certificate.debug(), - this.validity = CertificateValidity.debug(); + : cert = Certificate.debug(), + validity = CertificateValidity.debug(); CertificateInfo.fromJson(Map json) : cert = Certificate.fromJson(json['Cert']), @@ -24,7 +24,7 @@ class Certificate { String fingerprint; String signature; - Certificate.debug() : this.details = CertificateDetails.debug(), this.fingerprint = "DEBUG", this.signature = "DEBUG"; + Certificate.debug() : details = CertificateDetails.debug(), fingerprint = "DEBUG", signature = "DEBUG"; Certificate.fromJson(Map json) : details = CertificateDetails.fromJson(json['details']), @@ -44,7 +44,7 @@ class CertificateDetails { String issuer; CertificateDetails.debug() - : this.name = "DEBUG", + : name = "DEBUG", notBefore = DateTime.now(), notAfter = DateTime.now(), publicKey = "", @@ -70,7 +70,7 @@ class CertificateValidity { bool valid; String reason; - CertificateValidity.debug() : this.valid = true, this.reason = ""; + CertificateValidity.debug() : valid = true, reason = ""; CertificateValidity.fromJson(Map json) : valid = json['Valid'], reason = json['Reason']; } diff --git a/lib/models/Site.dart b/lib/models/Site.dart index 861b100..9d3bbe3 100644 --- a/lib/models/Site.dart +++ b/lib/models/Site.dart @@ -139,25 +139,25 @@ class Site { _updateFromJson(String json) { var decoded = Site._fromJson(jsonDecode(json)); - this.name = decoded["name"]; - this.id = decoded['id']; // TODO update EventChannel - this.staticHostmap = decoded['staticHostmap']; - this.ca = decoded['ca']; - this.certInfo = decoded['certInfo']; - this.lhDuration = decoded['lhDuration']; - this.port = decoded['port']; - this.cipher = decoded['cipher']; - this.sortKey = decoded['sortKey']; - this.mtu = decoded['mtu']; - this.connected = decoded['connected']; - this.status = decoded['status']; - this.logFile = decoded['logFile']; - this.logVerbosity = decoded['logVerbosity']; - this.errors = decoded['errors']; - this.unsafeRoutes = decoded['unsafeRoutes']; - this.managed = decoded['managed']; - this.rawConfig = decoded['rawConfig']; - this.lastManagedUpdate = decoded['lastManagedUpdate']; + name = decoded["name"]; + id = decoded['id']; // TODO update EventChannel + staticHostmap = decoded['staticHostmap']; + ca = decoded['ca']; + certInfo = decoded['certInfo']; + lhDuration = decoded['lhDuration']; + port = decoded['port']; + cipher = decoded['cipher']; + sortKey = decoded['sortKey']; + mtu = decoded['mtu']; + connected = decoded['connected']; + status = decoded['status']; + logFile = decoded['logFile']; + logVerbosity = decoded['logVerbosity']; + errors = decoded['errors']; + unsafeRoutes = decoded['unsafeRoutes']; + managed = decoded['managed']; + rawConfig = decoded['rawConfig']; + lastManagedUpdate = decoded['lastManagedUpdate']; } static _fromJson(Map json) { @@ -331,7 +331,7 @@ class Site { Future>> listAllHostmaps() async { try { - var res = await Future.wait([this.listHostmap(), this.listPendingHostmap()]); + var res = await Future.wait([listHostmap(), listPendingHostmap()]); return {"active": res[0], "pending": res[1]}; } on PlatformException catch (err) { throw err.details ?? err.message ?? err.toString(); diff --git a/lib/screens/EnrollmentScreen.dart b/lib/screens/EnrollmentScreen.dart index a7e517d..4093671 100644 --- a/lib/screens/EnrollmentScreen.dart +++ b/lib/screens/EnrollmentScreen.dart @@ -103,7 +103,7 @@ class _EnrollmentScreenState extends State { padding: EdgeInsets.only(top: 20), ); } - } else if (this.error != null) { + } else if (error != null) { // Error while enrolling, display it child = Center( child: Column( @@ -137,7 +137,7 @@ class _EnrollmentScreenState extends State { padding: EdgeInsets.symmetric(horizontal: 16, vertical: 10), ), Container( - child: Padding(child: SelectableText(this.error!), padding: EdgeInsets.all(16)), + child: Padding(child: SelectableText(error!), padding: EdgeInsets.all(16)), color: Theme.of(context).colorScheme.errorContainer, ), ], @@ -145,7 +145,7 @@ class _EnrollmentScreenState extends State { mainAxisAlignment: MainAxisAlignment.center, ), ); - } else if (this.enrolled) { + } else if (enrolled) { // Enrollment complete! child = Padding( child: Center(child: Text('Enrollment complete! 🎉', textAlign: TextAlign.center)), diff --git a/lib/screens/SettingsScreen.dart b/lib/screens/SettingsScreen.dart index c9b465f..3c4a1a3 100644 --- a/lib/screens/SettingsScreen.dart +++ b/lib/screens/SettingsScreen.dart @@ -27,7 +27,7 @@ class _SettingsScreenState extends State { void initState() { //TODO: we need to unregister on dispose? settings.onChange().listen((_) { - if (this.mounted) { + if (mounted) { setState(() {}); } }); diff --git a/lib/screens/siteConfig/StaticHostmapScreen.dart b/lib/screens/siteConfig/StaticHostmapScreen.dart index 1050757..3cb6d74 100644 --- a/lib/screens/siteConfig/StaticHostmapScreen.dart +++ b/lib/screens/siteConfig/StaticHostmapScreen.dart @@ -27,7 +27,7 @@ class StaticHostmapScreen extends StatefulWidget { this.lighthouse = false, this.onDelete, required this.onSave, - }) : this.destinations = destinations ?? []; + }) : destinations = destinations ?? []; final List destinations; final String nebulaIp;