如何从 init 函数或解决方法访问提供者模型中的值?
基本上,当我的应用程序加载时,我会在提供者模型中保存一些值。
一个值是搜索变量。然后我被重定向到一个加载页面,在那里我需要这个值来获取数据并呈现一个列表。
我正在 init 方法中检索数据。
-- 我的主要功能
void main() {
runApp(
Provider<UserModel>(
builder: (_) => UserModel(),
child: Jobs(),
),
); //added
}
Run Code Online (Sandbox Code Playgroud)
这是我的工作页面的片段
case '/main':
return MaterialPageRoute(
builder: (_) => JobsHomePage(title: "jobs"));
break;
Run Code Online (Sandbox Code Playgroud)
这是显示此列表的列表页面 --- JobsHomePage()
void initState() {
searchVal = Provider.of<UserModel>(context).searchVal;
jb =load(searchVal);
}
Run Code Online (Sandbox Code Playgroud)
然后我有一个构建器方法,它通过“jb”进行迭代并打印值
我得到的错误是继承错误
flutter:当继承的widget发生变化时,比如Theme.of()的值发生变化,就是依赖
感谢您的帮助...我没有发布整个代码,因为它很长,而且堆栈中出现了一些“所有代码”错误。
我正在使用 nextjs/reactjs 并需要一些有关如何重定向到页面的帮助
文件夹结构
-Pages
-business
-location.js
-selectlocation.js
Run Code Online (Sandbox Code Playgroud)
URL = http://myhost/business/ location ?city=Pensacola&state=FL
当参数丢失时,我想重定向到selectlocation
当参数为空时,如何从位置页面路由到选择位置页面
这是我的location.js代码片段
export default class extends Component {
static getInitialProps({ query: { city, state } }) {
return { city: city, state: state };
}
render() {
return (
<div>
<Head>
<title>{title}</title>
<meta name="description" content={description} />
</Head>
<LayoutWithHeader
banner={false}
view="business"
link="location banner"
locationCity={this.props.city}
locationState={this.props.state}>
<Location />
</LayoutWithHeader>
</div>
);
}
}
Run Code Online (Sandbox Code Playgroud)
SelectLocation.JS 的代码
export default () => (
<div>
<Head>
<title>Location</title>
</Head>
<LayoutWithHeader banner={true} …Run Code Online (Sandbox Code Playgroud) 我在更改 Flutter 中过滤器芯片中的图标时遇到一些问题。我想在显示小部件时添加一个“+”。然后,如果用户选择该芯片,则将图标更改为复选标记。
从第一张图可以看到,图标变成了“对勾”,但是下面有一个白色的对勾。
如何删除这个额外的复选标记?
代码片段
FilterChip(
avatar: selected.contains(ms.items[i].text)
? Icon(Icons.check, color: Palette.BLUE)
: Icon(Icons.add, color: Palette.GREY),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0),
side: BorderSide(
color: Palette.BLUE,
),
),
backgroundColor: Palette.WHITE,
padding: const EdgeInsets.all(8.0),
label: Text(
ms.items[i].text,
style: TextStyle(
fontSize: 16.0,
height: 1.4,
fontWeight: FontWeight.normal,
color: Palette.GREY,
),
),
Run Code Online (Sandbox Code Playgroud)
当前显示
所需显示
初始显示
我有一个问题,我需要使用标签导航。目前的材料脚手架只有1叠。因此,如果我需要深入几个级别(子页面),那么我将丢失选项卡上下文。Cupertino 脚手架允许我深入几个层次,但仍然保持根标签。
如果我换成库比蒂诺脚手架。我需要写两套代码吗?适用于 iOS 的 Cupertino 和适用于 android 的 Material 还是转换为颤振本机代码?。
谢谢
我通过 docker 在我的 mac 上安装 sonar-scanner
(https://hub.docker.com/r/sonarsource/sonar-scanner-cli)并且我收到错误“您必须为‘未知’定义以下强制属性:sonar.projectKey”。
我做了以下事情:
1:在JS项目根目录添加sonar-scanner.properties文件
# Required metadata
sonar.projectKey=my-app
sonar.projectName=Franchise
sonar.projectVersion=1.0
# Comma-separated paths to directories with sources (required)
sonar.sources=server/app.js,pages,components
Run Code Online (Sandbox Code Playgroud)
2 安装docker和扫描仪
这是我的 docker 命令
docker run --rm -e SONAR_HOST_URL="https://sonarqube.comp.com/" -e SONAR.PROJECTKEY="my-app" -v "/git/franchises" sonarsource/sonar-scanner-cli
请让我知道如何正确传递信息。
谢谢
需要一些帮助才能获取文件内容。
我使用颤振文件选择器插件来获取文件。插件返回路径。
'/Users//Library/Developer/CoreSimulator/Devices/A509517C-AC3F-4F87-856A-145F61075E8B/data/Containers/Data/Application/FC2B634B-F7BD-48EB-9B80-920476E20DEX .doc'
当我尝试在 Dart 中阅读内容时,出现错误
颤振:FileSystemException:无法使用编码“utf-8”解码数据
这是我的代码
Future<int> readFileStream(String path) async {
print(path);
File file = await new File(path);
file.length().then((len) {
print(len);
});
try {
// Read the file
String contents = await file.readAsString();
return int.parse(contents);
} catch (e) {
print(e);
// If encountering an error, return 0
return 0;
}
}
Run Code Online (Sandbox Code Playgroud)
我如何阅读内容?
谢谢你的帮助
我的颤振应用程序中有一个底部导航栏。如何将图标与中间对齐。目前,它似乎是顶部对齐
Widget _bottomNavigationBar(int selectedIndex) {
return BottomNavigationBar(
backgroundColor: Palette.YELLOW,
onTap: (int index) {
setState(() {
userModel.selectedIndex = index;
});
},
currentIndex: userModel.selectedIndex,
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Image.asset(
"assets/images/search_nav_icon.png",
),
title: Text(''),
),
BottomNavigationBarItem(
icon: Image.asset(
"assets/images/fav_nav_icon.png",
),
],
);
}
Run Code Online (Sandbox Code Playgroud)
我想在我的应用程序中使用 flutter-web 插件。但是,当我将其添加到 YAML 文件时,我收到以下 SDK 错误。我刚刚升级到1.20.4
\n我该如何修复这个错误?
\n当前的 Flutter SDK 版本是 1.20.4。
\n由于应用程序依赖于 webview_flutter >=1.0.0,需要 Flutter SDK 版本 >=1.22.0 <2.0.0,版本解析失败。\npub 失败 (1; 因为应用程序依赖于 webview_flutter >=1.0.0,需要 Flutter SDK version >=1.22.0 <2.0.0,版本解析失败。)
\nDoctor 摘要(要查看所有详细信息,请运行 flutter doctor -v):\n[\xe2\x9c\x93] Flutter(频道稳定,1.20.4,在 Mac OS X 10.15.6 19G2021 上,区域设置 en-US)
\n[\xe2\x9c\x93] Android 工具链 - 为 Android 设备开发(Android SDK 版本 28.0.3)\n[\xe2\x9c\x93] Xcode - 为 iOS 和 macOS 开发 (Xcode 12.0)\n[\xe2\ x9c\x93] Android Studio(版本 3.6)\n[\xe2\x9c\x93] VS Code(版本 1.49.2)\n[\xe2\x9c\x93] 连接的设备(1 个可用)
\n\xe2\x80\xa2 未发现问题! …
如何从 Flutter/Dart 中的字符串中删除不可打印的字符。
\nvar c ="Maintain central project files (hard copy and electronic) for administration.\xc3\xa2\xc2\xa2Perform a wide variety of administrative duties"\nRun Code Online (Sandbox Code Playgroud)\n感谢您的帮助
\n