Loading... # 前言 记录一下开发Flutter项目过程中遇到的问题,可以记录并且总结经验 ## 顶部莫名其妙出现的间隔(ListView、TabBarView等) 今天使用NestedScrollView+SliverAppBar+TabBarView的时候,在TabBarView的顶部一直和AppBar有一个间隔存在,找了半天也没发现是哪里的问题,甚至删掉了SliverAppBar间隔就不在了,经过一阵子对SliverAppBar的排查都找不到原因,想着会不会就是TabBarView导致的,谷歌了一下发现还真是。找到一个类似问题的。  [ListView和Appbar之间存在一个很大的间距](https://blog.csdn.net/wywinstonwy/article/details/122352534) ```dart MediaQuery.removePadding( removeTop: true, context: context, child: _buildTabBarView() ) ``` 使用MediaQuery.removePadding就可以去掉顶部的这个间距了,折腾了我几个小时,有时候排错找错方向了是真的不能死磕。。 ## 插件namespace报错 报错信息如下:`A problem occurred configuring project ':xxx'. > Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl. > Namespace not specified. Specify a namespace in the module's build file. See https://d.android.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace. If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to https://d.android.com/r/tools/upgrade-assistant/agp-upgrade-assistant for general information about using the AGP Upgrade Assistant.` 看到这个报错其实很容易解决,但不是长久之计,这个报错本质是因为gradle版本过高导致的,但是我降了半天版本死活还是报错。只好取巧了,将对应报错的依赖插件在 `build.gradle`中进行补充代码就可以了 找到你的插件缓存目录,并且找到对应的插件,找到  在android内 添加一个namespace 'xxxx'即可 <div class="tip inlineBlock warning"> xxxx可以去插件的清单文件中找到,复制粘贴上去即可 </div>  到此,重新运行main.dart发现运行成功~ Last modification:October 19, 2024 © Allow specification reprint Support Appreciate the author AliPayWeChat Like 2 如果觉得我的文章对你有用,请随意赞赏