flutter widget:Row

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了flutter widget:Row相关的知识,希望对你有一定的参考价值。

参考技术A row : 在水平方向上排列子widget的列表.

Row 是继承 Flex => MultiChildRenderObjectWidget => RenderObjectWidget => Widget .
所以 Row 具有动态布局的特点,可以让子控件展开以填充可水平的可用空间,用一个 Expanded 的控件包裹子控件。
Row 不支持滚动(通常认为一行的子控件超过可以容纳空间是错误的)。如果有一行控件控件比较多,希望可以滑动的时候,可以采用 ListView 。
同样,如果是垂直方向方面和 Row 对应的是 Column 。
小demo

这里需要注意的地方:
因为在 Row 里面有text,但是因为text的长度过长,一行肯定是放不下的,所以这里考虑用Expanded包裹一个Text,这样文字会自动换行,填充剩余部分。

效果图如下

修改下Row的 内容:

效果如下:可见多个Expanded 具有平分剩余空间的功能。和android 的weight 属性很相像。

Xcode 13 和 Flutter 2.5.1 - 致命错误:找不到“Flutter/Flutter.h”文件 #import <Flutter/Flutter.h>

【中文标题】Xcode 13 和 Flutter 2.5.1 - 致命错误:找不到“Flutter/Flutter.h”文件 #import <Flutter/Flutter.h>【英文标题】:Xcode 13 & Flutter 2.5.1 - fatal error: 'Flutter/Flutter.h' file not found #import <Flutter/Flutter.h> 【发布时间】:2021-09-29 15:37:26 【问题描述】:

我在升级到Xcode 13 后才开始遇到这个问题。几天前我将Flutter 升级为2.5.1

这就是我所看到的:

Failed to build iOS app
Error output from Xcode build:
↳
    --- xcodebuild: WARNING: Using the first of multiple matching destinations:
     platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device 
     platform:iOS Simulator, id:AA0EE6D2-4E24-48C6-B9D6-4F2598B68E4E, OS:15.0, name:iPad (9th generation) 
     platform:iOS Simulator, id:765C02E6-837E-4443-9073-722162C490DC, OS:15.0, name:iPad Air (4th generation) 
     platform:iOS Simulator, id:30429B61-93BC-4497-B556-3639373A10D0, OS:15.0, name:iPad Pro (9.7-inch) 
     platform:iOS Simulator, id:57217E13-F700-4673-9ABF-1866BAE1E435, OS:15.0, name:iPad Pro (11-inch) (3rd generation) 
     platform:iOS Simulator, id:A85DD0A6-EA0F-480C-9A6F-07966F4FE66B, OS:15.0, name:iPad Pro (12.9-inch) (5th generation) 
     platform:iOS Simulator, id:1D568B75-852B-42BE-8178-C39E6C515C41, OS:15.0, name:iPad mini (6th generation) 
     platform:iOS Simulator, id:347466A9-6BA4-4674-94B6-BCB3ACB11F00, OS:15.0, name:iPhone 8 
     platform:iOS Simulator, id:F74B444A-2838-4920-91DB-83893719250E, OS:15.0, name:iPhone 8 Plus 
     platform:iOS Simulator, id:2D4AF847-04A7-463C-A46C-D5D1E200CFDC, OS:15.0, name:iPhone 11 
     platform:iOS Simulator, id:BCD3D3BD-6485-4575-AA35-BF9ADEEBB4BD, OS:15.0, name:iPhone 11 Pro 
     platform:iOS Simulator, id:06DE013F-BF48-4857-B952-BFC2AA1BD304, OS:15.0, name:iPhone 11 Pro Max 
     platform:iOS Simulator, id:8A06D628-6132-4558-BB65-5598FFAC98DC, OS:15.0, name:iPhone 12 
     platform:iOS Simulator, id:885B1C8A-0497-4D95-8A87-447E40AB9238, OS:15.0, name:iPhone 12 Pro 
     platform:iOS Simulator, id:FF519331-8490-4219-92D0-ED9A08F11976, OS:15.0, name:iPhone 12 Pro Max 
     platform:iOS Simulator, id:51671583-ED36-4330-839B-401BA09B3996, OS:15.0, name:iPhone 12 mini 
     platform:iOS Simulator, id:950FC388-6567-40BD-AD31-6CC5A334AC97, OS:15.0, name:iPhone 13 
     platform:iOS Simulator, id:562728AB-E0CA-4675-BF75-787299ECE105, OS:15.0, name:iPhone 13 Pro 
     platform:iOS Simulator, id:CBB3D2FF-97DF-4328-8AD0-7350F83989D1, OS:15.0, name:iPhone 13 Pro Max 
     platform:iOS Simulator, id:D99FD6E3-C6DC-4F16-8092-83EA0216367F, OS:15.0, name:iPhone 13 mini 
     platform:iOS Simulator, id:2A06C9C4-9D8C-4C9B-9620-12265131A747, OS:15.0, name:iPhone SE (2nd generation) 
     platform:iOS Simulator, id:EA2B1A03-78F8-42B2-9818-41FE3F1E833A, OS:15.0, name:iPod touch (7th generation) 
     platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device 
    ** BUILD FAILED **
