import 'package:flutter/material.dart'; import 'package:openclosenew/colors.dart'; import 'package:openclosenew/home_screen.dart'; import 'FontFamily.dart'; class PageViewModel { String title; String body; String image; PageViewModel({required this.title, required this.body, required this.image}); } class IntroScreen extends StatefulWidget { @override State createState() => _IntroScreenState(); } class _IntroScreenState extends State { int pageIndex = 0; PageController pageController = PageController(); final List pages = [ PageViewModel( title: '', body: 'Best Hotels and Restaurants around you...', image: 'assets/images/onboarding_image_1.png', ), PageViewModel( title: '', body: 'Best Medicals, Clinics and Hospitals around you...', image: 'assets/images/onboarding_image_2.png', ), PageViewModel( title: '', body: 'Best Grocery and all Other Shops around you...', image: "assets/images/onboarding_image_3.png", ) ]; @override Widget build(BuildContext context) { return Scaffold( body: Column( children: [ Expanded( child: PageView.builder( itemCount: pages.length, controller: pageController, physics: BouncingScrollPhysics(), onPageChanged: (val) { setState(() { pageIndex = val; }); }, itemBuilder: (context, pos) { PageViewModel item = pages[pos]; return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset(item.image), SizedBox( height: 16, ), Text(item.body) ], ), ); }, ), ), Padding( padding: const EdgeInsets.only(bottom: 16, left: 70, right: 16), child: Row( children: [ Spacer(), Row( children: [ for (int i = 0; i < pages.length; i++) Container( height: 8, width: (pageIndex == i) ? 20 : 8, margin: EdgeInsets.only(right: 8), decoration: BoxDecoration( color: (pageIndex == i) ? primaryColor : Colors.green.shade100, borderRadius: BorderRadius.circular(8)), ), ], ), Spacer(), (pageIndex == 2) ? FloatingActionButton( onPressed: () { Navigator.push(context, MaterialPageRoute(builder: (_) => Register())); }, elevation: 0, backgroundColor: primaryColor, child: Icon( Icons.arrow_forward_rounded, color: White, ), ) : TextButton( onPressed: () { pageController.jumpToPage(2); }, child: Text( "Skip", style: TextStyle( color: Gray, fontSize: 18, fontFamily: Font, ), ), ), ], ), ), ], ), ); } }