Malarg commented on code in PR #24338:
URL: https://github.com/apache/beam/pull/24338#discussion_r1044151719


##########
playground/frontend/lib/modules/editor/components/share_dropdown/share_button.dart:
##########
@@ -18,16 +18,21 @@
 
 import 'package:flutter/material.dart';
 import 'package:flutter_gen/gen_l10n/app_localizations.dart';
-import 'package:playground/components/dropdown_button/dropdown_button.dart';
-import 
'package:playground/modules/editor/components/share_dropdown/share_dropdown_body.dart';
 import 'package:playground_components/playground_components.dart';
 
+import '../../../../components/dropdown_button/dropdown_button.dart';
+import 'share_dropdown_body.dart';
+
 const _kShareDropdownHeight = 140.0;
 const _kShareDropdownWidth = 460.0;
 const _kButtonColorOpacity = 0.2;
 
 class ShareButton extends StatelessWidget {
-  const ShareButton({super.key});
+  final PlaygroundController playgroundController;

Review Comment:
   I think, that compile-time guarantee of presence instance class will never 
be done in flutter, because, widget tree can be changes at runtime. 
   For example, look at this code:
   ```
   class Blue42 extends StatefulWidget {
     final Widget child;
   
     const Blue42({super.key, required this.child});
     @override
     _Blue42State createState() => _Blue42State();
   }
   
   class _Blue42State extends State<Blue42> {
     @override
     Widget build(BuildContext context) {
       final isOddSecond = DateTime.now().second.isOdd;
       if (isOddSecond) {
         return Provider.value(value: Colors.blue, child: widget.child);
       } else {
         return Provider.value(value: 42, child: widget.child);
       }
     }
   }
   ```
   You will never be sure, What exactly exists in the tree - `Colors.blue` or 
`42`. It's absolutely synthetic example, but it demonstrates that it's 
impossible to guarantee at compile-time that tree contains specific object. I'm 
sure, that it's not a reason for ridding of provider opportunities because of 
obtaining compile time guarantee. Eventually even Flutter use this mechanism 
every time when you use `Theme.of` or `MediaQuery.of`, so you trust flutter 
that these objects exists in the tree. We can trust ourselves too, so I don't 
think it will be a problem if we will use provider for objects which have to 
exist in a whole application lifecycle. 
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to