'How to resolve expected declaration error in swift?

I am new to swift and am trying to build an app. I am receiving "Expected Declaration" error on Xcode when I type the following code.

        .edgesIgnoringSafeArea(.bottom)

Please guide me on how to resolve it. Thanks



Solution 1:[1]

A declaration is one of the things listed in https://docs.swift.org/swift-book/ReferenceManual/Declarations.html

If the compiler is saying it's expecting a declaration, it means you have written something that isn't a declaration in some place in the code where only a declaration is allowed.

In your case .edgesIgnoringSafeArea is a method on SwiftUI View type, so it would only be valid to put that right after a SwiftUI view, not on its own. It might be because you have brackets in the wrong place.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Shadowrun