Questions tagged [viewbuilder]

54 questions
0
votes
1 answer

Set a @State var inside an If statement in Swift

I am trying to set the value of a @State var in an If statement that is inside of a struct of type :View, like so: struct Name: View { @State someVar: Int = 0 var body: some View { VStack { if this > that { someVar =…
0
votes
1 answer

PageView.Builder in Flutter The getter 'length' was called on null. Receiver: null Tried calling: length

when use response from API then show error The getter 'length' was called on null. Receiver: null Tried calling: length here is my API code var url = "https://domain.php"; var res; var splashs; void initState() { super.initState(); …
Yasir Mehmood
  • 296
  • 2
  • 11
0
votes
0 answers

ContentView file in SwiftUI too complex for the compiler?

Ever since SwiftUI 2 released, the compiler and debugger have just become awful. Whenever I add another view (that is a custom struct or even just a VStack containing a Text() element) to the ZStack in 'viewThatCanContainOtherViews()', the code…
nickcoding
  • 305
  • 8
  • 35
0
votes
0 answers

SwiftUI @ViewBuilder issue in Xcode 12 fails to compile project in View extension

Hi I am facing an issue in project/build compilation in Xcode 12 Beta 1-6 (SwiftUI 2.0), In scenario, Having Custom modifier in View extension. extension View { public func alert(isPresented: Binding, @ViewBuilder _ alert: () ->…
Nasir
  • 1,617
  • 2
  • 19
  • 34
0
votes
1 answer

(SwiftUI) How can I access the match I have found from one array in another in ViewBuilder?

I have two arrays. maschineItems: [MaschineItem] maschines: [Maschine] Both objects have the property "name" In my View I want to check whether the name of a maschineItem exists in the array of the machines. I want to make a 'light Bubble' for all…
0
votes
1 answer

SwiftUI: How do I return to same index with a Picker using SegmentedPickerStyle()

This is just me wrapping my head around ViewBuilders and the new SwiftUI paradigm. I have a "menu" at the top of my screen along with a couple of buttons. If I do a search (tap the magnifying glass), when I return the index always returns to 0 and…
Mozahler
  • 4,958
  • 6
  • 36
  • 56
-1
votes
1 answer

Custom Scrollview in SwiftUI

I have a piece of code that looks like this in my ContentView and I'd like to not repeat the ScrollView's modifiers unnecessarily. if variable == false { ScrollView { // Code here } .navigationBarTitleDisplayMode(.inline) …
Alexnnd
  • 429
  • 4
  • 13
-1
votes
1 answer

can I set a variable to @ViewBuilder?

Can onebody help me with the following please: I would like to be able to set a variable in a class conforming to "ObservableObject" to different Views in order to be able to pass that variable as "content" to custom view with @ViewBuilder Here is…
matyasl
  • 295
  • 2
  • 11
-1
votes
1 answer

SwiftUI: Waiting for variable to be true

Here's my code struct Home: View { @State var status = UserDefaults.standard.value(forKey: "status") as? Bool ?? false var userEmail = Auth.auth().currentUser?.email @State private var hasTimeElapsed = false var body: some View { if…
Canyon
  • 45
  • 6
1 2 3
4