当我移动到导航树上的另一个屏幕时,我需要暂停相机以节省电池和性能。
我尝试使用dispose()cameraController,但是当它从另一个屏幕返回时,flutter 不会重新初始化状态(虽然很明显)。
我使用相机的主要代码:
@override
void initState() {
super.initState();
availableCameras().then((cameras) {
setState(() {
_firstCamera = cameras.first;
_controller = CameraController(_firstCamera, ResolutionPreset.high);
_initializeControllerFuture = _controller.initialize();
});
});
}
@override
void dispose() {
_controller?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldKey,
body: Stack(
children: <Widget>[
FutureBuilder<void>(
future: _initializeControllerFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
return Stack(
alignment: FractionalOffset.center,
children: <Widget>[
new Positioned.fill(
child: _getCameraPreview(context),
),
...
],
);
} else {
return …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用单选按钮的两种方式数据绑定。它可以通过如下所示的一种方式正常工作,
android:checked="@{registration.gender.equals(Gender.FEMALE.getValue())}"。
但我的问题是,我需要在模型中设置所选单选按钮的值。
<?xml version="1.0" encoding="UTF-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools">
<data>
<import type="com.callhealth.customer.comman.enums.Gender" />
<import type="android.text.TextUtils" />
<import type="java.lang.Integer" />
<variable name="callback" type="com.callhealth.customer.usermanagement.callback.RegistrationCallback" />
<variable name="registration" type="com.callhealth.customer.usermanagement.model.request.LoginAndRegistrationRequestModel" />
</data>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:orientation="vertical">
<android.support.v7.widget.AppCompatTextView android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/label_gender" android:textSize="15sp" />
<RadioGroup android:id="@+id/gender_group" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="5dp" android:orientation="horizontal">
<android.support.v7.widget.AppCompatRadioButton android:layout_width="wrap_content" android:checked="@={registration.gender.equals(Gender.MALE.getValue())}" android:layout_height="wrap_content" android:text="@string/label_male" />
<android.support.v7.widget.AppCompatRadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:layout_marginStart="20dp" android:checked="@={registration.gender.equals(Gender.FEMALE.getValue())}" android:text="@string/label_female" />
</RadioGroup>
</LinearLayout>
</layout>
Run Code Online (Sandbox Code Playgroud)
我的模特班
public class LoginAndRegistrationRequestModel extends BaseObservable {
private Integer gender;
@Bindable
public Integer getGender() {
return …Run Code Online (Sandbox Code Playgroud) 我已将反应本机地图与最新的反应本机应用程序集成。在地图中,我想设置地图的边界。官方文档建议了该方法
setMapBoundaries ,但需要这样的论证northEast: LatLng, southWest: LatLng 。
我怎样才能获得这些参数的值。我的mapView是这样的。
<MapView
showsUserLocation
provider={MapView.PROVIDER_GOOGLE}
style={styles.map}
region={region}
onRegionChangeComplete={this.onRegionChangeComplete}
setMapBoundaries={}
onUserLocationChange={this.onUserLocationChange}
>
Run Code Online (Sandbox Code Playgroud)