title: how to change an image when I click a toggle button(flutter)
body: <p><a href="https://i.stack.imgur.com/crCkh.jpg" rel="nofollow noreferrer">enter image description here</a></p>
  <p>I cannot embed image because I don't have 10 reputation.
  I want to load image when I click toggle buttons. it seems simple for you but it is hard for me to do it. I am a beginner .
  I don't know how to write onPressed button. I already wrote onPressed buttons for toggle button. it seems like it is not possible to write one more oppressed code. I already used the onpressedbutton code to use ToggleButton, but I need one more function to load image but I don't know how to do it</p>
  <p><code>enter code here</code></p>
  <pre><code>import 'package:flutter/material.dart';
  import '123.dart';
  import '456.dart';
  
  void main() {
    runApp(MyApp());
  }
  
  class MyApp extends StatefulWidget {
    @override
    _MyAppState createState() =&gt; _MyAppState();
  }
  
  class _MyAppState extends State&lt;MyApp&gt; {
  
  
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        home: Scaffold(
          appBar: AppBar(title: Text('imageToggle'),),
          body: Column(
            children: [
              Expanded(child: Image.asset('images/meow.jpg')),
              Button123(
              ),
              Button456(),
  
            ],
          ),
        ),
      );
    }
  }
  </code></pre>
  <pre><code>
  class Button456 extends StatefulWidget {
    @override
    _Button456State createState() =&gt; _Button456State();
  }
  
  class _Button456State extends State&lt;Button456&gt; {
    List&lt;bool&gt; isSelected = List.generate(3, (index) =&gt; false);
    @override
    Widget build(BuildContext context) {
      return Container(
          child: ToggleButtons(
            isSelected: isSelected,
            color: Colors.black,
            fillColor: Colors.grey,
            children: [
              Padding(padding: const EdgeInsets.symmetric(horizontal: 12),
                child: Text('cat1'),),
              Padding(padding: const EdgeInsets.symmetric(horizontal: 12),
                child: Text('cat2'),),
              Padding(padding: const EdgeInsets.symmetric(horizontal: 12),
                child: Text('cat3'),),
  
  
            ],
            onPressed: (int newIndexx) {
              setState(() {
                for (int index = 0; index &lt; isSelected.length; index++) {
                  if (index == newIndexx) {
                    isSelected[index] = true;
                  } else {
                    isSelected[index] = false;
                  }
                }
              });
            },
          )
      );
    }
  }
  </code></pre>