我有Store Model,如果我的模型为null,我想返回null.
public Store Details() => db.Store.Single(s => s.Id == 1);
Run Code Online (Sandbox Code Playgroud)
此查询有时会返回一个值,有时会返回null.如何将返回类型具体包含在内?
我想垂直对齐表格。
从 'react' 导入 React, { Component }; 从 'native-base' 导入 { 容器、标题、内容、表单、项目、输入、按钮、文本 };从'react-native'导入{StyleSheet};
export default class FormExample extends Component {
render() {
return (
<Container>
<Content>
<Form style={styles.container}>
<Item>
<Input placeholder="Email" />
</Item>
<Item last>
<Input placeholder="Password" />
</Item>
<Button block>
<Text>Submit</Text>
</Button>
</Form>
</Content>
</Container>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
margin: 25,
alignItems: "center"
}
Run Code Online (Sandbox Code Playgroud)
});
我的应用程序看起来像这样。
我想使用 Firebase 设置身份验证。我有这个身份验证存储库,它具有获取当前用户的方法。
@override
Stream<User?> get user => _firebaseAuth.userChanges();
Run Code Online (Sandbox Code Playgroud)
在我的块内,我有这个构造函数。
class AuthBloc extends Bloc<AuthEvent, AuthState> {
final AuthRepository _authRepository;
late StreamSubscription<User?> _authSubscription;
AuthBloc(AuthRepository authRepository)
: _authRepository = authRepository,
super(const AuthState.initial()) {
on<AuthStarted>(_onUserChanged);
}
void _onUserChanged(AuthStarted event, Emitter<AuthState> emit) {
_authSubscription = _authRepository.user.listen((user) async {
if (user != null) {
emit(AuthState.authenticated(user));
} else {
const AuthState.unauthenticated();
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
当我的应用程序启动时,我在我的主类上调用它。
BlocProvider<AuthBloc>(
create: (context) => AuthBloc(context.read<AuthRepository>())
..add(const AuthEvent.started()),
),
Run Code Online (Sandbox Code Playgroud)
这就是我的状态
part of 'auth_bloc.dart';
@freezed
class AuthState with _$AuthState {
const factory …Run Code Online (Sandbox Code Playgroud) 我有这个有密码字段和confirmPassword字段的表单.我想将密码字段与confirmPassword字段进行比较.我这样做有点问题,因为我有一个ng-show,当密码不匹配但是消息总是显示时,应该只显示"Passwords Do Not Match"错误.
<label class="control-label">Password *
<div class="row m-b-15">
<div class="col-md-12">
<input type="text" placeholder="Password" name="password" required="" ng-model="user.password" class="form-control"/>
</div>
</div>
<label class="control-label">Re-enter Password *</label>
<div class="row m-b-15">
<div class="col-md-12">
<input type="text" placeholder="Re-enter Password" name="confirmPassword" required="" ng-model="user.confirmPassword" ka-compare-to="user.password" class="form-control"/>
<div ng-show="signUpForm.confirmPassword.$error" class="form-group has-error">
<label class="control-label">Passwords Do Not Match</label>
</div>
</div>
</div>
</label>
.directive('kaCompareTo', function(){
return {
restrict: 'A',
require: 'ngModel',
scope: {
otherModelValue: '=kaCompareTo'
},
link: function(scope, element, attributes, ngModel){
ngModel.$validators.kaCompareTo = function(modelValue){
return modelValue === scope.otherModelValue;
};
scope.$watch("otherModelValue", function() …Run Code Online (Sandbox Code Playgroud) 我有这段代码。
Container(
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(18),
),
child: Center(
child: Text(
'Monday',
style: TextStyle(
color: Colors.white,
fontSize: 30,
),
),
),
);
Run Code Online (Sandbox Code Playgroud)
这产生了这个
但我想要看起来像这样的东西。
我有这个for循环,我想在每个循环中增加年份,但是我只得到最后一年,它们都重复多次。
for (let i = 0; i < 2; i++) {
this.data.year = new Date().getFullYear() + i;
this.data.noSolar = averageBill * increaseRate;
this.data.withSolar = (contractAmount * .004) + customerCharge;
this.data.saving = (contractAmount * .004 + customerCharge) * 12 - (averageBill * 12);
this.data.check = SREC;
this.data.total = (contractAmount * .004 + customerCharge) * 12 - (averageBill * 12) + SREC;
this.dataSource.push(this.data);
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,“ 2020年”显示了两次。我想要像2019和2020这样的东西。就像变量多次被引用一样。
我正在使用 React Native NativeBase,我想将一个数字传递给我的输入值,但我收到一个错误,提示我无法将数字传递给字符串。
<Input
keyboardType="numeric"
onChangeText={(text) => setTarget(text)}
value={target}
/>
Run Code Online (Sandbox Code Playgroud)
现在如果我这样做。
<Input
keyboardType="numeric"
// onChangeText={(text) => setTarget(text)}
value={"target"}
Run Code Online (Sandbox Code Playgroud)
错误消失。这是值的定义
const [target, setTarget] = useState<number>(0);
Run Code Online (Sandbox Code Playgroud)
我有两个李的ul.
<ul>
<li class="first">$2.00</li>
<li class="second">- $4.00</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
现在,当打印他们没有正确对齐.我想要做的是将第二个类别移动到左边两个空格,这样两个美元符号符号垂直对齐这是我的codepen.
flutter ×2
react-native ×2
reactjs ×2
angular ×1
angularjs ×1
asp.net ×1
asp.net-mvc ×1
c# ×1
c#-7.0 ×1
css ×1
flexbox ×1
flutter-bloc ×1
freezed ×1
javascript ×1
native-base ×1
poco ×1
typescript ×1