Xcode's output:
↳
    /Users/abc/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/wakelock-0.5.2/ios/Classes/messages.m:4:9: fatal error: 'Flutter/Flutter.h' file not found
    #import <Flutter/Flutter.h>
            ^~~~~~~~~~~~~~~~~~~
    1 error generated.
    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in parallel
Could not build the application for the simulator.

我尝试过重新安装 Flutter,删除并重新克隆我的项目,移除 pod,flutter clean + pod install,flutter 缓存修复,以及从项目中移除 Flutter 并重新添加。

每一个都会导致上述错误的一些变化。

我还必须更改我的Podfile --

post_install do |installer|
  installer.pods_project.targets.each do |target|
   target.build_configurations.each do |config|
    config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
   end
  end
 end

如果我将其还原,则会收到一组不同的错误,其中一些 pod 抱怨设置为 8.0,需要从 9.0 到 14.9.9。

我尝试更改 Runner 项目中的各个 pod,但这不起作用。以上清除了该错误,但现在我面临另一个错误。

请注意,Android 运行良好。这只是 iOS。

对这个有什么其他建议吗?

【问题讨论】:

【参考方案1】:

这对我有用:

在 Podfile 中: 替换

post_install do |installer|
  installer.pods_project.targets.each do |target|
   target.build_configurations.each do |config|
    config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
   end
  end
 end

post_install do |installer| 
  installer.pods_project.targets.each do |target| 
    flutter_additional_ios_build_settings(target) 
  end 
end

然后在 Xcode 和 Pods 中打开 iOS 文件,对于每个 Target,在 Build Settings 中,将部署目标设置为 11(也许 9 就足够了)

这是你已经尝试过的吗?

【讨论】:

【参考方案2】:

XCode 13 和 Flutter 2.5.3 有类似的问题:通过 xcodebuild 构建随机模块时出现错误(从 UI 构建可以正常工作)。在我尝试删除“有问题的”库之后 - 错误是针对下一个随机库,直到我卡在 Flutter.h 中。

我的问题是,在解决问题的过程中,我在 XCode 中将部署目标更改为 13,但却弄得一团糟:我在 PodfileProject->Runner->Info中更新了它>,Project->Runner->Build settings,但是忘记为 Targets->Runner->Build Settings 做。

一旦我更新了Targets->Runner->Build Settings,它也开始成功编译。

最终我在所有地方都回滚到了 Target 11.0,它仍然可以编译。

【讨论】:

以上是关于flutter widget:Row的主要内容,如果未能解决你的问题,请参考以下文章

[Flutter] flutter项目一直卡在 Running Gradle task 'assembleDebug'...

flutter 日志输出,Flutter打印日志,flutter log,flutter 真机日志

Flutter开发 Flutter 包和插件 ( Flutter 包和插件简介 | 创建 Flutter 插件 | 创建 Dart 包 )

flutter与原生混编(iOS)

Flutter-布局

如何解决flutter gradle build error?C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991