Browse Source

Lint fixes for trailing comma

Neeraj Gupta 3 years ago
parent
commit
c15e054204

+ 1 - 0
analysis_options.yaml

@@ -35,6 +35,7 @@ analyzer:
     exhaustive_cases: error
     exhaustive_cases: error
     curly_braces_in_flow_control_structures: error
     curly_braces_in_flow_control_structures: error
     directives_ordering: error
     directives_ordering: error
+    require_trailing_commas: warning
     always_use_package_imports: error
     always_use_package_imports: error
     prefer_final_fields: error
     prefer_final_fields: error
     unused_import: error
     unused_import: error

+ 6 - 13
lib/services/memories_service.dart

@@ -65,16 +65,12 @@ class MemoriesService extends ChangeNotifier {
     final List<List<int>> durations = [];
     final List<List<int>> durations = [];
     for (var yearAgo = 1; yearAgo <= yearsBefore; yearAgo++) {
     for (var yearAgo = 1; yearAgo <= yearsBefore; yearAgo++) {
       final date = _getDate(present, yearAgo);
       final date = _getDate(present, yearAgo);
-      final startCreationTime =
-          date.subtract(Duration(days: daysBefore)).microsecondsSinceEpoch;
-      final endCreationTime =
-          date.add(Duration(days: daysAfter)).microsecondsSinceEpoch;
+      final startCreationTime = date.subtract(Duration(days: daysBefore)).microsecondsSinceEpoch;
+      final endCreationTime = date.add(Duration(days: daysAfter)).microsecondsSinceEpoch;
       durations.add([startCreationTime, endCreationTime]);
       durations.add([startCreationTime, endCreationTime]);
     }
     }
-    final archivedCollectionIds =
-        CollectionsService.instance.getArchivedCollections();
-    final files = await _filesDB.getFilesCreatedWithinDurations(
-        durations, archivedCollectionIds);
+    final archivedCollectionIds = CollectionsService.instance.getArchivedCollections();
+    final files = await _filesDB.getFilesCreatedWithinDurations(durations, archivedCollectionIds);
     final seenTimes = await _memoriesDB.getSeenTimes();
     final seenTimes = await _memoriesDB.getSeenTimes();
     final List<Memory> memories = [];
     final List<Memory> memories = [];
     final filter = ImportantItemsFilter();
     final filter = ImportantItemsFilter();
@@ -90,11 +86,8 @@ class MemoriesService extends ChangeNotifier {
 
 
   DateTime _getDate(DateTime present, int yearAgo) {
   DateTime _getDate(DateTime present, int yearAgo) {
     final year = (present.year - yearAgo).toString();
     final year = (present.year - yearAgo).toString();
-    final month = present.month > 9
-        ? present.month.toString()
-        : "0" + present.month.toString();
-    final day =
-        present.day > 9 ? present.day.toString() : "0" + present.day.toString();
+    final month = present.month > 9 ? present.month.toString() : "0" + present.month.toString();
+    final day = present.day > 9 ? present.day.toString() : "0" + present.day.toString();
     final date = DateTime.parse(year + "-" + month + "-" + day);
     final date = DateTime.parse(year + "-" + month + "-" + day);
     return date;
     return date;
   }
   }

+ 4 - 5
lib/ui/grant_permissions_widget.dart

@@ -8,8 +8,7 @@ class GrantPermissionsWidget extends StatelessWidget {
   const GrantPermissionsWidget({Key key}) : super(key: key);
   const GrantPermissionsWidget({Key key}) : super(key: key);
   @override
   @override
   Widget build(BuildContext context) {
   Widget build(BuildContext context) {
-    final isLightMode =
-        MediaQuery.of(context).platformBrightness == Brightness.light;
+    final isLightMode = MediaQuery.of(context).platformBrightness == Brightness.light;
     return Scaffold(
     return Scaffold(
       body: SingleChildScrollView(
       body: SingleChildScrollView(
         child: Column(
         child: Column(
@@ -31,7 +30,8 @@ class GrantPermissionsWidget extends StatelessWidget {
                                 colorBlendMode: BlendMode.modulate,
                                 colorBlendMode: BlendMode.modulate,
                               )
                               )
                             : Image.asset(
                             : Image.asset(
-                                'assets/loading_photos_background_dark.png'),
+                                'assets/loading_photos_background_dark.png',
+                              ),
                         Center(
                         Center(
                           child: Column(
                           child: Column(
                             children: [
                             children: [
@@ -95,8 +95,7 @@ class GrantPermissionsWidget extends StatelessWidget {
           child: Text("Grant permission"),
           child: Text("Grant permission"),
           onPressed: () async {
           onPressed: () async {
             final state = await PhotoManager.requestPermissionExtend();
             final state = await PhotoManager.requestPermissionExtend();
-            if (state == PermissionState.authorized ||
-                state == PermissionState.limited) {
+            if (state == PermissionState.authorized || state == PermissionState.limited) {
               await SyncService.instance.onPermissionGranted(state);
               await SyncService.instance.onPermissionGranted(state);
             } else if (state == PermissionState.denied) {
             } else if (state == PermissionState.denied) {
               AlertDialog alert = AlertDialog(
               AlertDialog alert = AlertDialog(

+ 9 - 14
lib/ui/huge_listview/lazy_loading_gallery.dart

@@ -70,10 +70,8 @@ class _LazyLoadingGalleryState extends State<LazyLoadingGallery> {
 
 
     _reloadEventSubscription = widget.reloadEvent.listen((e) => _onReload(e));
     _reloadEventSubscription = widget.reloadEvent.listen((e) => _onReload(e));
 
 
-    _currentIndexSubscription =
-        widget.currentIndexStream.listen((currentIndex) {
-      bool shouldRender = (currentIndex - widget.index).abs() <
-          kNumberOfDaysToRenderBeforeAndAfter;
+    _currentIndexSubscription = widget.currentIndexStream.listen((currentIndex) {
+      bool shouldRender = (currentIndex - widget.index).abs() < kNumberOfDaysToRenderBeforeAndAfter;
       if (mounted && shouldRender != _shouldRender) {
       if (mounted && shouldRender != _shouldRender) {
         setState(() {
         setState(() {
           _shouldRender = shouldRender;
           _shouldRender = shouldRender;
@@ -83,8 +81,7 @@ class _LazyLoadingGalleryState extends State<LazyLoadingGallery> {
   }
   }
 
 
   Future _onReload(FilesUpdatedEvent event) async {
   Future _onReload(FilesUpdatedEvent event) async {
-    final galleryDate =
-        DateTime.fromMicrosecondsSinceEpoch(_files[0].creationTime);
+    final galleryDate = DateTime.fromMicrosecondsSinceEpoch(_files[0].creationTime);
     final filesUpdatedThisDay = event.updatedFiles.where((file) {
     final filesUpdatedThisDay = event.updatedFiles.where((file) {
       final fileDate = DateTime.fromMicrosecondsSinceEpoch(file.creationTime);
       final fileDate = DateTime.fromMicrosecondsSinceEpoch(file.creationTime);
       return fileDate.year == galleryDate.year &&
       return fileDate.year == galleryDate.year &&
@@ -98,8 +95,7 @@ class _LazyLoadingGalleryState extends State<LazyLoadingGallery> {
             getDayTitle(galleryDate.microsecondsSinceEpoch),
             getDayTitle(galleryDate.microsecondsSinceEpoch),
       );
       );
       if (event.type == EventType.addedOrUpdated) {
       if (event.type == EventType.addedOrUpdated) {
-        final dayStartTime =
-            DateTime(galleryDate.year, galleryDate.month, galleryDate.day);
+        final dayStartTime = DateTime(galleryDate.year, galleryDate.month, galleryDate.day);
         final result = await widget.asyncLoader(
         final result = await widget.asyncLoader(
           dayStartTime.microsecondsSinceEpoch,
           dayStartTime.microsecondsSinceEpoch,
           dayStartTime.microsecondsSinceEpoch + kMicroSecondsInDay - 1,
           dayStartTime.microsecondsSinceEpoch + kMicroSecondsInDay - 1,
@@ -170,7 +166,9 @@ class _LazyLoadingGalleryState extends State<LazyLoadingGallery> {
         LazyLoadingGridView(
         LazyLoadingGridView(
           widget.tag,
           widget.tag,
           _files.sublist(
           _files.sublist(
-              index, min(index + kSubGalleryItemLimit, _files.length)),
+            index,
+            min(index + kSubGalleryItemLimit, _files.length),
+          ),
           widget.asyncLoader,
           widget.asyncLoader,
           widget.selectedFiles,
           widget.selectedFiles,
           index == 0,
           index == 0,
@@ -255,9 +253,7 @@ class _LazyLoadingGridViewState extends State<LazyLoadingGridView> {
           });
           });
         }
         }
       },
       },
-      child: _shouldRender
-          ? _getGridView()
-          : PlaceHolderWidget(widget.files.length),
+      child: _shouldRender ? _getGridView() : PlaceHolderWidget(widget.files.length),
     );
     );
   }
   }
 
 
@@ -282,8 +278,7 @@ class _LazyLoadingGridViewState extends State<LazyLoadingGridView> {
   Widget _getGridView() {
   Widget _getGridView() {
     return GridView.builder(
     return GridView.builder(
       shrinkWrap: true,
       shrinkWrap: true,
-      physics:
-          NeverScrollableScrollPhysics(), // to disable GridView's scrolling
+      physics: NeverScrollableScrollPhysics(), // to disable GridView's scrolling
       itemBuilder: (context, index) {
       itemBuilder: (context, index) {
         return _buildFile(context, widget.files[index]);
         return _buildFile(context, widget.files[index]);
       },
       },

+ 4 - 3
lib/ui/settings/debug_section_widget.dart

@@ -28,7 +28,9 @@ class DebugSectionWidget extends StatelessWidget {
             _showKeyAttributesDialog(context);
             _showKeyAttributesDialog(context);
           },
           },
           child: SettingsTextItem(
           child: SettingsTextItem(
-              text: "Key attributes", icon: Icons.navigate_next),
+            text: "Key attributes",
+            icon: Icons.navigate_next,
+          ),
         ),
         ),
         GestureDetector(
         GestureDetector(
           behavior: HitTestBehavior.translucent,
           behavior: HitTestBehavior.translucent,
@@ -54,8 +56,7 @@ class DebugSectionWidget extends StatelessWidget {
             Text("Key", style: TextStyle(fontWeight: FontWeight.bold)),
             Text("Key", style: TextStyle(fontWeight: FontWeight.bold)),
             Text(Sodium.bin2base64(Configuration.instance.getKey())),
             Text(Sodium.bin2base64(Configuration.instance.getKey())),
             Padding(padding: EdgeInsets.all(12)),
             Padding(padding: EdgeInsets.all(12)),
-            Text("Encrypted Key",
-                style: TextStyle(fontWeight: FontWeight.bold)),
+            Text("Encrypted Key", style: TextStyle(fontWeight: FontWeight.bold)),
             Text(keyAttributes.encryptedKey),
             Text(keyAttributes.encryptedKey),
             Padding(padding: EdgeInsets.all(12)),
             Padding(padding: EdgeInsets.all(12)),
             Text(
             Text(

+ 17 - 37
lib/ui/settings/details_section_widget.dart

@@ -28,12 +28,10 @@ class _DetailsSectionWidgetState extends State<DetailsSectionWidget> {
   void initState() {
   void initState() {
     super.initState();
     super.initState();
     _fetchUserDetails();
     _fetchUserDetails();
-    _userDetailsChangedEvent =
-        Bus.instance.on<UserDetailsChangedEvent>().listen((event) {
+    _userDetailsChangedEvent = Bus.instance.on<UserDetailsChangedEvent>().listen((event) {
       _fetchUserDetails();
       _fetchUserDetails();
     });
     });
-    _tabChangedEventSubscription =
-        Bus.instance.on<TabChangedEvent>().listen((event) {
+    _tabChangedEventSubscription = Bus.instance.on<TabChangedEvent>().listen((event) {
       if (event.selectedIndex == 3) {
       if (event.selectedIndex == 3) {
         _fetchUserDetails();
         _fetchUserDetails();
       }
       }
@@ -104,8 +102,7 @@ class _DetailsSectionWidgetState extends State<DetailsSectionWidget> {
           _userDetails == null
           _userDetails == null
               ? const EnteLoadingWidget()
               ? const EnteLoadingWidget()
               : Padding(
               : Padding(
-                  padding:
-                      EdgeInsets.only(top: 20, bottom: 20, left: 16, right: 16),
+                  padding: EdgeInsets.only(top: 20, bottom: 20, left: 16, right: 16),
                   child: Container(
                   child: Container(
                     color: Colors.transparent,
                     color: Colors.transparent,
                     child: Column(
                     child: Column(
@@ -122,8 +119,7 @@ class _DetailsSectionWidgetState extends State<DetailsSectionWidget> {
                                 style: Theme.of(context)
                                 style: Theme.of(context)
                                     .textTheme
                                     .textTheme
                                     .subtitle2
                                     .subtitle2
-                                    .copyWith(
-                                        color: Colors.white.withOpacity(0.7)),
+                                    .copyWith(color: Colors.white.withOpacity(0.7)),
                               ),
                               ),
                               Text(
                               Text(
                                 "${convertBytesToReadableFormat(_userDetails.getFreeStorage())} of ${convertBytesToReadableFormat(_userDetails.getTotalStorage())} free",
                                 "${convertBytesToReadableFormat(_userDetails.getFreeStorage())} of ${convertBytesToReadableFormat(_userDetails.getTotalStorage())} free",
@@ -150,16 +146,14 @@ class _DetailsSectionWidgetState extends State<DetailsSectionWidget> {
                                 Container(
                                 Container(
                                   color: Colors.white.withOpacity(0.75),
                                   color: Colors.white.withOpacity(0.75),
                                   width: MediaQuery.of(context).size.width *
                                   width: MediaQuery.of(context).size.width *
-                                      ((_userDetails
-                                              .getFamilyOrPersonalUsage()) /
+                                      ((_userDetails.getFamilyOrPersonalUsage()) /
                                           _userDetails.getTotalStorage()),
                                           _userDetails.getTotalStorage()),
                                   height: 4,
                                   height: 4,
                                 ),
                                 ),
                                 Container(
                                 Container(
                                   color: Colors.white,
                                   color: Colors.white,
                                   width: MediaQuery.of(context).size.width *
                                   width: MediaQuery.of(context).size.width *
-                                      (_userDetails.usage /
-                                          _userDetails.getTotalStorage()),
+                                      (_userDetails.usage / _userDetails.getTotalStorage()),
                                   height: 4,
                                   height: 4,
                                 ),
                                 ),
                               ],
                               ],
@@ -179,41 +173,30 @@ class _DetailsSectionWidgetState extends State<DetailsSectionWidget> {
                                               color: Colors.white,
                                               color: Colors.white,
                                             ),
                                             ),
                                           ),
                                           ),
-                                          Padding(
-                                              padding:
-                                                  EdgeInsets.only(right: 4)),
+                                          Padding(padding: EdgeInsets.only(right: 4)),
                                           Text(
                                           Text(
                                             "You",
                                             "You",
                                             style: Theme.of(context)
                                             style: Theme.of(context)
                                                 .textTheme
                                                 .textTheme
                                                 .bodyText1
                                                 .bodyText1
-                                                .copyWith(
-                                                    color: Colors.white,
-                                                    fontSize: 12),
+                                                .copyWith(color: Colors.white, fontSize: 12),
                                           ),
                                           ),
-                                          Padding(
-                                              padding:
-                                                  EdgeInsets.only(right: 12)),
+                                          Padding(padding: EdgeInsets.only(right: 12)),
                                           Container(
                                           Container(
                                             width: 8.71,
                                             width: 8.71,
                                             height: 8.99,
                                             height: 8.99,
                                             decoration: BoxDecoration(
                                             decoration: BoxDecoration(
                                               shape: BoxShape.circle,
                                               shape: BoxShape.circle,
-                                              color: Colors.white
-                                                  .withOpacity(0.75),
+                                              color: Colors.white.withOpacity(0.75),
                                             ),
                                             ),
                                           ),
                                           ),
-                                          Padding(
-                                              padding:
-                                                  EdgeInsets.only(right: 4)),
+                                          Padding(padding: EdgeInsets.only(right: 4)),
                                           Text(
                                           Text(
                                             "Family",
                                             "Family",
-                                            style: Theme.of(context)
-                                                .textTheme
-                                                .bodyText1
-                                                .copyWith(
-                                                    color: Colors.white,
-                                                    fontSize: 12),
+                                            style: Theme.of(context).textTheme.bodyText1.copyWith(
+                                                  color: Colors.white,
+                                                  fontSize: 12,
+                                                ),
                                           ),
                                           ),
                                         ],
                                         ],
                                       )
                                       )
@@ -222,9 +205,7 @@ class _DetailsSectionWidgetState extends State<DetailsSectionWidget> {
                                         style: Theme.of(context)
                                         style: Theme.of(context)
                                             .textTheme
                                             .textTheme
                                             .bodyText1
                                             .bodyText1
-                                            .copyWith(
-                                                color: Colors.white,
-                                                fontSize: 12),
+                                            .copyWith(color: Colors.white, fontSize: 12),
                                       ),
                                       ),
                                 Padding(
                                 Padding(
                                   padding: const EdgeInsets.only(right: 16.0),
                                   padding: const EdgeInsets.only(right: 16.0),
@@ -233,8 +214,7 @@ class _DetailsSectionWidgetState extends State<DetailsSectionWidget> {
                                     style: Theme.of(context)
                                     style: Theme.of(context)
                                         .textTheme
                                         .textTheme
                                         .bodyText1
                                         .bodyText1
-                                        .copyWith(
-                                            color: Colors.white, fontSize: 12),
+                                        .copyWith(color: Colors.white, fontSize: 12),
                                   ),
                                   ),
                                 )
                                 )
                               ],
                               ],

+ 2 - 5
lib/ui/settings/theme_switch_widget.dart

@@ -16,7 +16,7 @@ class ThemeSwitchWidget extends StatelessWidget {
       current: selectedTheme,
       current: selectedTheme,
       values: const [0, 1],
       values: const [0, 1],
       onChanged: (i) {
       onChanged: (i) {
-        print("Changed to ${i}, selectedTheme is ${selectedTheme} ");
+        debugPrint("Changed to {i}, selectedTheme is {selectedTheme} ");
         if (i == 0) {
         if (i == 0) {
           AdaptiveTheme.of(context).setLight();
           AdaptiveTheme.of(context).setLight();
         } else {
         } else {
@@ -42,10 +42,7 @@ class ThemeSwitchWidget extends StatelessWidget {
       height: 36,
       height: 36,
       indicatorSize: Size(36, 36),
       indicatorSize: Size(36, 36),
       indicatorColor: Theme.of(context).colorScheme.themeSwitchIndicatorColor,
       indicatorColor: Theme.of(context).colorScheme.themeSwitchIndicatorColor,
-      borderColor: Theme.of(context)
-          .colorScheme
-          .themeSwitchInactiveIconColor
-          .withOpacity(0.1),
+      borderColor: Theme.of(context).colorScheme.themeSwitchInactiveIconColor.withOpacity(0.1),
       borderWidth: 1,
       borderWidth: 1,
     );
     );
   }
   }

+ 10 - 11
lib/ui/settings_page.dart

@@ -53,9 +53,7 @@ class SettingsPage extends StatelessWidget {
               },
               },
             ),
             ),
 
 
-            (Platform.isAndroid)
-                ? ThemeSwitchWidget()
-                : const SizedBox.shrink(),
+            (Platform.isAndroid) ? ThemeSwitchWidget() : const SizedBox.shrink(),
           ],
           ],
         ),
         ),
       ),
       ),
@@ -103,15 +101,16 @@ class SettingsPage extends StatelessWidget {
 
 
     return SingleChildScrollView(
     return SingleChildScrollView(
       child: Padding(
       child: Padding(
-          padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 20),
-          child: Center(
-            child: ConstrainedBox(
-              constraints: BoxConstraints(maxWidth: 350),
-              child: Column(
-                children: contents,
-              ),
+        padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 20),
+        child: Center(
+          child: ConstrainedBox(
+            constraints: BoxConstraints(maxWidth: 350),
+            child: Column(
+              children: contents,
             ),
             ),
-          )),
+          ),
+        ),
+      ),
     );
     );
   }
   }
 }
 }

+ 6 - 2
lib/ui/viewer/gallery/gallery.dart

@@ -17,8 +17,12 @@ import 'package:photos/ui/viewer/gallery/empte_state.dart';
 import 'package:photos/utils/date_time_util.dart';
 import 'package:photos/utils/date_time_util.dart';
 import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
 import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
 
 
-typedef GalleryLoader = Future<FileLoadResult> Function(int creationStartTime, int creationEndTime,
-    {int limit, bool asc});
+typedef GalleryLoader = Future<FileLoadResult> Function(
+  int creationStartTime,
+  int creationEndTime, {
+  int limit,
+  bool asc,
+});
 
 
 class Gallery extends StatefulWidget {
 class Gallery extends StatefulWidget {
   final GalleryLoader asyncLoader;
   final GalleryLoader asyncLoader;