Improve PlatformException#stacktrace
docs for Android (#104331)
This commit is contained in:
parent
bb30bfddec
commit
f9ac22a426
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user