每当我可以底部导航栏时,我的 api 都不起作用,请看一下图片!
谢谢, Mohsin在此处输入图片描述
import 'package:flutter/material.dart';
import 'package:flutter_grocery/helper/product_type.dart';
import 'package:flutter_grocery/helper/responsive_helper.dart';
import 'package:flutter_grocery/localization/language_constrants.dart';
import 'package:flutter_grocery/provider/banner_provider.dart';
import 'package:flutter_grocery/provider/category_provider.dart';
import 'package:flutter_grocery/provider/localization_provider.dart';
import 'package:flutter_grocery/provider/product_provider.dart';
import 'package:flutter_grocery/utill/dimensions.dart';
import 'package:flutter_grocery/utill/styles.dart';
import 'package:flutter_grocery/view/base/custom_app_bar.dart';
import 'package:flutter_grocery/view/base/main_app_bar.dart';
import 'package:flutter_grocery/view/base/title_widget.dart';
import 'package:flutter_grocery/view/screens/auth/login_screen.dart';
import 'package:flutter_grocery/view/screens/cart/cart_screen.dart';
import 'package:flutter_grocery/view/screens/category/all_category_screen.dart';
import 'package:flutter_grocery/view/screens/dashboard/dashboard_screen.dart';
import 'package:flutter_grocery/view/screens/home/widget/banners_view.dart';
import 'package:flutter_grocery/view/screens/home/widget/category_view.dart';
import 'package:flutter_grocery/view/screens/home/widget/daily_item_view.dart';
import 'package:flutter_grocery/view/screens/home/widget/product_view.dart';
import 'package:flutter_grocery/view/screens/menu/bottomnavigationbar.dart';
import 'package:provider/provider.dart';
class HomeScreen extends StatefulWidget {
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
Future<void> _loadData(BuildContext context, bool reload) async {
// await Provider.of<CategoryProvider>(context, listen: false).getCategoryList(context, reload);
await Provider.of<CategoryProvider>(context, listen: false).getCategoryList(
context,
Provider.of<LocalizationProvider>(context, listen: false)
.locale
.languageCode,
reload,
);
await Provider.of<BannerProvider>(context, listen: false)
.getBannerList(context, reload);
await Provider.of<ProductProvider>(context, listen: false).getDailyItemList(
context,
reload,
Provider.of<LocalizationProvider>(context, listen: false)
.locale
.languageCode,
);
// await Provider.of<ProductProvider>(context, listen: false).getPopularProductList(context, '1', true);
Provider.of<ProductProvider>(context, listen: false).getPopularProductList(
context,
'1',
reload,
Provider.of<LocalizationProvider>(context, listen: false)
.locale
.languageCode,
);
}
@override
Widget build(BuildContext context) {
final ScrollController _scrollController = ScrollController();
_loadData(context, false);
return RefreshIndicator(
onRefresh: () async {
await _loadData(context, true);
},
backgroundColor: Theme.of(context).primaryColor,
child: Scaffold(
bottomNavigationBar: BottomNavStartingPoint(),
appBar: ResponsiveHelper.isDesktop(context) ? MainAppBar() : null,
body: Scrollbar(
child: SingleChildScrollView(
controller: _scrollController,
child: Center(
child: SizedBox(
width: 1170,
child: Column(crossAxisAlignment: CrossAxisAlignment.start,
// controller: _scrollController,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Home',
style: TextStyle(
fontFamily: poppinsRegular.fontFamily,
fontSize: 25,
fontWeight: FontWeight.w600),
),
),
Consumer<BannerProvider>(
builder: (context, banner, child) {
return banner.bannerList == null
? BannersView()
: banner.bannerList.length == 0
? SizedBox()
: BannersView();
}),
// Category
Consumer<CategoryProvider>(
builder: (context, category, child) {
return category.categoryList == null
? CategoryView()
: category.categoryList.length == 0
? SizedBox()
: CategoryView();
}),
// Category
Consumer<ProductProvider>(
builder: (context, product, child) {
return product.dailyItemList == null
? DailyItemView()
: product.dailyItemList.length == 0
? SizedBox()
: DailyItemView();
}),
// Popular Item
Padding(
padding: EdgeInsets.all(Dimensions.PADDING_SIZE_SMALL),
child: TitleWidget(
title: getTranslated('popular_item', context)),
),
ProductView(
productType: ProductType.POPULAR_PRODUCT,
scrollController: _scrollController),
]),
),
),
),
),
),
);
}
}
这是主页这一页的全部代码,我正在努力解决这个问题,我希望你能帮助我,如果有人能帮助我,我将不胜感激!
再次感谢!