Hide And Show Radio Button
Complete Code For Hide And Show Radio Button In Flutter
main.dart
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; void main(){ runApp(MyApp()); } class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp ]); return MaterialApp( debugShowCheckedModeBanner: false, title: 'Animation Playground', theme: ThemeData( primarySwatch: Colors.blue, ), home: ShowHideRadio(), ); } } class ShowHideRadio extends StatefulWidget { @override _ShowHideRadioState createState() => _ShowHideRadioState(); } class _ShowHideRadioState extends State<ShowHideRadio> { bool _isRadioChecked = true; int _currValue = 1; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.cyan, title: Text("Hide & Show Radio Button"), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: <Widget>[ _isRadioChecked ? RadioListTile( activeColor: Colors.cyan, groupValue: _currValue, value: 1, onChanged: (val) => setState(() => _currValue = val), title: Text("Radio Button Text"), ) : SizedBox(), SizedBox(height: 30.0), RaisedButton( color: Colors.cyan, child: Text(_isRadioChecked ? "Hide" : "Show",style: TextStyle(color: Colors.white),), onPressed: () { setState(() => _isRadioChecked = !_isRadioChecked); }, ), ], ), ), ); } }