Introduction Screen allows you to have a screen on an app's first launch to, for example, explain your app.
This widget is very customizable with a great design.
introduction_screen uses another package, dots_indicator, that I also created.
Breaking change in 5.0.0: this package now uses the standalone
material_ui package instead of
package:flutter/material.dart. Your app must also use material_ui (or
keep the deprecated MaterialUiCompatibilityBridge). Requires Flutter
>=3.44.0 and Dart ^3.12.0. See the CHANGELOG for
details.
Examples
Not all of the many parameters in each class are used in these examples.
See Parameter Lists for the complete documentation for each class.
Note: if you want to display IntroductionScreen only once, like on the first start of your app, use
shared_preferences (or a similar strategy)
to save the status of whether it has been already displayed or not.
It's not responsibility of this package to handle this.
PageViewModel
A list of PageViewModels is used for IntroductionScreen's pages parameter.
Simple page
This example only defines the title, body, and image parameters.
(You can define image as any widget.)
PageViewModel(
title: "Title of introduction page",
body: "Welcome to the app! This is a description of how it works.",
image: constCenter(
child: Icon(Icons.waving_hand, size: 50.0),
),
)
Page with custom colors
This example defines the color of the page using the decoration parameter.
The image link does not exist and is only for example.
PageViewModel(
title: "Title of blue page",
body: "Welcome to the app! This is a description on a page with a blue background.",
image: Center(
child: Image.network("https://example.com/image.png", height: 175.0),
),
decoration: constPageDecoration(
pageColor: Colors.blue,
),
)
Page with custom text style
This example defines custom TextStyles in the decoration parameter for the title and body.
PageViewModel(
title: "Title of orange text and bold page",
body: "This is a description on a page with an orange title and bold, big body.",
image: constCenter(
child: Text("👋", style: TextStyle(fontSize: 100.0)),
),
decoration: constPageDecoration(
titleTextStyle: TextStyle(color: Colors.orange),
bodyTextStyle: TextStyle(fontWeight: FontWeight.w700, fontSize: 20.0),
),
)
Page with a footer (button)
This example defines a footer for the page with a button.
The image does not exist and is only for example.
PageViewModel(
title: "Title of custom button page",
body: "This is a description on a page with a custom button below.",
image: Image.asset("res/images/logo.png", height: 175.0),
footer: ElevatedButton(
onPressed: () {
// On button pressed
},
child: constText("Let's Go!"),
),
)
Page with widget body
This example defines the page body using bodyWidget and a Widget, rather than with body and a String.
Only use bodyorbodyWidget.
The titleWidget parameter does the same thing for the title.
PageViewModel(
title: "Title of custom body page",
bodyWidget: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Text("Click on "),
Icon(Icons.edit),
Text(" to edit a post"),
],
),
image: constCenter(child: Icon(Icons.android)),
)
IntroductionScreen
The IntroductionScreen Widget is the single object that holds all pages and related navigation and settings.
In these examples, listPagesViewModel is a list of pages.
A page is a PageViewModel object, like the examples in the previous section.
Note:
If you not provide the next parameter, the "Next" button will be not displayed. The parameter showNextButton must then be set to false.
If you want to display the "Skip" button, you must add a skip parameter and set showSkipButton to true.
The done parameter is only required if showDoneButton is true.
Simple intro screen
This example only defines the pages, showNextButton, done, and onDone parameters.
Intro screen with custom button text and dots indicators
This example defines dotsDecorator to show a custom implementation of the page progress dots.
This example also uses a custom style for the "Done" button, bolding it.
A custom style will be applied to all buttons using the baseBtnStyle parameter ("Back", "Skip", "Next", "Done").
Specific button style parameters may also be used: backStyle, skipStyle, nextStyle, doneStyle.
If both baseBtnStyle and a specific button style are defined, the baseBtnStyle will be merge with specific style.
Activate the SafeArea by setting safeAreaList: [true,true,true,true] parameter.
PageViewModel parameters
You can provide many parameters to customize each pages:
title: "Title of the page" or titleWidget: Text("Custom widget for title")
body: "Body of the page" or bodyWidget: Text("Custom widget for body")
image: Image.asset(...) image of the page.
It's expecting a Widget, so if you want to pass a Video, Text, or anything else, you can.
backgroundImage: 'assets/fullscreen.jpg' background image of the page (optional).
It's expecting a String with a path to an image asset. Works just like the image parameter under the hood while making an asset span all over the screen.
Doesn't affect the image nor fullscreen parameters: can be used together with them to build more complex layouts.
footer: ElevatedButton(...), display a widget below body
Like image param, it's expecting a Widget, you can pass what you want.
decoration: PageDecoration(...), page decoration to customize page
See next section for all parameters you can pass
reverse: true, reverse order of image and content (title/body). (Default: false)
useScrollView: false, by default pages use a Scrollview to handle small screen or long body text. You can remove ScrollView by setting to false.
scrollViewKeyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.manual, by default the keyboard dismiss behavious is manual, you can change it.
Only used if useScrollView not set to false.
PageDecoration parameters
pageColor: Colors.white, background color of the page
You cannot use both pageColor and boxDecoration params
titleTextStyle: TextStyle(...), TextStyle of the title
bodyTextStyle: TextStyle(...), TextStyle of the body
boxDecoration: BoxDecoration(...), BoxDecoration of page container
You cannot use both pageColor and boxDecoration params
imageFlex: 2, flex ratio of the image
bodyFlex: 3, flex ratio of the content (title/body)
footerFlex: 1, flex ratio of the content (title/body)
footerFit: FlexFit.loose, flex ratio of the content (title/body)
imagePadding: EdgeInsets.only(bottom: 12.0), padding of the image Widget. (Default EdgeInsets.only(bottom: 24.0))
contentPadding: EdgeInsets.only(all: 24.0), padding of the content (title/body/footer) Widget. (Default EdgeInsets.all(16))
titlePadding: EdgeInsets.only(bottom: 24.0), padding of the title text/Widget. (Default EdgeInsets.only(top: 16.0, bottom: 24.0))
descriptionPadding: EdgeInsets.only(bottom: 24.0), padding of the body text/Widget. (Default EdgeInsets.zero)
footerPadding: EdgeInsets.only(top: 24.0), padding of the footer text/Widget. (Default EdgeInsets.symmetric(vertical: 24.0))