I want to pass two String variables to another class in flutter and used it. I tried but failed.
I tried this way but it said; Instance member can't be accessed using static. I want to know the right way to do it.
In MyHome class; I passed litemspage0[index] and litemsname0[index] to VideoPlayer0 class
_getPage(int page) {
switch (page) {
case 0:
return ListView.builder(
itemBuilder: (context, index) {
return new Padding(
padding:
new EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),
child: new Card(
elevation: 2.0,
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(16.0)),
child: InkWell(
onTap: () {
Navigator.of(context).push(
new MaterialPageRoute(
builder: (context) {
return new VideoPlayer0(litemspage0[index],litemsname0[index]);
},
),
);
I want to use litemspage0[index],litemsname0[index] in VideoPlayer0 class. Here is the code I tried,
class VideoPlayer0 extends StatefulWidget {
final String litemspage0;
final String litemsname0;
VideoPlayer0(this.litemspage0, this.litemsname0);
@override
_MyHomePageState0 createState() => _MyHomePageState0();
}
class _MyHomePageState0 extends State<VideoPlayer0> {
static const platform = const MethodChannel("www.youtube.com");
TextEditingController _idController = TextEditingController();
TextEditingController _seekToController = TextEditingController();
double _volume = 1.0;
VideoPlayerController _videoController;
String position = "Get Current Position";
String status = "Get Player Status";
String videoDuration = "Get Video Duration";
String _source = VideoPlayer0.litemspage0;
bool isMute = false;
But I'm getting this error.
String _source = VideoPlayer0.litemspage0;
Instance member 'litemspage0' can't be accessed using static access.
I want to know the proper way to pass variables in one class to another in flutter.
widgetlikewidget.litemsname0Only static members can be accessed in initializers.String _source = widget.litemspage0;widget