Skip to content

Instantly share code, notes, and snippets.

@bltavares
Created July 4, 2022 18:55
Show Gist options
  • Save bltavares/875532f35cf0144890f757905d35dfd9 to your computer and use it in GitHub Desktop.
Save bltavares/875532f35cf0144890f757905d35dfd9 to your computer and use it in GitHub Desktop.
silent-sunshine-7526

silent-sunshine-7526

Created with <3 with dartpad.dev.

import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: const MyStatelessWidget(),
),
);
}
}
class NoisyText extends StatelessWidget {
const NoisyText(this.text, {super.key });
final String text;
@override
Widget build(BuildContext context) {
print('RENDERED $text');
return Text(text);
}
}
class MyStatelessWidget extends StatelessWidget {
const MyStatelessWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final PageController controller = PageController();
return PageView(
/// [PageView.scrollDirection] defaults to [Axis.horizontal].
/// Use [Axis.vertical] to scroll vertically.
controller: controller,
children: const <Widget>[
Center(
child: NoisyText('First Page'),
),
Center(
child: NoisyText('Second Page'),
),
Center(
child: NoisyText('Third Page'),
)
],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment