Browse Source

Fix: Null check error in FlowyHoverContainer (#2148)

* fix: fix null check error in FlowyHoverContainer and delete unnecessary widget

* chore: set child to required in FlowyHoverContainer

* chore: delete unused import file
Yijing Huang 2 years ago
parent
commit
9fff00f731

+ 0 - 24
frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/accessory/cell_accessory.dart

@@ -3,7 +3,6 @@ import 'package:flowy_infra/image.dart';
 import 'package:flowy_infra_ui/style_widget/hover.dart';
 import 'package:flutter/material.dart';
 import 'package:provider/provider.dart';
-import 'package:flowy_infra/size.dart';
 import 'package:styled_widget/styled_widget.dart';
 import 'package:appflowy/generated/locale_keys.g.dart';
 import 'package:easy_localization/easy_localization.dart';
@@ -123,7 +122,6 @@ class _AccessoryHoverState extends State<AccessoryHover> {
   @override
   Widget build(BuildContext context) {
     List<Widget> children = [
-      const _Background(),
       Padding(padding: widget.contentPadding, child: widget.child),
     ];
 
@@ -171,28 +169,6 @@ class AccessoryHoverState extends ChangeNotifier {
   bool get onHover => _onHover;
 }
 
-class _Background extends StatelessWidget {
-  const _Background({Key? key}) : super(key: key);
-
-  @override
-  Widget build(BuildContext context) {
-    return Consumer<AccessoryHoverState>(
-      builder: (context, state, child) {
-        if (state.onHover) {
-          return FlowyHoverContainer(
-            style: HoverStyle(
-              borderRadius: Corners.s6Border,
-              hoverColor: AFThemeExtension.of(context).lightGreyHover,
-            ),
-          );
-        } else {
-          return const SizedBox();
-        }
-      },
-    );
-  }
-}
-
 class CellAccessoryContainer extends StatelessWidget {
   final List<GridCellAccessoryBuilder> accessories;
   const CellAccessoryContainer({required this.accessories, Key? key})

+ 3 - 3
frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/hover.dart

@@ -115,11 +115,11 @@ class HoverStyle {
 
 class FlowyHoverContainer extends StatelessWidget {
   final HoverStyle style;
-  final Widget? child;
+  final Widget child;
 
   const FlowyHoverContainer({
     Key? key,
-    this.child,
+    required this.child,
     required this.style,
   }) : super(key: key);
 
@@ -151,7 +151,7 @@ class FlowyHoverContainer extends StatelessWidget {
               .iconTheme
               .copyWith(color: Theme.of(context).colorScheme.onSurface),
         ),
-        child: child!,
+        child: child,
       ),
     );
   }