// import 'dart:io'; import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import '../../models/app_bottom_nav_item.dart'; import '../../services/app_info.service.dart'; import '../../util/util.dart'; class LandingPage extends StatefulWidget { LandingPage({Key? key}) : super(key: key); @override _LandingPageState createState() => _LandingPageState(); } class _LandingPageState extends State { int _selectedLanding = 0; List bottomNavItems = []; List pages = []; @override Widget build(BuildContext context) { // ScreenUtil.init( // BoxConstraints( // maxWidth: MediaQuery.of(context).size.width, // maxHeight: MediaQuery.of(context).size.height), // designSize: const Size(414, 896), // orientation: Orientation.portrait, // context: context, // ); List roleWithBottomNavItems = AppInfoService.to.bottomNavItems!; bottomNavItems = roleWithBottomNavItems .map((e) => BottomNavigationBarItem( icon: e.icon, activeIcon: e.activeIcon, label: e.label)) .toList(); pages = roleWithBottomNavItems.map((e) => e.page!).toList(); return Scaffold( bottomNavigationBar: BottomNavigationBar( iconSize: ScreenAdaper.sp(40), type: BottomNavigationBarType.fixed, items: bottomNavItems, showSelectedLabels: true, showUnselectedLabels: true, currentIndex: _selectedLanding, onTap: (landing) { _onItemTapped(landing); }, ), body: pages[_selectedLanding], ); } void _onItemTapped(int landing) { if (landing != _selectedLanding) { setState(() { _selectedLanding = landing; }); } } }