Skip to content

Instantly share code, notes, and snippets.

@RyouMon
Created December 11, 2022 03:05
Show Gist options
  • Save RyouMon/a255e87405a96e78477bcc433f336317 to your computer and use it in GitHub Desktop.
Save RyouMon/a255e87405a96e78477bcc433f336317 to your computer and use it in GitHub Desktop.
SingleChildScrollView Example
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class SingleChildScrollViewTest extends StatelessWidget {
const SingleChildScrollViewTest({super.key});
@override
Widget build(BuildContext context) {
String str = "ABCDEFGHIGKLMNOPQRSTUVWXYZ";
return Scrollbar(
child: SingleChildScrollView(
padding: const EdgeInsets.all(16.0),
child: Center(
child: Column(
children: str
.split("")
.map((e) => Text(e, textScaleFactor: 2.0))
.toList()))));
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(title)),
body: const SingleChildScrollViewTest(),
);
}
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'SingleChildScrollView Example'),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment