我在我的网站上实现了第三方小部件以获得丰富的摘要星星。问题是 Google-bot 和 Google 结构化数据测试工具无法识别 ld+json 标记,因为它位于html标记之外。我已经使用 React Helmet 将脚本强制放在head标签内,但徒劳无功!
这是我的应用程序的代码:
return (
<div className="cleanslate widget-box">
{comp}
<Helmet>
<script type="application/ld+json">
{`
{
"@context": "https://schema.org/",
"@type": "CreativeWorkSeries",
"name": "${this.state.name}",
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "${this.state.rating}",
"bestRating": "10",
"ratingCount": "${this.state.voters}"
}
}
`}
</script>
</Helmet>
</div>
)
Run Code Online (Sandbox Code Playgroud) 我想设计一个自定义圆角 TextInputLayout 正如我展示的活动 TextInputLayout 的示例图像
以下
我的 xml 代码是
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/mobile_number"
android:inputType="number"
android:fontFamily="@font/montserrat_regular"
android:maxLength="10" />
</com.google.android.material.textfield.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
android widget android-textinputlayout material-components material-components-android
我已经用 ConfigurationActivity 构建了一个小部件。一切都很好,但问题是我无法在创建后重新配置它并更改其设置。其他小部件(如天气应用程序或日历应用程序)在您长按它们时会提供一个选项(与“从家里删除”和“应用程序信息”一起),即打开其 ConfigurationActivity 的“小部件设置”。我怎样才能添加这个选项?在下面的屏幕截图中,我的应用程序中缺少“小部件设置”选项。
我试图制作一个使用交易视图小部件的角度项目。问题是,当我在 中使用这些小部件时,它们工作正常index.html,但我想将它们用作网站的组件。我尝试包含该小部件,app.component.html但小部件代码在那里不起作用。我是 Angular 的新手,不知道应该在app.component.ts. 有人可以帮我吗?这是代码index.html:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>News</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
</head>
<body>
<app-root></app-root>
<div class="container">
<h1>Forex Rates</h1>
<!-- TradingView Widget BEGIN -->
<div class="tradingview-widget-container">
<div class="tradingview-widget-container__widget"></div>
<!-- <div class="tradingview-widget-copyright"><a href="https://in.tradingview.com/markets/currencies/forex-cross-rates/" rel="noopener" target="_blank"><span class="blue-text">Forex Rates</span></a> by TradingView</div> -->
<script type="text/javascript" src="https://s3.tradingview.com/external-embedding/embed-widget-forex-cross-rates.js" async>
{
"width": 840,
"height": 400,
"currencies": [
"EUR",
"USD",
"JPY",
"GBP",
"CHF",
"AUD", …Run Code Online (Sandbox Code Playgroud) 我想在 flutter 中制作 to do 应用程序,为了使用 focusNode 我编写了这段代码 ->
FocusNode _titleFocus;
FocusNode _descriptionFocus;
FocusNode _todoFocus;
@override
void initState() {
// TODO: implement initState
super.initState();
if(widget.task!=null){
_titleFocus = FocusNode();
_descriptionFocus = FocusNode();
_todoFocus = FocusNode();
}
}
@override
void dispose() {
// TODO: implement dispose
_titleFocus.dispose();
_descriptionFocus.dispose();
_todoFocus.dispose();
super.dispose();
}
Run Code Online (Sandbox Code Playgroud)
我首先在代码下方启动 FocusNode,该 focusNode 在退出待办任务对象时可以正常工作,但是当我想创建新的任务对象并将焦点传递给另一个对象时,它不起作用。我使用这段代码来传递焦点......
focusNode: _titleFocus,
_descriptionFocus.requestFocus();
Run Code Online (Sandbox Code Playgroud)
但它出错并显示消息 ->
The following NoSuchMethodError was thrown while finalizing the widget tree:
The method 'dispose' was called on null.
Receiver: null
Tried calling: dispose()
Run Code Online (Sandbox Code Playgroud) 我尝试编写生成数组随机值并显示在小部件卡上的代码(每次打开时都会显示 array{string} 中的另一个值)。实际上,代码从数组中选择一个单元格一次,每次我打开小部件它显示了与第一个选择的相同的小部件(没有更改)我使用 slimycard 包(https://pub.dev/packages/slimy_card)
// in 'homepage' class widget build
child: StreamBuilder(
initialData: false,
stream: slimyCard.stream,
builder: ((BuildContext context, AsyncSnapshot snapshot) {
return ListView(
padding: EdgeInsets.only(top: 150),
children: <Widget>[
// SlimyCard is being called here.
SlimyCard(
color: Colors.transparent.withOpacity(0.2),
topCardHeight: 450,
width: 400,
topCardWidget: topCardWidget(),
bottomCardWidget: bottomCardWidget(),
),
],
);
}),
)
// the widget I want to change his text every time he's opened.
Widget bottomCardWidget() {
return FutureBuilder(
future: _getfromlist(widget.mode),
initialData: 'loading..',
builder: (BuildContext context, AsyncSnapshot<String> …Run Code Online (Sandbox Code Playgroud) 如何将动态长文本与另一个小部件(如按钮)连续展开,如下所示:
我尝试了一下Expanded,Flexible但Warp没有得出结论。
!注意我不希望这个在 aStack或Padding从底部使用!导致该文本会发生变化,其长度可能会变大或变短。
更新:我尝试使用 ExtendedText,但 TextOverFlowWidget 的子项没有显示给我。我的代码:
Container(
color: Colors.amber,
height: 70,
child: ExtendedText(
'bbbbb ${toPhoneStyle(widget.inputPhone)} (${widget.selectedCountry.dialCode}) aaaaaa aaaaaaaaaaa',
overflowWidget: TextOverflowWidget(
// maxHeight: double.infinity,
// align: TextOverflowAlign.right,
// fixedOffset: Offset.zero,
child: Container(
width: 60,
height: 60,
color: Colors.red,
),
),
),
),
Run Code Online (Sandbox Code Playgroud)
但是如果像这样缩小容器的高度height:20,则显示如下:
我有一个Widget包裹在Padding. 我想分别了解rightPadding当前width设备的。这是我尝试过的:
child: Padding(
padding: const EdgeInsets.only(
top: 8,
bottom: 8,
right: MediaQuery.of(context).size.width / 30), // -> error
child: Image.asset('assets/images/person.png'),
),
Run Code Online (Sandbox Code Playgroud)
但我收到错误:
无效常量值
这是为什么?我该如何解决这个问题?
Flutter 正在抱怨 ,_isSelected因为它不是final。问题是这是must not最终的,因为它是在buttonPressed......
class SelectionButton extends StatefulWidget {
final String title;
final Function(String) onSelectionButtonTap;
bool isSelected;
SelectionButton({
required this.title,
required this.onSelectionButtonTap,
required this.isSelected,
});
@override
_SelectionButtonState createState() => _SelectionButtonState();
}
class _SelectionButtonState extends State<SelectionButton> {
@override
Widget build(BuildContext context) {
return Expanded(
child: GestureDetector(
onTap: () {
setState(() {
widget.onSelectionButtonTap(widget.title);
widget.isSelected = !widget.isSelected;
});
},
child: Container(
decoration: BoxDecoration(
color: widget.isSelected ? AppColors.primary : AppColors.white,
borderRadius: BorderRadius.circular(
scaleWidth(10),
),
),
child: …Run Code Online (Sandbox Code Playgroud) 我的文本“Line1”下方的空间过多。我想将图像向上移动更多,但不知道如何消除所有空间?这是一个小部件,因此很想听到有关如何使其适合所有设备正确调整大小的建议!
var body: some View {
ZStack {
Color("BackgroundColor")
VStack(alignment: .leading) {
HStack {
Text("Line1")
.foregroundColor(Color("Orange"))
.bold()
.font(.system(size: 17.5))
.padding(.top)
Spacer()
Image("Icon")
.padding(.top)
}
.padding()
VStack(alignment: .leading) {
Image("Icon2")
Text("State")
.foregroundColor(Color("white"))
.font(.system(size: 15))
//.font(family == .systemLarge ? .title :
// .headline)
.padding(.top, family == .systemLarge ? -15
: 0)
Text("Last update 4.16.2021")
.foregroundColor(Color("Color2"))
.font(.system(size: 10))
.opacity(0.5)
Spacer()
Spacer()
}
.padding()
}
}
Run Code Online (Sandbox Code Playgroud)