0

I would like the program to transition a large screen and then also transition the screen with further list selections. How can I remedy this error?

class _MyStatefulWidgetState extends State<MyStatefulWidget> {
  int _selectedIndex = 0;
  static final List<Widget> _widgetOptions = <Widget>[
    Text(
      'Index 0: Home',
    ),
    Text(
      'Play画面',
    ),
    Text(
      'Make画面',
    ),
    ListView(
      children: <Widget>[

        ListTile(
          leading: Icon(Icons.key),
          title: Text('設定1'),
          onTap: () {
            Navigator.push(context,MaterialPageRoute(
                builder: (context) => SetsFirst()));
          },
        ),
        Divider(),
        ListTile(
          leading: Icon(Icons.key),
          title: Text('設定2'),
          onTap: () {
            Navigator.push(context,MaterialPageRoute(
                builder: (context) => SetsSecond()));
          },
        ),
        Divider(),
      ],
    )
  ];

1 Answers1

0

By preferring classes over functions.

The issue is the BuildContext you're using for navigation.

jamieastley
  • 560
  • 2
  • 8
  • How do I change the code to eliminate the error? – Kabocha Aug 05 '22 at 10:34
  • By doing as suggested and reading the detailed response which was linked: preferring classes over functions. The issue is the `BuildContext` which is being passed to your static function. – jamieastley Aug 08 '22 at 02:16