scroll_loop_auto_scroll 0.0.2 scroll_loop_auto_scroll: ^0.0.2 copied to clipboard
This widget automatically scrolls the custom child widget to an infinite loop.
import 'package:flutter/material.dart';
import 'package:scroll_loop_auto_scroll/scroll_loop_auto_scroll.dart';
void main() => runApp(const MyApp());
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Scroll Loop Auto Scroll',
debugShowCheckedModeBanner: false,
home: HomePage());
}
}
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
//Example 1
const ScrollLoopAutoScroll(
child: Text(
'Very long text that bleeds out of the rendering space',
style: TextStyle(fontSize: 20),
),
scrollDirection: Axis.horizontal,
),
const SizedBox(
height: 40,
),
//Example 2
SizedBox(
height: 199,
child: ScrollLoopAutoScroll(
scrollDirection: Axis.vertical,
child: Column(
children: [
Container(
height: 80,
width: MediaQuery.of(context).size.width - 40,
color: Colors.green,
alignment: Alignment.center,
child: const Text(
'ONE',
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
),
Container(
height: 80,
width: MediaQuery.of(context).size.width - 40,
color: Colors.red,
alignment: Alignment.center,
child: const Text(
'FOR',
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
),
Container(
height: 80,
width: MediaQuery.of(context).size.width - 40,
color: Colors.blue,
alignment: Alignment.center,
child: const Text(
'ALL',
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
),
Container(
height: 80,
width: MediaQuery.of(context).size.width - 40,
color: Colors.orange,
alignment: Alignment.center,
child: const Text(
'AND',
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
),
Container(
height: 80,
width: MediaQuery.of(context).size.width - 40,
color: Colors.blue,
alignment: Alignment.center,
child: const Text(
'ALL',
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
),
Container(
height: 80,
width: MediaQuery.of(context).size.width - 40,
color: Colors.red,
alignment: Alignment.center,
child: const Text(
'FOR',
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
),
Container(
height: 80,
width: MediaQuery.of(context).size.width - 40,
color: Colors.green,
alignment: Alignment.center,
child: const Text(
'ONE',
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
),
],
),
),
),
const SizedBox(
height: 40,
),
//Example 3
SizedBox(
width: MediaQuery.of(context).size.width - 40,
child: ScrollLoopAutoScroll(
scrollDirection: Axis.horizontal,
child: Row(
children: [
Container(
height: 80,
width: MediaQuery.of(context).size.width / 2,
color: Colors.green,
alignment: Alignment.center,
child: const Text(
'ONE',
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
),
Container(
height: 80,
width: MediaQuery.of(context).size.width / 2,
color: Colors.red,
alignment: Alignment.center,
child: const Text(
'FOR',
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
),
Container(
height: 80,
width: MediaQuery.of(context).size.width / 2,
color: Colors.blue,
alignment: Alignment.center,
child: const Text(
'ALL',
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
),
Container(
height: 80,
width: MediaQuery.of(context).size.width / 2,
color: Colors.orange,
alignment: Alignment.center,
child: const Text(
'AND',
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
),
Container(
height: 80,
width: MediaQuery.of(context).size.width / 2,
color: Colors.blue,
alignment: Alignment.center,
child: const Text(
'ALL',
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
),
Container(
height: 80,
width: MediaQuery.of(context).size.width / 2,
color: Colors.red,
alignment: Alignment.center,
child: const Text(
'FOR',
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
),
Container(
height: 80,
width: MediaQuery.of(context).size.width / 2,
color: Colors.green,
alignment: Alignment.center,
child: const Text(
'ONE',
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
),
],
),
),
)
],
),
),
),
);
}
}