Introduction

In this article, we will learn how to implement an awesome introduction view with animation in Flutter. Introduction View is the first impression of the app so it should be the best. Well, let’s make it the best.
Output
Flutter Awesome Introduction View Flutter Awesome Introduction View
Plugin Required
intro_views_flutter: ^2.6.0

Steps

Step 1
The first and most basic step is to create a new application in Flutter. If you are a beginner in Flutter, then you can check my blog Create a first app in Flutter. For now, I have created an app named as “flutter_intro_view”.
Step 2
Now, we will configure intro_views_flutter plugin in pubspec.yaml file.
  1. dependencies:
  2. flutter:
  3. sdk: flutter
  4. cupertino_icons: ^0.1.2
  5. intro_views_flutter: ^2.6.0
Step 3
Now, we will add introduction images in the project in assets/images folder and configure them in pubspec.yaml file.
  1. assets:
  2. - assets/images/1.jpg
  3. - assets/images/2.jpg
  4. - assets/images/3.jpg
Step 4
Now, we will add a custom font to make the UI better.
  1. fonts:
  2. - family: Pacifico
  3. fonts:
  4. - asset: fonts/Pacifico-Regular.ttf
Step 5
Now, it’s time to implement an actual Introduction View using flutter_intro_views. Following is the implementation for that. For more understanding, please read comments in code.
  1. import 'package:flutter/material.dart';
  2. import 'package:intro_views_flutter/Models/page_view_model.dart';
  3. import 'package:intro_views_flutter/intro_views_flutter.dart';
  4. void main() => runApp(MyApp());
  5. class MyApp extends StatelessWidget {
  6. final pages = [
  7. PageViewModel(
  8. pageColor: const Color.fromRGBO(0, 157, 204, 1), // To Define page background color
  9. bubble: Icon(Icons.check_circle), // to define page indicator at bottom
  10. body: Text(
  11. 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.',
  12. ), // compulsory to define body and it will be shown at bottom
  13. title: Text(
  14. 'Super Sale',
  15. style: TextStyle(fontSize: 32.0),
  16. ), // it will be shown at page header
  17. textStyle: TextStyle(
  18. fontFamily: 'Pacifico',
  19. color: Colors.black,
  20. ), // generic text style define for whole page
  21. mainImage: Image.asset(
  22. 'assets/images/1.jpg',
  23. width: 300.0,
  24. alignment: Alignment.center,
  25. ), // to define image for the introduction
  26. ),
  27. PageViewModel(
  28. pageColor: const Color.fromRGBO(255, 245, 2, 1),
  29. bubble: Icon(Icons.check_circle),
  30. body: Text(
  31. 'There are many variations of passages of Lorem Ipsum available',
  32. ),
  33. title: Text(
  34. 'Mega Sale',
  35. style: TextStyle(fontSize: 32.0),
  36. ),
  37. mainImage: Image.asset(
  38. 'assets/images/2.jpg',
  39. width: 300.0,
  40. alignment: Alignment.center,
  41. ),
  42. textStyle: TextStyle(
  43. fontFamily: 'Pacifico',
  44. color: Colors.black,
  45. ),
  46. ),
  47. PageViewModel(
  48. pageColor: const Color.fromRGBO(0, 54, 128, 1),
  49. bubble: Icon(Icons.check_circle),
  50. body: Text(
  51. 'Sed ut perspiciatis unde omnis iste natus error sit voluptatem',
  52. ),
  53. title: Text(
  54. 'Super Sale',
  55. style: TextStyle(fontSize: 32.0),
  56. ),
  57. mainImage: Image.asset(
  58. 'assets/images/3.jpg',
  59. width: 300.0,
  60. alignment: Alignment.center,
  61. ),
  62. textStyle: TextStyle(
  63. fontFamily: 'Pacifico',
  64. color: Colors.white,
  65. ),
  66. ),
  67. ];
  68. @override
  69. Widget build(BuildContext context) {
  70. return MaterialApp(
  71. debugShowCheckedModeBanner: false,
  72. title: 'Flutter Intro View',
  73. theme: ThemeData(
  74. primarySwatch: Colors.blue,
  75. ),
  76. home: Builder(
  77. builder: (context) => IntroViewsFlutter(
  78. pages,
  79. skipText: Text('SKIP',style: TextStyle(color: Colors.black),), // Customize skip button
  80. doneText: Text('GO TO APP',style: TextStyle(color: Colors.white),), // Customize done button
  81. onTapDoneButton: () {
  82. Navigator.push(
  83. context,
  84. MaterialPageRoute(
  85. builder: (context) => MyHomePage(),
  86. ),
  87. ); // after introduction where to navigate
  88. },
  89. pageButtonTextStyles: TextStyle(
  90. color: Colors.white,
  91. fontSize: 18.0,
  92. ),
  93. ),
  94. ),
  95. );
  96. }
  97. }
  98. class MyHomePage extends StatefulWidget {
  99. @override
  100. _MyHomePageState createState() => _MyHomePageState();
  101. }
  102. class _MyHomePageState extends State<MyHomePage> {
  103. int _counter = 0;
  104. void _incrementCounter() {
  105. setState(() {
  106. _counter++;
  107. });
  108. }
  109. @override
  110. Widget build(BuildContext context) {
  111. return Scaffold(
  112. appBar: AppBar(
  113. title: Text('Home Page'),
  114. ),
  115. body: Center(
  116. child: Column(
  117. mainAxisAlignment: MainAxisAlignment.center,
  118. children: <Widget>[
  119. Text(
  120. 'You have pushed the button this many times:',
  121. ),
  122. Text(
  123. '$_counter',
  124. style: Theme.of(context).textTheme.display4,
  125. ),
  126. ],
  127. ),
  128. ),
  129. floatingActionButton: FloatingActionButton(
  130. onPressed: _incrementCounter,
  131. tooltip: 'Increment',
  132. child: Icon(Icons.add),
  133. ),
  134. );
  135. }
  136. }
Hooray…. Run the app and test it on an emulator/simulator or device :)))

Conclusion

We have learned how to implement an awesome introduction view in Flutter.
Reference