Invalid constant value.dart(invalid_constant)
787
Just remove const value in front of TextField
TextField(
controller: urlController,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Paste URL',
),
)
Author by
Sasitha Dilshan
I am a mobile application developer. interested in flutter development and iOS (swift).
Updated on November 27, 2022Comments
-
Sasitha Dilshan 6 daysin the bellow code I got the error on " controller: urlController," this line
var url; final urlController = TextEditingController(); @override void dispose() { urlController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: const Color(0xff16352A), title: const Text( 'Downloader', style: TextStyle(color: Color(0xffEDAB24)), ), ), body: Container( padding: const EdgeInsets.all(20.0), child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ const SizedBox(height: 50.0), const TextField( controller: urlController, decoration: InputDecoration( border: OutlineInputBorder(), labelText: 'Paste URL', ), ), const SizedBox(height: 20.0), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ TextButton( onPressed: () {}, child: const Text( 'Download', style: TextStyle(fontSize: 30.0), ), style: TextButton.styleFrom( primary: Colors.white, backgroundColor: const Color(0xff284635), ), ), const SizedBox(width: 20.0), TextButton( onPressed: () { setState(() { url = urlController.text; }); }, child: const Text( 'Clear', style: TextStyle(fontSize: 30.0), ), style: TextButton.styleFrom( primary: Colors.white, backgroundColor: const Color(0xff284635), ), ), ], ) ], ), ), ); } }-
Sasitha Dilshan about 1 yearin the above code I got the error on " controller: urlController," this line
-