title: SwiftUI -> Thread 1: Fatal error: No observable object of type MyObject.Type found (EnvironmentObject in sheet)
body: <p>I'm building an app with SwiftUI. When I was trying to display a sheet (previously Modal), this error message appears:</p>
  <blockquote>
  <p>Thread 1: Fatal error: No observable object of type BixiStationCombinedListViewModel.Type found.</p>
  <p>A View.environmentObject(_:) for BixiStationCombinedListViewModel.Type may be missing as an ancestor of this view.</p>
  </blockquote>
  <p>This error occurs when I'm using a <code>@State</code> variable to display a modal that includes a <code>Map View</code> using MapKit.</p>
  <p>I don't see why and how I should implement a new <code>Environment Object</code>.</p>
  <p>Is it because the <code>Station</code> I select when tapping on the <code>CardView</code>  should be stored globally and the info should be passed to the dedicated <code>View</code>?</p>
  <p>The <code>View</code> handling the <code>@State</code>:</p>
  <pre><code>struct CardView: View {
      
      @EnvironmentObject var bixiModel: BixiStationCombinedListViewModel
      @State private var isModalOpen: Bool = false
          
      var station: BixiStationCombinedViewModel
          
      var body: some View {
          
          ZStack(alignment: .leading) {
              
                  Card()
                  
                  StationTextInfo(station: station)
  
          } .onTapGesture {
              self.isModalOpen = true
              print(self.isModalOpen)
          }
          .sheet(isPresented: self.$isModalOpen) {
              BixiStationDetailView(station: self.station)
          }
  
      }
  }
  </code></pre>
  <p>The <code>View</code> I'm trying to show within the sheet:</p>
  <pre><code>struct BixiStationDetailView: View {
      
      @EnvironmentObject var bixiModel: BixiStationCombinedListViewModel
          
      var station: BixiStationCombinedViewModel
      
      var body: some View {
          VStack {
              MapView(coordinate: station.coordinate, name: station.name)        
          }
      }
  }
  </code></pre>
  <p>Finally the Object:</p>
  <pre><code>class BixiStationCombinedListViewModel: ObservableObject {
      
      init() {
          fetchDataFromApi()
      }
      
      @Published var stationsCombinedList = [BixiStationCombinedViewModel]()
      
      var stationsInformationList = [BixiStationInformationViewModel]()
      var stationsDataList = [BixiStationDataViewModel]()
          
      func fetchDataFromApi() {
  
          }        
      }
  }
  </code></pre>
  <p>How can I get rid of the error message and display the proper <code>View</code>?</p>