Skip to content

Commit

Permalink
returning error if style is missing or invalid args
Browse files Browse the repository at this point in the history
  • Loading branch information
itheamc committed Jun 24, 2024
1 parent 67f257f commit 925ba67
Showing 1 changed file with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -931,10 +931,30 @@ class MapLibreMapController: NSObject, FlutterPlatformView, MLNMapViewDelegate,
result(reply)

case "style#setStyle":
guard let arguments = methodCall.arguments as? [String: Any] else { return }
guard let style = arguments["style"] as? String else { return }
setStyleString(styleString: style)
result(nil)
if let arguments = methodCall.arguments as? [String: Any] {
if let style = arguments["style"] as? String {
setStyleString(styleString: style)
result(nil)
} else {
// Error for missing style key in argument
result(
FlutterError(
code: "invalidStyleString",
message: "Missing style key in arguments",
details: nil
)
)
}
} else {
// Error for invalid arguments type
result(
FlutterError(
code: "invalidArgumentsType",
message: "Arguments not of type [String: Any]",
details: nil
)
)
}
default:
result(FlutterMethodNotImplemented)
}
Expand Down

0 comments on commit 925ba67

Please sign in to comment.