Skip to content
Readerstacks logo Readerstacks
  • Home
  • Softwares
  • Angular
  • Php
  • Laravel
  • Flutter
Readerstacks logo
Readerstacks
How to create a scroll like tiktok in flutter

How to create a scroll like tiktok in flutter ?

Aman Jain, January 8, 2022January 15, 2022

Flutter such a great framework to develop the mobile application using flutter we can create any type of complex using with ease. In this tutorial i will show you how can we make a UI like tiktok, Reels, moj like scroll in flutter.

We will use PageView to create the UI like these apps. PageView accepts multiple parameter to change te direction or initial page etc. You can also read our last article for scrollview.

So in this article i will cover PageView to create a scroll like tiktok in flutter by step by step

Step 1 : Create flutter project

Very first step is to create the fluter application using command line tool or in Android studio.

flutter create example_app

This will create a new project with name my_app then go in to the folder.

Step 2 : Create a widgets for scroll list

Now, Create a widget to scroll the content.

File : lib/TiktokScrollWidget.dart

import 'package:flutter/material.dart';
class TiktokScrollWidget extends StatelessWidget {
  final List<String> list = <String>['1', '2', '3', '4', '5'];
  TiktokScrollWidget({Key? key}) : super(key: key);
  PageController pageController = PageController(initialPage: 1);
  List<Widget> buildContainers() {
    return list
        .map((e) => Container(
            decoration: const BoxDecoration(
              image: DecorationImage(
                  image: NetworkImage("https://picsum.photos/200/300"),
                  fit: BoxFit.cover),
            ),
            child: Container(
                alignment: Alignment.bottomLeft,
                margin: EdgeInsets.only(bottom: 40, left: 20),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.end,
                  children: [
                    Text(" Name of user  " + e,
                        style: TextStyle(
                            color: Colors.white, fontWeight: FontWeight.bold)),
                    Text(" subtitle  " + e,
                        style: TextStyle(color: Colors.white))
                  ],
                ))))
        .toList();

    // return [Container(
    //    // height: 200,
    //      margin: EdgeInsets.all(5),
    //      decoration: BoxDecoration(
    //          border: Border.all(color: Colors.red)
    //      ),
    //      child: Center(
    //          child:  Text(e)
    //      )
    //  ),
    //    Container(
    //      // height: 200,
    //        margin: EdgeInsets.all(5),
    //        decoration: BoxDecoration(
    //            border: Border.all(color: Colors.red)
    //        ),
    //        child: Center(
    //            child:  Text(e)
    //        )
    //    )]
  }

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(title: const Text("Readerstack")),
        body: PageView(
            controller: pageController,
            scrollDirection: Axis.vertical,
            children: buildContainers()),
      ),
    );
  }
}

Here as you can see we have used PageView to build the scroll view like ticktock and also created a PageController to set initial page and used scrollDirection to change the direction of scroll.

Step 3 : Add Page to main file

Add you new pages to main.dart and start navigating.

import 'package:flutter/material.dart';
import 'package:example_app/TiktokScrollWidget.dart';

void main() => runApp(TiktokScrollWidget());

Step 4: Run the project

Simply run the project using command line or in android studio to check the implementation.

flutter run lib/main.dart

Live Preview

How to create horizontal slide in flutter using pageview?

Flutter Pageview by default creates horizontal scroll with slide therefore we do not need to change anything in pageview so in above example we need to remove scrollDirection.

 PageView(
           controller: pageController,
           children: buildContainers()
         )

Related

Dart Flutter Flutterscrolltiktok

Post navigation

Previous post
Next post

Related Posts

Dart How to add one side border to container widget flutter

How to add one side border to container widget flutter?

September 17, 2022March 16, 2024

In this tutorial we will learn to add add one side border to container widget flutter. Border is used to create border around the widget or container and using the border we can style it in different way like adding the width of border, color of border and one side…

Read More
Dart Display Asset Image in Flutter

How to show local(asset) image in flutter application?

January 2, 2022January 15, 2022

In this tutorial we will learn to show assets image in flutter. In flutter there is two types of images we can show one is asset image and other one is network image. To use the images in flutter we have Image class which supports both local and remote images….

Read More
Dart Create Drawer in flutter

How to create drawer in flutter with example ?

January 3, 2022January 15, 2022

Flutter itself provides various widgets to create the industry level standard layout. One of the feature of flutter is creating default drawer in flutter with Scaffold. Using the drawer we can show our application menus list and hide show in sidebar. In this s tutorial i will create a simple…

Read More

Aman Jain
Aman Jain

With years of hands-on experience in the realm of web and mobile development, they have honed their skills in various technologies, including Laravel, PHP CodeIgniter, mobile app development, web app development, Flutter, React, JavaScript, Angular, Devops and so much more. Their proficiency extends to building robust REST APIs, AWS Code scaling, and optimization, ensuring that your applications run seamlessly on the cloud.

Categories

  • Angular
  • CSS
  • Dart
  • Devops
  • Flutter
  • HTML
  • Javascript
  • jQuery
  • Laravel
  • Laravel 10
  • Laravel 11
  • Laravel 9
  • Mysql
  • Php
  • Softwares
  • Ubuntu
  • Uncategorized

Archives

  • August 2025
  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • October 2024
  • July 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • July 2023
  • March 2023
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Recent Posts

  • The Transformative Power of Education in the Digital Age
  • Understanding High Vulnerabilities: A Closer Look at the Week of July 14, 2025
  • Exploring Fresh Resources for Web Designers and Developers
  • The Intersection of Security and Technology: Understanding Vulnerabilities
  • Mapping Together: The Vibrant Spirit of OpenStreetMap Japan
©2023 Readerstacks | Design and Developed by Readerstacks
Go to mobile version