Unverified Commit f9ac22a4 authored by Jonas Uekötter's avatar Jonas Uekötter Committed by GitHub

Improve `PlatformException#stacktrace` docs for Android (#104331)

parent bb30bfdd
......@@ -145,6 +145,51 @@ class PlatformException implements Exception {
/// print(stacktrace);
/// }
/// ```
///
/// On Android this field is populated when a `RuntimeException` or a subclass of it is thrown in the method call handler,
/// as shown in the following example:
///
/// ```kotlin
/// import androidx.annotation.NonNull
/// import io.flutter.embedding.android.FlutterActivity
/// import io.flutter.embedding.engine.FlutterEngine
/// import io.flutter.plugin.common.MethodChannel
///
/// class MainActivity: FlutterActivity() {
/// private val CHANNEL = "channel_name"
///
/// override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
/// super.configureFlutterEngine(flutterEngine)
/// MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler {
/// call, result -> throw RuntimeException("Oh no")
/// }
/// }
/// }
/// ```
///
/// It is also populated on Android if the method channel result is not serializable.
/// If the result is not serializable, an exception gets thrown during the serialization process.
/// This can be seen in the following example:
///
/// ```kotlin
/// import androidx.annotation.NonNull
/// import io.flutter.embedding.android.FlutterActivity
/// import io.flutter.embedding.engine.FlutterEngine
/// import io.flutter.plugin.common.MethodChannel
///
/// class MainActivity: FlutterActivity() {
/// private val CHANNEL = "channel_name"
///
/// override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
/// super.configureFlutterEngine(flutterEngine)
/// MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler {
/// call, result -> result.success(Object())
/// }
/// }
/// }
/// ```
///
/// In the cases described above, the content of [stacktrace] will be the unprocessed output of calling `toString()` on the exception.
final String? stacktrace;
@override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment