import 'package:flutter/material.dart'; import 'package:openclosenew/home_screen.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) ? Colors.green : Colors.green.shade100, borderRadius: BorderRadius.circular(8)), ), ], ), Spacer(), (pageIndex == 2) ? FloatingActionButton( onPressed: () { Navigator.push(context, MaterialPageRoute(builder: (_) => Register())); }, elevation: 0, backgroundColor: Colors.green, child: Icon( Icons.arrow_forward_rounded, color: Colors.white, ), ) : TextButton( onPressed: () { pageController.jumpToPage(2); }, child: Text( "Skip", style: TextStyle(color: Colors.grey.shade600), ), ), ], ), ) ], ), ); } }