ListView-> Column小部件树在页面上颤振的垂直对齐列

时间:2020-07-16 03:43:46

标签: flutter flutter-layout flutter-listview

我的Flutter外观如​​下。首次加载页面时显示的是CircularProgressIndicator。

它与页面顶部对齐。但是,如何在页面上将CircularProgressIndicator垂直居中?

function mutatedLoop3() {
  myArray = []
  td = []
  for (i = 0; i <= 1; i++) {
    console.log('previous td', JSON.stringify(td))
    for (j = 0; j <= 2; j++) {
      td[j] = 9
    }
    console.log('mutated td', JSON.stringify(td))
    if (i == 0) td = [1, 2, 3] // you reassign to a new array, means new reference
    else if (i == 1) td = [4, 5, 6]
    myArray.push(td)
    console.log(JSON.stringify(td), JSON.stringify(myArray))
    console.log('---')
  }
  console.log(myArray[0]) // Returns 9,9,9 when I expect 1,2,3
}

function fixedLoop3() {
  myArray = []
  for (i = 0; i <= 1; i++) {
    td = [] // now it is reset every iteration
    for (j = 0; j <= 2; j++) {
      td[j] = 9
    }
    if (i == 0) td = [1, 2, 3]
    else if (i == 1) td = [4, 5, 6]
    myArray.push(td)
    console.log(JSON.stringify(td), JSON.stringify(myArray))
    console.log('---')
  }
  console.log(myArray[0]) // Returns 9,9,9 when I expect 1,2,3
}

mutatedLoop3()
fixedLoop3()

1 个答案:

答案 0 :(得分:1)

您不需要使用... from app_workflow.forms import PhotoForm, NewContactForm class NewContactView(View): def get(self, request): ... def post(self, request): form = NewContactForm(self.request.POST, self.request.FILES) if form.is_valid(): data = {'is_valid': True, 'name': photo.file.name, 'url': photo.file.url} else: data = {'is_valid': False} return JsonResponse(data) class DragAndDropUploadView(View): def get(self, request): ... def post(self, request): form = PhotoForm(self.request.POST, self.request.FILES) if form.is_valid(): data = {'is_valid': True, 'name': photo.file.name, 'url': photo.file.url} else: data = {'is_valid': False} return JsonResponse(data) 小部件来包装CircularProgressIndicator,只需使用Column小部件来包装即可。

检查以下示例代码:

Center