add
This commit is contained in:
@@ -271,10 +271,12 @@ class _CountryPageState extends State<CountryPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBody(ThemeData theme) {
|
Widget _buildBody(ThemeData theme) {
|
||||||
|
// 加载中且列表为空
|
||||||
if (_isLoading && _countries.isEmpty) {
|
if (_isLoading && _countries.isEmpty) {
|
||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: CircularProgressIndicator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 有错误信息且列表为空
|
||||||
if (_errorMessage != null && _countries.isEmpty) {
|
if (_errorMessage != null && _countries.isEmpty) {
|
||||||
return Center(
|
return Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -294,6 +296,43 @@ class _CountryPageState extends State<CountryPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 无数据状态(列表为空且无错误)
|
||||||
|
if (_countries.isEmpty) {
|
||||||
|
return Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
// 无数据背景图标
|
||||||
|
Icon(
|
||||||
|
Icons.flag_outlined,
|
||||||
|
size: 120,
|
||||||
|
color: theme.colorScheme.onSurface.withOpacity(0.1),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
// 无数据提示文字
|
||||||
|
Text(
|
||||||
|
'暂无国家数据',
|
||||||
|
style: theme.textTheme.titleLarge?.copyWith(
|
||||||
|
color: theme.colorScheme.onSurface.withOpacity(0.5),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
// 刷新按钮
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
Icons.refresh,
|
||||||
|
size: 28,
|
||||||
|
color: theme.colorScheme.primary,
|
||||||
|
),
|
||||||
|
onPressed: () => _fetchCountries(isRefresh: true),
|
||||||
|
tooltip: '刷新数据',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 正常列表展示
|
||||||
return RefreshIndicator(
|
return RefreshIndicator(
|
||||||
onRefresh: _refresh,
|
onRefresh: _refresh,
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
|
|||||||
Reference in New Issue
Block a user