you may have to run the code to see what the problem is but for some reason when I try to add a Stack widget to the container within the flexible space it splits the container in two, and the image only shows on the left instead of the whole container.
If I don’t add the stack widget,the image fills the whole container.
Any help would be appreciated.
import 'package:country_state_city_picker/country_state_city_picker.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:multi_vendor_vendor_app/vendor/controllers/vendor_registration.dart';
import 'package:multi_vendor_vendor_app/vendor/views/auth/vendor_auth_screen.dart';
class VendorRegistrationScreen extends StatefulWidget {
const VendorRegistrationScreen({super.key});
@override
State<VendorRegistrationScreen> createState() =>
_VendorRegistrationScreenState();
}
class _VendorRegistrationScreenState extends State<VendorRegistrationScreen> {
final FirebaseAuth _firebaseAuth = FirebaseAuth.instance;
final VendorController _vendorController = VendorController();
late String countryValue;
late String stateValue;
late String cityValue;
Uint8List? _image;
selectGalleryImage() async {
Uint8List im = await _vendorController.pickStoreImage(ImageSource.gallery);
setState(() {
_image = im;
});
}
selectCameraImage() async {
Uint8List im = await _vendorController.pickStoreImage(ImageSource.gallery);
setState(() {
_image = im;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: [
SliverAppBar(
toolbarHeight: 200,
flexibleSpace: LayoutBuilder(builder: (context, constraints) {
return FlexibleSpaceBar(
background: Container(
decoration: BoxDecoration(
gradient: LinearGradient(colors: [
Colors.blue,
Colors.yellow,
Colors.yellow.shade900,
])),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
height: 90,
width: 90,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
),
child: _image != null
? Stack(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Image.memory(
_image!,
fit: BoxFit.cover,
),
),
Positioned(
top: 5,
right: 5,
child: IconButton(
onPressed: () {
selectGalleryImage();
},
icon: Icon(CupertinoIcons.photo)))
],
)
: IconButton(
onPressed: () {
selectGalleryImage();
},
icon: const Icon(
CupertinoIcons.photo,
)),
),
],
),
),
);
}),
),
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
TextFormField(
decoration: InputDecoration(
labelText: 'Business Name',
),
),
SizedBox(
height: 10,
),
TextFormField(
keyboardType: TextInputType.emailAddress,
decoration: InputDecoration(
labelText: 'Email Address',
),
),
SizedBox(
height: 10,
),
TextFormField(
keyboardType: TextInputType.phone,
decoration: InputDecoration(
labelText: 'Phone Number',
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: SelectState(
onCountryChanged: (value) {
setState(() {
countryValue = value;
});
},
onStateChanged: (value) {
setState(() {
stateValue = value;
});
},
onCityChanged: (value) {
setState(() {
cityValue = value;
});
},
),
),
],
),
),
)
],
),
);
}
}