skip to Main Content

i have radio list in flutter on different sheet i called the function of radio list on my home screen and i want if i click on the radio list it will navigate to my edit screen i had used inkwell function but it is still not working what should i do now

import 'package:flutter/material.dart';
import 'package:flutter_application_1/Edit_Screen.dart';

class RadioListExample extends StatefulWidget {
  @override
  _RadioListExampleState createState() => _RadioListExampleState();
}

class _RadioListExampleState extends State<RadioListExample> {
  int _selectedValue = 0;

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () {
        Navigator.push(
          context,
          MaterialPageRoute(builder: (context) => const EditScreen()),
        );
      },
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          RadioListTile(
            title: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  'Heading',
                  style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
                ),
                Text(
                  'This is my subheading for test',
                  style: TextStyle(fontSize: 14),
                ),
                Container(
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(6),
                    border: Border.all(width: 1.0),
                  ),
                  padding: const EdgeInsets.all(6.0),
                  child: Text(
                    'Today 06:00 PM',
                    style: TextStyle(color: Colors.blue),
                  ),
                ),
              ],
            ),
            value: 1,
            groupValue: _selectedValue,
            onChanged: (value) {
              setState(() {
                _selectedValue = value as int;
              });
            },
            secondary: Icon(
              Icons.star,
              color: Colors.blue,
            ),
          ),
        ],
      ),
    );
  }
}

I had tried inkwell function on tap but it is not working

2

Answers


  1. It’s happening cause the RadioListTile widget also tap-able, it generally calls the onChanged function of it’s click.
    You need to think of some other way to navigate.

    Login or Signup to reply.
  2. You need to add toggleable to true in RadioListTile and add an event in onChange.

    RadioListTile(
      value: controller.listItem[index],
      groupValue: controller.selectedFolder.value,
      toggleable: true, // Enable toggleable
      onChanged: (newValue) {
        // Your function here
      },
      title: Text(controller.listItem[index],),
    )
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search