title: How can I retain the data type in result.success() method in onMethodCall in Flutter Java?
body: <p>I am trying to return a <code>List&lt;List&lt;String&gt;&gt;</code> back to my Flutter code from my <code>MainActivity.java</code>.</p>
  <p>I created a</p>
  <pre><code>new MethodChannel(Objects.requireNonNull(getFlutterEngine()).getDartExecutor(), CHANNEL).setMethodCallHandler(new MethodChannel.MethodCallHandler() {
              
      @Override
      public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
          if (call.method.equals(&quot;getOTD&quot;)) {
              result.success(listOfList);
          }  
      }                
  }
  </code></pre>
  <p>to return the listOfList variable. However, whenever it always coverts the <code>List&lt;List&lt;String&gt;&gt;</code> to <code>&lt;Object&gt;</code> while returning the &quot;success&quot; value. How can I make the method return the value without changing the data type? If that is not possible, how can I convert the Object back to <code>List&lt;List&lt;String&gt;&gt;</code> in the dart part?</p>
  <p>Here is my dart side of the code snippet:</p>
  <pre><code>  void getOTD() async {
      try {
        otdList = await platform.invokeMethod(&quot;getOTD&quot;);
        otdList = otdList.cast&lt;List&lt;List&lt;String&gt;&gt;&gt;();
        print(otdList);
      } catch (e) {
        print(e);
      }
    }
  </code></pre>
  <p>I tried casting the variable, but it did not work. I want to perform many operations on that variable later, so I need the <code>List&lt;List&lt;&gt;String&gt;</code> format. I have declared otdList in my dart code as follows since I was receiving an Object:</p>
  <pre><code>List&lt;Object?&gt; otdList = [];
  </code></pre>