我需要一些輕微的支持。正如您在影像中看到的,在我的 AppBar 和卡片之間有一個我無法消除的空間。我試圖從我的顫振應用程式中洗掉這個空間,但我似乎找不到可以洗掉這個空間的地方。有人可以幫我找到消除這個空間的方法嗎?

我的整個代碼
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:my_app/config/constant.dart';
import 'package:my_app/models/commodities.dart';
import 'package:my_app/models/response_options.dart';
import 'package:my_app/models/token.dart';
import 'package:my_app/src/pages/page_seleted_index.dart';
import 'package:http/http.dart' as http;
import 'package:my_app/widgets/shipper_drawer.dart';
class CreateShipmentPage extends StatefulWidget {
final Token token;
const CreateShipmentPage({required this.token, Key? key}) : super(key: key);
@override
State<CreateShipmentPage> createState() => _CreateShipmentPageState();
}
class _CreateShipmentPageState extends State<CreateShipmentPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: <Widget>[
_CustomAppBar(token: widget.token),
SliverFillRemaining(
child: FutureBuilder(
future: getData(),
builder: (context, AsyncSnapshot<OptionsResponse?> snapshot) {
if (!snapshot.hasData) {
return const Center(child: CircularProgressIndicator());
} else {
return DisplayOptions(
snapshot.data!.options.commodities, widget.token);
}
},
),
),
],
),
drawer: ShipperDrawer(token: widget.token),
);
}
}
class _CustomAppBar extends StatelessWidget {
final Token token;
const _CustomAppBar({required this.token, Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return SliverAppBar(
backgroundColor: const Color.fromRGBO(3, 9, 23, 1),
pinned: true,
title: Text(
"Hi, ${token.user.name} \nWhat do you want ship?",
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
),
centerTitle: false,
flexibleSpace: const FlexibleSpaceBar(
background: FadeInImage(
placeholder: AssetImage('assets/loading.gif'),
image: AssetImage('assets/truck.png'),
fit: BoxFit.scaleDown,
alignment: Alignment.bottomRight,
),
),
);
}
}
uj5u.com熱心網友回復:
Flutter 在一些小部件上方添加了自動填充,例如來自ListView檔案:
默認情況下,ListView 將自動填充串列的可滾動末端以避免由 MediaQuery 的填充指示的部分障礙。
像這樣包裹你的卡片小部件以洗掉頂部填充:
MediaQuery.removePadding({removeTop: true, child: ...})
uj5u.com熱心網友回復:
同意@Peter Koltai。你需要wrap你的SliverFillRemaining小部件
MediaQuery.removePadding({removeTop: true, child: ...})
銀色小部件中也有默認間距。
或者你可以SliverList像這樣使用小部件
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return Card(
child: Container(height: 44.0,child: Center(child: Text("$index"))),
);
},
childCount: 5
),
)
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/354863.html
標籤:扑
