I have a button which when pressed opens a modal bottom sheet. The sheet has a form widget that takes few text fields and an image (from gallery/camera). For this image input, I have created another stateful widget which is called in the previous view (the modal sheet). Now, the image file received through user is set in a variable in the child stateful widget. My question is, how can I access this variable (a File object in child widget) inside the parent widget?
Please refer to the following code:
Bottom Sheet: (See comment where child widget is called.)
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()
],
),
)
],
),
),
),
),
)
);
}```
Navigator.pop
to send a result. – creativecreatorormaybenot