cupertino_page_scaffold.0.dart 1.66 KB
Newer Older
1 2 3 4 5 6 7 8
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flutter code sample for CupertinoPageScaffold

import 'package:flutter/cupertino.dart';

9
void main() => runApp(const PageScaffoldApp());
10

11
class PageScaffoldApp extends StatelessWidget {
12
  const PageScaffoldApp({super.key});
13 14 15 16

  @override
  Widget build(BuildContext context) {
    return const CupertinoApp(
17 18
      theme: CupertinoThemeData(brightness: Brightness.light),
      home: PageScaffoldExample(),
19 20 21 22
    );
  }
}

23
class PageScaffoldExample extends StatefulWidget {
24
  const PageScaffoldExample({super.key});
25 26

  @override
27
  State<PageScaffoldExample> createState() => _PageScaffoldExampleState();
28 29
}

30
class _PageScaffoldExampleState extends State<PageScaffoldExample> {
31 32 33 34 35 36 37 38
  int _count = 0;

  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
      // Uncomment to change the background color
      // backgroundColor: CupertinoColors.systemPink,
      navigationBar: const CupertinoNavigationBar(
39
        middle: Text('CupertinoPageScaffold Sample'),
40
      ),
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
      child: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Center(
              child: Text('You have pressed the button $_count times.'),
            ),
            const SizedBox(height: 20.0),
            Center(
              child: CupertinoButton.filled(
                onPressed: () => setState(() => _count++),
                child: const Icon(CupertinoIcons.add),
              ),
            ),
          ],
        ),
57 58 59 60
      ),
    );
  }
}