title: Error when create a custom class with optional parameters in flutter
body: <p>I try to create an abstract class to create a responsive application, I follow someone in <a href="https://youtu.be/mlP5VPnxg7o" rel="nofollow noreferrer">youtube</a>, the person in the the video is using the same code as I do, but in my case I got an error in the constructor that said:</p>
  <pre><code>The parameter 'mobile' can't have a value of 'null' because of its type, but the implicit default value is 'null'.
  </code></pre>
  <p>I tried to change the mobile to optional <code>final Widget? mobile;</code> but in the condition build method I got another error:</p>
  <pre><code>The return type 'Widget?' isn't a 'Widget', as required by the closure's context. 
  </code></pre>
  <h3>Code:</h3>
  <pre><code>import 'package:flutter/material.dart';
  
  class ResponsiveWidget extends StatelessWidget {
    final Widget mobile;
    final Widget tablet;
    final Widget desktop;
  
    const ResponsiveWidget({Key? key, this.mobile, this.tablet, this.desktop})
        : super(key: key);
  
    @override
    Widget build(BuildContext context) {
      return LayoutBuilder(builder: (context, constraint) {
        if (constraint.maxWidth &lt; 768) {
          return mobile; // &lt;----------- second error here
        } else {
          return desktop;
        }
      });
    }
  }
  </code></pre>
  <p>and then we can use:</p>
  <pre><code>body: SafeArea(
    child: ResponsiveWidget(
      mobile: Column(
        children: [buildContainer(), buildText()],
      ),
      desktop: Row(
        children: [buildContainer(), buildText()],
      ),
    ),
  ),
  </code></pre>
  <h3>More details:</h3>
  <p>Even when I try to check if my widget is null or not and return a default widget for example :</p>
  <pre><code>return this.mobile != null ? mobile : Container();
  </code></pre>
  <p>I got an error:</p>
  <pre><code>The return type 'Widget?' isn't a 'Widget', as required by the closure's context. 
  </code></pre>
  <p>Is there any trick to avoid this issue please ?</p>