title: Access changed Slider value from another class in Flutter
body: <p>I have a class that has a slider.adaptive in it and the whole layout with it. In my main class I call that slider class and declare values for the layout(title etc.). The problem that I'm having is that the value from the slider itself cannot be accessed and saved in that class calling the slider class.
  I'm still a beginner with Flutter so I would enjoy easy as possible explanations, so I can comprehend them.</p>
  <p>The code I have so far:</p>
  <pre><code>class CustomSlider extends StatefulWidget {
    final double value;
    final String title;
    final String good;
    final String bad;
  
    CustomSlider({
      required this.value,
      required this.title,
      required this.good,
      required this.bad,
    });
  
    @override
    _CustomSlider createState() {
      return _CustomSlider(value: value, title: title, good: good, bad: bad);
    }
  }
  
  class _CustomSlider extends State&lt;CustomSlider&gt; {
    double value;
    String title = &quot;&quot;;
    double height = 15.0;
    double width = 10.0;
    String good;
    String bad;
  
    _CustomSlider({
      required this.value,
      required this.title,
      required this.good,
      required this.bad,
    });
  
    //double value = 0.0;
    @override
    Widget build(BuildContext context) {
      return Container(
  
  //more layout here in-between
  
                     Expanded(
                        child: Slider.adaptive(
                          value: value,
                          min: 0,
                          max: 10,
                          divisions: 10,
                          activeColor: Colors.cyanAccent,
                          onChanged: (double changedValue) {
                            setState((){
                                value = changedValue;
                            });
                            print(value);
                          },
  
                          // semanticFormatterCallback: (double endValue){
                          //   return '$value';
                          // },
                          label: value.toString(),
                        ),
                      ),
  </code></pre>
  <p>The class calling Customslider:</p>
  <pre><code>class RecordSymptoms extends StatefulWidget {
    @override
    State createState() =&gt; new _RecordSymptoms();
  }
  
  class _RecordSymptoms extends State&lt;RecordSymptoms&gt; {
    final double height = 20;
    double symptomTotal = 0;
    var generalWellbeing1;
    double generalWellbeing = 0;
    double cramps = 0;
    double flatulence = 0;
    double bowel = 0;
  
    @override
    Widget build(BuildContext context) =&gt; Scaffold(
          backgroundColor: Colors.teal[100],
          endDrawer: menu(),
          appBar: AppBar(
            title: Text(
              'Symptome erfassen',
              style: TextStyle(
                color: Colors.black,
              ),
            ),
            backgroundColor: Colors.cyanAccent,
          ),
          body: Stack(
            children: &lt;Widget&gt;[
              Positioned.fill(
                child: Image(
                  image: AssetImage('assets/Inner_Peace.png'),
                  fit: BoxFit.fill,
                ),
              ),
              Column(
                children: &lt;Widget&gt;[
                  CustomSlider(
                      value: generalWellbeing,
                      title: 'Allgemeines Wohlbefinden',
                      good: &quot;Gut&quot;,
                      bad: &quot;Schlecht&quot;),
                  CustomSlider(
                      value: cramps,
                      title: 'Krämpfe',
                      good: &quot;Keine&quot;,
                      bad: &quot;Extrem&quot;),
                  CustomSlider(
                      value: flatulence,
                      title: 'Blähungen',
                      good: &quot;Keine&quot;,
                      bad: &quot;Extrem&quot;),
                  CustomSlider(
                      value: bowel,
                      title: 'Stuhlgang',
                      good: &quot;Fest&quot;,
                      bad: &quot;Flüssig&quot;),
                  Spacer(),
                  Container(
                    child: Row(
                      children: &lt;Widget&gt;[
                        Flexible(
                          flex: 20,
                          child: CustomButton(
                            text: 'Keine Symptome',
                            onClick: () {
                              Navigator.of(context).push(
                                MaterialPageRoute(
                                  builder: (context) =&gt; RecordedMeals(),
                                ),
                              );
                            },
                          ),
                        ),
                        Flexible(
                          flex: 20,
                          child: CustomButton(
                            text: 'Symptome speichern',
                            onClick: () async {
                              Navigator.of(context).push(
                                MaterialPageRoute(
                                  builder: (context) =&gt; RecordedMeals(),
                                ),
                              );
                              print(generalWellbeing);
                              print(bowel.toString());
                              print(cramps.toString());
                              print(flatulence.toString());
                            },
                          ),
                        ),
                      ],
                    ),
                  ),
                  SizedBox(height: height),
                ],
              ),
            ],
          ),
        );
  </code></pre>
  <p>I tried the <code>semanticFormatterCallback</code>, but I don't know how to be able to get that over to the other class. I've also tried to change the class into a function, but then I have the problem that the sliders of all four sliders move together.</p>
  <p>the <code>print(flatulence.toString());</code> and the other ones all print out 0.0 which makes sense when it cant get the value from the other class since I initialized them with 0.</p>