PageScaffold
sample.packages.flutter.lib.src.cupertino.page_scaffold.22.
This example shows a [CupertinoPageScaffold] with a [ListView] as a [child]. The [CupertinoButton] is connected to a callback that increments a counter. The [backgroundColor] can be changed.
import 'package:flutter/cupertino.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 const CupertinoApp(
title: _title,
home: MyStatefulWidget(),
);
}
}
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({Key? key}) : super(key: key);
@override
State createState() => _MyStatefulWidgetState();
}
class _MyStatefulWidgetState extends State {
int _count = 0;
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
// Uncomment to change the background color
// backgroundColor: CupertinoColors.systemPink,
navigationBar: const CupertinoNavigationBar(
middle: Text('Sample Code'),
),
child: ListView(
children: [
CupertinoButton(
onPressed: () => setState(() => _count++),
child: const Icon(CupertinoIcons.add),
),
Center(
child: Text('You have pressed the button $_count times.'),
),
],
),
);
}
}
SHARE: