This is my code :
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class viewLossEvent extends StatefulWidget {
String code,
viewLossEvent(
{this.code});
@override
State<viewLossEvent> createState() => _viewLossEventState();
}
class _viewLossEventState extends State<viewLossEvent> {
int _selectedIndex = 0;
void _navigateBottomBar(int index){
setState(() {
_selectedIndex = index;
});
}
final List<Widget> _pages = [
Container(
child: Text(
'${widget.code}'
),
),
];
the error that I am getting :
"The instance member 'widget' can't be accessed in an initializer."
I am getting the error right here :
can anyone help solve this and kindly explain why this is happening.
Thank You!