Home > Net >  flutter data passing issue between screens components without using global variables
flutter data passing issue between screens components without using global variables

Time:11-23

I am creating Screen components Separate to use such components like card, textfields so we can easily use it on web. I am getting issue of passing data between components, Dont use the method of golbal varibales if i am sending data to components it only show componets but I want to send data to component but Navigate to main screen.

I am trying this method without creating Global variable file.

CodePudding user response:

you can use one of this ways:

1- Send your variables by constructor

class YourPgae extends StatefulWidget {
final int wabtedvar;
const YourPgae({super.key, required this.wabtedvar});

@override
State<YourPgae> createState() => _YourPgaeState();
}

2- Or, you can use state management library such as provider, flutter_bloc or get to send variables globally without using global variable

CodePudding user response:

try this:

Card(value : 1);

class CardWidget extends StatelessWidget {

CardWidget(this.value);enter code here int ? value ; }

  • Related