From the above article, I found that if you execute dart with a character string as an argument, it will be passed by value.
Is it possible to pass the above result by reference and make B (). B 6?

class B {
  var b= 3;
  void bMethod (int b_arg) {
    b_arg= 6;
void main () {
  B (). bMethod (B (). B);
  print (B (). b); //3

It may not meet your needs, but may these articles be helpful? Is there a way to pass a primitive parameter by reference in Dart ?, Flutter function parameter pass by reference

kunif2021-12-21 17:04:59

This question may be in the XY problem. In other words, even though there is a different purpose that you really want to do, it may be difficult to collect answers that are more in line with the purpose because you are asking questions after deciding on a solution. .. Specifically, I think that this question may be simpler if you don't use classes in the first place (reference). It seems that the questioner's question has already been resolved, so no additional action is required, but if you ask the next question, please write down the circumstances that led to the question, and you may be able to post a more helpful answer. Not.

nekketsuuu2021-12-21 17:04:59