From 54894156d3e7dafe203b47ad51ed968ece949938 Mon Sep 17 00:00:00 2001 From: Anthony Date: Mon, 1 Jan 2024 22:42:53 +0000 Subject: [PATCH] Fix dart analysis issues --- .flutter-plugins-dependencies | 2 +- CHANGELOG.md | 1 + example/lib/main.dart | 45 ++++++++++++------------ example/pubspec.lock | 18 +++++++++- example/pubspec.yaml | 6 ++-- lib/widgets/permission_view.dart | 6 ++-- lib/widgets/role_selector_widget.dart | 2 +- lib/widgets/role_view_widget.dart | 5 ++- lib/widgets/user_permissions_widget.dart | 4 +-- lib/widgets/user_roles_widget.dart | 4 +-- 10 files changed, 55 insertions(+), 38 deletions(-) diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index d764e13..867f26d 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_secure_storage","path":"/Users/anthony/.pub-cache/hosted/pub.dev/flutter_secure_storage-9.0.0/","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/Users/anthony/.pub-cache/hosted/pub.dev/path_provider_foundation-2.3.1/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/anthony/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.3.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"flutter_secure_storage","path":"/Users/anthony/.pub-cache/hosted/pub.dev/flutter_secure_storage-9.0.0/","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"/Users/anthony/.pub-cache/hosted/pub.dev/path_provider_android-2.2.1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/Users/anthony/.pub-cache/hosted/pub.dev/shared_preferences_android-2.2.1/","native_build":true,"dependencies":[]}],"macos":[{"name":"flutter_secure_storage_macos","path":"/Users/anthony/.pub-cache/hosted/pub.dev/flutter_secure_storage_macos-3.0.1/","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/Users/anthony/.pub-cache/hosted/pub.dev/path_provider_foundation-2.3.1/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/anthony/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.3.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"flutter_secure_storage_linux","path":"/Users/anthony/.pub-cache/hosted/pub.dev/flutter_secure_storage_linux-1.2.0/","native_build":true,"dependencies":[]},{"name":"path_provider_linux","path":"/Users/anthony/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/anthony/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.3.2/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"flutter_secure_storage_windows","path":"/Users/anthony/.pub-cache/hosted/pub.dev/flutter_secure_storage_windows-3.0.0/","native_build":true,"dependencies":[]},{"name":"path_provider_windows","path":"/Users/anthony/.pub-cache/hosted/pub.dev/path_provider_windows-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/anthony/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.3.2/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"flutter_secure_storage_web","path":"/Users/anthony/.pub-cache/hosted/pub.dev/flutter_secure_storage_web-1.1.2/","dependencies":[]},{"name":"shared_preferences_web","path":"/Users/anthony/.pub-cache/hosted/pub.dev/shared_preferences_web-2.2.1/","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_secure_storage","dependencies":["flutter_secure_storage_linux","flutter_secure_storage_macos","flutter_secure_storage_web","flutter_secure_storage_windows"]},{"name":"flutter_secure_storage_linux","dependencies":[]},{"name":"flutter_secure_storage_macos","dependencies":[]},{"name":"flutter_secure_storage_web","dependencies":[]},{"name":"flutter_secure_storage_windows","dependencies":["path_provider"]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2024-01-01 22:20:54.951924","version":"3.16.5"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_secure_storage","path":"/Users/anthony/.pub-cache/hosted/pub.dev/flutter_secure_storage-9.0.0/","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/Users/anthony/.pub-cache/hosted/pub.dev/path_provider_foundation-2.3.1/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/anthony/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.3.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"flutter_secure_storage","path":"/Users/anthony/.pub-cache/hosted/pub.dev/flutter_secure_storage-9.0.0/","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"/Users/anthony/.pub-cache/hosted/pub.dev/path_provider_android-2.2.1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/Users/anthony/.pub-cache/hosted/pub.dev/shared_preferences_android-2.2.1/","native_build":true,"dependencies":[]}],"macos":[{"name":"flutter_secure_storage_macos","path":"/Users/anthony/.pub-cache/hosted/pub.dev/flutter_secure_storage_macos-3.0.1/","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/Users/anthony/.pub-cache/hosted/pub.dev/path_provider_foundation-2.3.1/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/anthony/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.3.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"flutter_secure_storage_linux","path":"/Users/anthony/.pub-cache/hosted/pub.dev/flutter_secure_storage_linux-1.2.0/","native_build":true,"dependencies":[]},{"name":"path_provider_linux","path":"/Users/anthony/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/anthony/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.3.2/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"flutter_secure_storage_windows","path":"/Users/anthony/.pub-cache/hosted/pub.dev/flutter_secure_storage_windows-3.0.0/","native_build":true,"dependencies":[]},{"name":"path_provider_windows","path":"/Users/anthony/.pub-cache/hosted/pub.dev/path_provider_windows-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/anthony/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.3.2/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"flutter_secure_storage_web","path":"/Users/anthony/.pub-cache/hosted/pub.dev/flutter_secure_storage_web-1.1.2/","dependencies":[]},{"name":"shared_preferences_web","path":"/Users/anthony/.pub-cache/hosted/pub.dev/shared_preferences_web-2.2.1/","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_secure_storage","dependencies":["flutter_secure_storage_linux","flutter_secure_storage_macos","flutter_secure_storage_web","flutter_secure_storage_windows"]},{"name":"flutter_secure_storage_linux","dependencies":[]},{"name":"flutter_secure_storage_macos","dependencies":[]},{"name":"flutter_secure_storage_web","dependencies":[]},{"name":"flutter_secure_storage_windows","dependencies":["path_provider"]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2024-01-01 22:38:39.981001","version":"3.16.5"} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index d9c1183..c015d83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * Update license date * Update pubspec.yaml * Add GitHub actions +* Fix dart analysis issues ## [1.1.1] - 2023-12-10 diff --git a/example/lib/main.dart b/example/lib/main.dart index 86250a6..e3905e0 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:nylo_support/helpers/extensions.dart'; import 'package:permission_policy/permission_policy.dart'; void main() { @@ -11,7 +10,7 @@ void main() { }; PermissionPolicy.instance.addRoles(roleAndPermissions); - runApp(MyApp()); + runApp(const MyApp()); } class MyApp extends StatelessWidget { @@ -43,10 +42,10 @@ class _MyHomePageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text("Permission Policy")), + appBar: AppBar(title: const Text("Permission Policy")), body: SafeArea( child: Container( - padding: EdgeInsets.symmetric(horizontal: 8), + padding: const EdgeInsets.symmetric(horizontal: 8), width: double.infinity, child: Column( crossAxisAlignment: CrossAxisAlignment.center, @@ -54,12 +53,12 @@ class _MyHomePageState extends State { children: [ ListView( shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - children: [ - Text("Your role").fontWeightBold(), + physics: const NeverScrollableScrollPhysics(), + children: const [ + Text("Your role"), UserRoles(), // This widget will show the users current role - Text("Your Permissions").fontWeightBold(), + Text("Your Permissions"), UserPermissions(), // This widget will show the users current permissions ], ), @@ -69,7 +68,7 @@ class _MyHomePageState extends State { border: Border.all(color: Colors.black12, width: 2)), child: Column( children: [ - Padding( + const Padding( padding: EdgeInsets.symmetric(vertical: 16), child: Text("Select a role"), ), @@ -82,23 +81,23 @@ class _MyHomePageState extends State { ), ), ), - RoleView( + const RoleView( roles: ['user', 'subscriber'], child: Text("The user and subscriber UI"), ), - PermissionView( - child: Text("You can subscribe"), - permissions: ['can_subscribe']), - PermissionView( - child: Text("You can unsubscribe"), - permissions: ['can_unsubscribe']), - PermissionView( - child: Text("You can view Content 🚀"), - permissions: ['view_content']), - PermissionView( - child: Text("You can view exclusive Content 🎩"), - permissions: ['view_exclusive_content']), - Divider(), + const PermissionView( + permissions: ['can_subscribe'], + child: Text("You can subscribe")), + const PermissionView( + permissions: ['can_unsubscribe'], + child: Text("You can unsubscribe")), + const PermissionView( + permissions: ['view_content'], + child: Text("You can view Content 🚀")), + const PermissionView( + permissions: ['view_exclusive_content'], + child: Text("You can view exclusive Content 🎩")), + const Divider(), ...PermissionPolicy.instance.assignableRoles().map((role) { return MaterialButton( onPressed: () async { diff --git a/example/pubspec.lock b/example/pubspec.lock index f68a3b7..dc8d5fe 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -102,6 +102,14 @@ packages: url: "https://pub.dev" source: hosted version: "5.1.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: e2a421b7e59244faef694ba7b30562e489c2b489866e505074eb005cd7060db7 + url: "https://pub.dev" + source: hosted + version: "3.0.1" flutter_localizations: dependency: transitive description: flutter @@ -197,6 +205,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.6.7" + lints: + dependency: transitive + description: + name: lints + sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290 + url: "https://pub.dev" + source: hosted + version: "3.0.0" matcher: dependency: transitive description: @@ -294,7 +310,7 @@ packages: source: hosted version: "2.2.0" permission_policy: - dependency: "direct dev" + dependency: "direct main" description: path: ".." relative: true diff --git a/example/pubspec.yaml b/example/pubspec.yaml index af0283c..4004910 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -5,15 +5,15 @@ environment: sdk: '>=2.19.0 <3.0.0' dependencies: + permission_policy: + path: ../ flutter: sdk: flutter dev_dependencies: flutter_test: sdk: flutter - - permission_policy: - path: ../ + flutter_lints: ^3.0.1 flutter: diff --git a/lib/widgets/permission_view.dart b/lib/widgets/permission_view.dart index b084576..43b7a9f 100644 --- a/lib/widgets/permission_view.dart +++ b/lib/widgets/permission_view.dart @@ -13,8 +13,10 @@ import 'package:permission_policy/permission_policy.dart'; /// ``` class PermissionView extends StatelessWidget { const PermissionView( - {Key? key, required this.child, required this.permissions, this.loading}) - : super(key: key); + {super.key, + required this.child, + required this.permissions, + this.loading}); final List permissions; final Widget? loading; diff --git a/lib/widgets/role_selector_widget.dart b/lib/widgets/role_selector_widget.dart index 69b9195..4ac8f9c 100644 --- a/lib/widgets/role_selector_widget.dart +++ b/lib/widgets/role_selector_widget.dart @@ -5,7 +5,7 @@ import 'package:permission_policy/permission_policy.dart'; /// RoleSelector is a widget that shows a list of roles that can be assigned to /// a user. class RoleSelector extends StatelessWidget { - const RoleSelector({Key? key, this.onUpdate, this.builder}) : super(key: key); + const RoleSelector({super.key, this.onUpdate, this.builder}); final Widget Function(String data)? builder; final Function()? onUpdate; diff --git a/lib/widgets/role_view_widget.dart b/lib/widgets/role_view_widget.dart index 77765a9..050b2ca 100644 --- a/lib/widgets/role_view_widget.dart +++ b/lib/widgets/role_view_widget.dart @@ -14,12 +14,11 @@ import 'package:permission_policy/permission_policy.dart'; /// ``` class RoleView extends StatelessWidget { const RoleView( - {Key? key, + {super.key, required this.roles, required this.child, this.defaultView, - this.loading}) - : super(key: key); + this.loading}); final Widget? loading, defaultView; final List roles; diff --git a/lib/widgets/user_permissions_widget.dart b/lib/widgets/user_permissions_widget.dart index b72c625..0ed67ba 100644 --- a/lib/widgets/user_permissions_widget.dart +++ b/lib/widgets/user_permissions_widget.dart @@ -6,12 +6,12 @@ import 'package:permission_policy/permission_policy.dart'; /// UserPermissions is a widget that shows the permissions for the current user. class UserPermissions extends StatefulWidget { - const UserPermissions({Key? key}) : super(key: key); + const UserPermissions({super.key}); static String state = "user_permissions"; @override - _UserPermissionsState createState() => _UserPermissionsState(); + createState() => _UserPermissionsState(); } class _UserPermissionsState extends NyState { diff --git a/lib/widgets/user_roles_widget.dart b/lib/widgets/user_roles_widget.dart index d507f60..fd3d770 100644 --- a/lib/widgets/user_roles_widget.dart +++ b/lib/widgets/user_roles_widget.dart @@ -6,12 +6,12 @@ import 'package:permission_policy/permission_policy.dart'; /// UserRole is a widget that shows the role for the current user. class UserRoles extends StatefulWidget { - const UserRoles({Key? key}) : super(key: key); + const UserRoles({super.key}); static String state = "user_roles"; @override - _UserRolesState createState() => _UserRolesState(); + createState() => _UserRolesState(); } class _UserRolesState extends NyState {