title: Flutter scoped_model : Is it possible to pass data to a field of a model class?
body: <p>Is it possible to pass data to a field of a model class? Say from an onPressed method. It doesn't accept a onPressed function with parameters, 'onPressed: model.setNumber(25),' Or is there any way of doing this? Is Redux related to this type of passing data around?</p>
  
  <p>I have provided the code below:</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:scoped_model/scoped_model.dart';
  
  void main() {
    runApp(new MyApp());
  }
  
  class MyApp extends StatelessWidget {
    @override
   Widget build(BuildContext context) {
      return new ScopedModel&lt;CounterModel&gt;(
        model: new CounterModel(),
        child: new MaterialApp(
          title: 'Flutter Demo',
          theme: new ThemeData(
            primarySwatch: Colors.green,
          ),
          home: new CounterHome('Scoped Model Demo'),
        ),
      );
    }
  }
  
  class CounterModel extends Model {
    int myNumber = 0;
  
    void setNumber(int number) {
  
      myNumber = number;
  
      notifyListeners();
    }
  }
  
  class CounterHome extends StatelessWidget {
    final String title;
  
    CounterHome(this.title);
  
    @override
    Widget build(BuildContext context) {
      return new Scaffold(
        appBar: new AppBar(
          title: new Text(title),
        ),
        body: new Center(
          child: new Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: &lt;Widget&gt;[
              new Text(
                    'The new number is:',
                  ),
  
              new ScopedModelDescendant&lt;CounterModel&gt;(
                builder: (context, child, model) =&gt; new Text(
                    model.myNumber.toString(),
                    style: Theme.of(context).textTheme.display1),
              ),
            ],
          ),
        ),
  
        floatingActionButton: new ScopedModelDescendant&lt;CounterModel&gt;(
          builder: (context, child, model) =&gt; new FloatingActionButton(
            onPressed: model.setNumber(25), //THIS GIVES AN ERROR
            tooltip: 'new number',
            child: new Icon(Icons.add),
          ),
        ),
      );
    }
  }
  </code></pre>