I work on a flutter app to learn, however on my junnction beetween my sliver AppBar title and the rest of my page i have few pixels.
I try to put margin negative.
Do you have an idea how to remove it ?
here is my code :
import 'package:flutter/material.dart';
import 'package:food_deliver/controllers/recommended_product_controller.dart';
import 'package:food_deliver/models/Popular_product_model.dart';
import 'package:food_deliver/routes/route_helper.dart';
import 'package:food_deliver/utils/app_constats.dart';
import 'package:food_deliver/utils/colors.dart';
import 'package:food_deliver/utils/dimensions.dart';
import 'package:food_deliver/widget/app_icon.dart';
import 'package:food_deliver/widget/big_text.dart';
import 'package:food_deliver/widget/expandable_text_widget.dart';
import 'package:get/get.dart';
class RecommendedFoodDetail extends StatelessWidget {
final int pageId;
const RecommendedFoodDetail({Key? key, required this.pageId})
: super(key: key);
@override
Widget build(BuildContext context) {
ProductModel product =
Get.find<RecommendedProductController>().recommendedProductList[pageId];
return Scaffold(
backgroundColor: Colors.white,
body: CustomScrollView(
shrinkWrap: true,
slivers: [
SliverAppBar(
automaticallyImplyLeading: false,
toolbarHeight: 80,
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
onTap: () {
Get.toNamed(RouteHelper.getInitial());
},
child: AppIcon(iconData: Icons.close)),
AppIcon(iconData: Icons.shopping_bag_sharp)
]),
bottom: PreferredSize(
preferredSize: Size.fromHeight(Dimensions.height20),
child: Container(
child: Center(
child: BigText(
text: product.name!,
size: Dimensions.height30,
)),
width: double.maxFinite,
padding: EdgeInsets.only(top: 7, bottom: 7),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(Dimensions.width20),
topRight: Radius.circular(Dimensions.width20))),
),
),
expandedHeight: 300,
pinned: true,
backgroundColor: AppColors.yellowColor,
flexibleSpace: FlexibleSpaceBar(
//title: Text("title"),
background: Image(
image: NetworkImage(AppConstats.BASE_URL +
AppConstats.UPLOAD_URL +
product.img!),
fit: BoxFit.cover),
),
),
SliverToBoxAdapter(
child: Column(
children: [
Container(
margin: EdgeInsets.only(
left: Dimensions.width20, right: Dimensions.width20),
child: ExpandableTextWidget(text: product.description!))
],
)),
],
),
bottomNavigationBar: Column(mainAxisSize: MainAxisSize.min, children: [
Container(
padding: EdgeInsets.only(
left: Dimensions.width20 * 3.5,
right: Dimensions.width20 * 3.5,
top: Dimensions.height10,
bottom: Dimensions.height10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
AppIcon(
iconData: Icons.remove,
backgroundColor: AppColors.mainColor,
iconColor: Colors.white,
iconSize: 30,
),
BigText(
text: "\$ ${product.price} x 0",
color: AppColors.mainBlackColor,
),
AppIcon(
iconData: Icons.add,
backgroundColor: AppColors.mainColor,
iconColor: Colors.white,
iconSize: 30,
)
],
),
),
Container(
padding: EdgeInsets.only(
top: Dimensions.height20,
bottom: Dimensions.height20,
left: Dimensions.width20,
right: Dimensions.width20,
),
child: Container(
margin: EdgeInsets.only(
left: Dimensions.width10, right: Dimensions.width10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
margin: EdgeInsets.only(left: 0, right: 0),
padding: EdgeInsets.only(
top: Dimensions.height20,
bottom: Dimensions.height20,
left: Dimensions.width20,
right: Dimensions.width20),
decoration: BoxDecoration(
color: Color.fromARGB(255, 230, 228, 228),
borderRadius:
BorderRadius.circular(Dimensions.radius20)),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.favorite,
color: AppColors.mainColor,
size: 25,
),
],
),
),
Container(
padding: EdgeInsets.only(
top: Dimensions.height20,
bottom: Dimensions.height20,
left: Dimensions.width20,
right: Dimensions.width20),
decoration: BoxDecoration(
color: AppColors.mainColor,
borderRadius:
BorderRadius.circular(Dimensions.radius20)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
BigText(
size: 22,
text: "\$ 10 Add to cart",
color: Colors.white,
),
],
),
)
]),
),
),
]),
);
}
}
I think a simple work around is to place everything inside a container with white background.