押すとモーダルボトムシートを開くボタンがあります。シートには、いくつかのテキスト フィールドと画像 (ギャラリー/カメラから) を受け取るフォーム ウィジェットがあります。この画像入力用に、前のビュー (モーダル シート) で呼び出される別のステートフル ウィジェットを作成しました。これで、ユーザーから受け取った画像ファイルが子ステートフル ウィジェットの変数に設定されます。私の質問は、親ウィジェット内でこの変数 (子ウィジェットの File オブジェクト) にアクセスするにはどうすればよいですか?
次のコードを参照してください。
ボトムシート: (子ウィジェットが呼び出されるコメントを参照してください。)
context: _scaffoldKey.currentContext,
builder: (BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
elevation: 0.0,
automaticallyImplyLeading: false,
backgroundColor: Colors.white,
title: Center(
child: _formTitleWidget(),
),
),
body: Container(
height: MediaQuery.of(context).size.height* 0.5,
margin: EdgeInsets.all(MediaQuery
.of(context)
.copyWith()
.size
.width * 0.05),
child: Form(
key: _addChildFormKey,
child: SingleChildScrollView(
child: Container(
height: MediaQuery.of(context).size.height* 0.4,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// Calling the child widget here - where 'image' variable is set
AddChildView(),
Container(
height: MediaQuery.of(context).size.height* 0.4,
width: MediaQuery.of(context).size.width* 0.65,
child: Column(
children: [
_childNameInput(),
_childBirthDateInput(),
_childHeightInput(),
_childWeightInput(),
_addChildWithInfo()
],
),
)
],
),
),
),
),
)
);
}```