# 23 Flutter: Radio with Functions

{% code title="main.dart" %}

```dart
import 'package:flutter/material.dart';

void main(){
  runApp(new MaterialApp(
    home: new MyApp(),
  ));
}

class MyApp extends StatefulWidget {
  @override
  _State createState() => new _State();
}

//State is information of the application that can change over time or when some actions are taken.
class _State extends State<MyApp>{

 int _value1 = 0;
 int _value2 = 0;

 void _setvalue1(int value) => setState(() => _value1 = value);
 void _setvalue2(int value) => setState(() => _value2 = value);

 Widget makeRadios() {
   List<Widget> list = new List<Widget>();

   for(int i=0; i<3; i++){
     list.add(new Radio(value: i, groupValue: _value1, onChanged: _setvalue1));
   }

   Column column = new Column(
     children: list,
   );

   return column;
 }

 Widget makeRadioTiles() {
   List<Widget> list = new List<Widget>();

   for(int i = 0; i < 3; i++){
     list.add(new RadioListTile(
       value: i,
       groupValue: _value2,
       onChanged: _setvalue2,
       activeColor: Colors.green,
       controlAffinity: ListTileControlAffinity.trailing,
       title: new Text('Item: ${i}'),
       subtitle: new Text('sub title'),

     ));
   }

   Column column = new Column(children: list,);
   return column;
 }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('Name here'),
      ),
      //hit Ctrl+space in intellij to know what are the options you can use in flutter widgets
      body: new Container(
        padding: new EdgeInsets.all(32.0),
        child: new Center(
          child: new Column(
            children: <Widget>[
              makeRadios(),
              makeRadioTiles()
            ],
          ),
        ),
      ),
    );
  }
}

```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kodestat.gitbook.io/flutter/23-flutter-radio-with-functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
