Issue
class Notice extends StatefulWidget {
final String s_id;
const Notice({Key key, this.s_id}) : super(key: key);
@override
_NoticeState createState() => _NoticeState();
}
class _NoticeState extends State<Notice> {
TextEditingController _titleController = new TextEditingController();
var api =
Uri.parse('https://www.a2rstore.in/api/school/v1/noticeApi.php?id=${widget.s_id}');
Solution
You can’t call the "widget" without the context.
The proper way to do it is by first defining your variable:
class _NoticeState extends State<Notice> {
TextEditingController _titleController = new TextEditingController();
var api;
...
}
And then assigning to it the value either in the build or initState method:
@override
initState(){
api = Uri.parse('https://www.a2rstore.in/api/school/v1/noticeApi.php?id=${widget.s_id}');
}
Answered By – Gabriel Costache
Answer Checked By – Willingham (FlutterFixes Volunteer)