title: Flutter Error: The Method toDouble() was called on null, Tried calling toDouble
body: <p>I am stuck on the error saying <code>toDouble was called on null</code>. I have checked my code many times and I can't figure out whats happening.</p>
  <p>This is the code for bottom_sheet_panel</p>
  <pre><code>import 'package:flutter/material.dart';
  import 'package:freezeria/Screens/services/database.dart';
  import 'package:freezeria/common_code/common.dart';
  import 'package:freezeria/common_code/loader.dart';
  import 'package:freezeria/req_info/shakes.dart';
  import 'package:freezeria/req_info/user.dart';
  import 'package:provider/provider.dart';
  
  class bottomSheetPanel extends StatefulWidget {
    @override
    _bottomSheetPanelState createState() =&gt; _bottomSheetPanelState();
  }
  
  class _bottomSheetPanelState extends State&lt;bottomSheetPanel&gt; {
    final _formkey = GlobalKey&lt;FormState&gt;();
    final List&lt;String&gt; blending = ['1', '2', '3', '4', '5'];
    final List&lt;String&gt; cupsize = ['Select', 'Small', 'Medium', 'Large'];
    final List&lt;String&gt; flavour = [
      'Chocolate',
      'Vanilla',
      'Strawberry',
      'Blueberry',
      'Raspberry',
      'Kiwi',
      'Select'
    ];
    final List&lt;String&gt; cream = [
      'Whipped',
      'Caramel',
      'Chocolate',
      'Strawberry',
      'Select'
    ];
    final List&lt;String&gt; toppings = [
      'Oreo',
      'Cherry',
      'Strawberry',
      'Sweet Lime',
      'Waffle',
      'Blackberries',
      'Select'
    ];
  
    String _currentName;
    String _currentCupSize;
    int _currentBlend;
    String _currentFlavour;
    String _currentCream;
    String _currentToppings;
    @override
    Widget build(BuildContext context) {
      final receiveUser = Provider.of&lt;User&gt;(context);
  
      return StreamBuilder&lt;UserData&gt;(
          stream: Database(uid: receiveUser.uid).userDataStream,
          builder: (context, snapshot) {
            if (snapshot.hasData) {
              UserData recentData = snapshot.data;
              return Form(
                key: _formkey,
                child: SingleChildScrollView(
                  child: Column(
                    children: [
                      Text(
                        &quot;Update Your Data&quot;,
                        style: TextStyle(fontSize: 20.0),
                      ),
                      SizedBox(
                        height: 20.0,
                      ),
                      TextFormField(
                        initialValue: recentData.Name,
                        decoration:
                            decorationCode.copyWith(hintText: 'Enter your name'),
                        validator: (val) =&gt;
                            val.isEmpty ? 'Please enter a name' : null,
                        onChanged: (val) =&gt; setState(() {
                          return _currentName = val;
                        }),
                      ),
                      SizedBox(
                        height: 20.0,
                      ),
                      DropdownButtonFormField(
                        value: _currentCupSize ?? recentData.CupSize,
                        items: cupsize.map((size) {
                          return DropdownMenuItem(
                            value: size,
                            child: Text('$size Size'),
                          );
                        }).toList(),
                        onChanged: (val) =&gt; setState(() {
                          return _currentCupSize = val;
                        }),
                      ),
                      SizedBox(
                        height: 20.0,
                      ),
                      Slider(
                        value: (_currentBlend ?? recentData.Blend).toDouble(),
                        activeColor:
                            Colors.grey[_currentBlend ?? recentData.Blend],
                        inactiveColor:
                            Colors.grey[_currentBlend ?? recentData.Blend],
                        min: 100.0,
                        max: 700.0,
                        divisions: 6,
                        onChangeEnd: (val) =&gt; setState(() {
                          return _currentBlend = val.round();
                        }),
                        
                      ),
                      SizedBox(
                        height: 20.0,
                      ),
                      DropdownButtonFormField(
                        value: _currentFlavour ?? recentData.Flavour,
                        items: flavour.map((flav) {
                          return DropdownMenuItem(
                            value: flav,
                            child: Text('$flav Flavour'),
                          );
                        }).toList(),
                        onChanged: (val) =&gt; setState(() {
                          return _currentFlavour = val;
                        }),
                      ),
                      SizedBox(
                        height: 20.0,
                      ),
                      DropdownButtonFormField(
                        value: _currentCream ?? recentData.Cream,
                        items: cream.map((crem) {
                          return DropdownMenuItem(
                            value: crem,
                            child: Text('$crem Cream'),
                          );
                        }).toList(),
                        onChanged: (val) =&gt; setState(() {
                          return _currentCream = val;
                        }),
                      ),
                      SizedBox(
                        height: 20.0,
                      ),
                      DropdownButtonFormField(
                        value: _currentToppings ?? recentData.Toppings,
                        items: toppings.map((top) {
                          return DropdownMenuItem(
                            value: top,
                            child: Text('$top Toppings'),
                          );
                        }).toList(),
                        onChanged: (val) =&gt; setState(() {
                          return _currentToppings = val;
                        }),
                      ),
                      SizedBox(
                        height: 20.0,
                      ),
                      ElevatedButton(
                        onPressed: () async {
                          print(_currentName);
                          print(_currentBlend);
                          print(_currentCupSize);
                          print(_currentFlavour);
                          print(_currentToppings);
                        },
                        style: ButtonStyle(
                          backgroundColor: MaterialStateProperty.all&lt;Color&gt;(
                              Colors.purple[300]),
                          foregroundColor:
                              MaterialStateProperty.all&lt;Color&gt;(Colors.white),
                        ),
                        child: Text(
                          'UPDATE',
                          style: TextStyle(color: Colors.white),
                        ),
                      )
                    ],
                  ),
                ),
              );
            } else {
              Loading();
            }
          });
    }
  }
  </code></pre>
  <p>The <code>toDouble()</code> in Slider Function is giving error, also <code>recentData.name</code> is not updating the name in the bottom sheet.</p>
  <p>It is seen that <code>_currentBlend</code> and <code>recentData</code> are giving null values, how do I correct it?</p>
  <p>Any help will be much appreciated:)</p>