Browse Source

Made state variables final and private

ashilkn 2 năm trước cách đây
mục cha
commit
0da37cc847

+ 16 - 16
lib/ui/viewer/location/add_location_sheet.dart

@@ -50,14 +50,14 @@ class AddLocationSheet extends StatefulWidget {
 }
 }
 
 
 class _AddLocationSheetState extends State<AddLocationSheet> {
 class _AddLocationSheetState extends State<AddLocationSheet> {
+  //The value of these notifiers has no significance.
   //When memoriesCountNotifier is null, we show the loading widget in the
   //When memoriesCountNotifier is null, we show the loading widget in the
   //memories count section which also means the gallery is loading.
   //memories count section which also means the gallery is loading.
-  ValueNotifier<int?> memoriesCountNotifier = ValueNotifier(null);
-  //The value of this notifier has no significance.
-  ValueNotifier<bool> submitNotifer = ValueNotifier(false);
-  ValueNotifier<bool> cancelNotifier = ValueNotifier(false);
+  final ValueNotifier<int?> _memoriesCountNotifier = ValueNotifier(null);
+  final ValueNotifier<bool> _submitNotifer = ValueNotifier(false);
+  final ValueNotifier<bool> _cancelNotifier = ValueNotifier(false);
   final _focusNode = FocusNode();
   final _focusNode = FocusNode();
-  Widget? keyboardTopButtons;
+  Widget? _keyboardTopButtons;
 
 
   @override
   @override
   void initState() {
   void initState() {
@@ -68,8 +68,8 @@ class _AddLocationSheetState extends State<AddLocationSheet> {
   @override
   @override
   void dispose() {
   void dispose() {
     _focusNode.removeListener(_focusNodeListener);
     _focusNode.removeListener(_focusNodeListener);
-    submitNotifer.dispose();
-    cancelNotifier.dispose();
+    _submitNotifer.dispose();
+    _cancelNotifier.dispose();
     super.dispose();
     super.dispose();
   }
   }
 
 
@@ -100,8 +100,8 @@ class _AddLocationSheetState extends State<AddLocationSheet> {
                           hintText: "Location name",
                           hintText: "Location name",
                           borderRadius: 2,
                           borderRadius: 2,
                           focusNode: _focusNode,
                           focusNode: _focusNode,
-                          submitNotifier: submitNotifer,
-                          cancelNotifier: cancelNotifier,
+                          submitNotifier: _submitNotifer,
+                          cancelNotifier: _cancelNotifier,
                           popNavAfterSubmission: true,
                           popNavAfterSubmission: true,
                           onSubmit: (locationName) async {
                           onSubmit: (locationName) async {
                             await _addLocationTag(locationName);
                             await _addLocationTag(locationName);
@@ -110,7 +110,7 @@ class _AddLocationSheetState extends State<AddLocationSheet> {
                           alwaysShowSuccessState: true,
                           alwaysShowSuccessState: true,
                         ),
                         ),
                         const SizedBox(height: 24),
                         const SizedBox(height: 24),
-                        RadiusPickerWidget(memoriesCountNotifier),
+                        RadiusPickerWidget(_memoriesCountNotifier),
                         const SizedBox(height: 24),
                         const SizedBox(height: 24),
                         Text(
                         Text(
                           "A location tag groups all photos that were taken within some radius of a photo",
                           "A location tag groups all photos that were taken within some radius of a photo",
@@ -128,7 +128,7 @@ class _AddLocationSheetState extends State<AddLocationSheet> {
                     child: Padding(
                     child: Padding(
                       padding: const EdgeInsets.symmetric(horizontal: 16),
                       padding: const EdgeInsets.symmetric(horizontal: 16),
                       child: ValueListenableBuilder(
                       child: ValueListenableBuilder(
-                        valueListenable: memoriesCountNotifier,
+                        valueListenable: _memoriesCountNotifier,
                         builder: (context, value, _) {
                         builder: (context, value, _) {
                           Widget widget;
                           Widget widget;
                           if (value == null) {
                           if (value == null) {
@@ -174,7 +174,7 @@ class _AddLocationSheetState extends State<AddLocationSheet> {
                     ),
                     ),
                   ),
                   ),
                   const SizedBox(height: 24),
                   const SizedBox(height: 24),
-                  AddLocationGalleryWidget(memoriesCountNotifier),
+                  AddLocationGalleryWidget(_memoriesCountNotifier),
                 ],
                 ],
               ),
               ),
             ),
             ),
@@ -199,16 +199,16 @@ class _AddLocationSheetState extends State<AddLocationSheet> {
 
 
   void _focusNodeListener() {
   void _focusNodeListener() {
     final bool hasFocus = _focusNode.hasFocus;
     final bool hasFocus = _focusNode.hasFocus;
-    keyboardTopButtons ??= KeyboardTopButton(
+    _keyboardTopButtons ??= KeyboardTopButton(
       onDoneTap: () {
       onDoneTap: () {
-        submitNotifer.value = !submitNotifer.value;
+        _submitNotifer.value = !_submitNotifer.value;
       },
       },
       onCancelTap: () {
       onCancelTap: () {
-        cancelNotifier.value = !cancelNotifier.value;
+        _cancelNotifier.value = !_cancelNotifier.value;
       },
       },
     );
     );
     if (hasFocus) {
     if (hasFocus) {
-      KeyboardOverlay.showOverlay(context, keyboardTopButtons!);
+      KeyboardOverlay.showOverlay(context, _keyboardTopButtons!);
     } else {
     } else {
       KeyboardOverlay.removeOverlay();
       KeyboardOverlay.removeOverlay();
     }
     }