main.dart 1.26 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
import 'package:flutter/material.dart';
import 'package:flutter_driver/driver_extension.dart';
7

8 9
import 'motion_events_page.dart';
import 'page.dart';
10
import 'wm_integrations.dart';
11

12
final List<PageWidget> _allPages = <PageWidget>[
13
  const MotionEventsPage(),
14
  const WindowManagerIntegrationsPage(),
15
];
16 17 18

void main() {
  enableFlutterDriverExtension(handler: driverDataHandler.handleMessage);
19
  runApp(const MaterialApp(home: Home()));
20 21
}

22
class Home extends StatelessWidget {
23
  const Home({Key? key}) : super(key: key);
24

25 26
  @override
  Widget build(BuildContext context) {
27
    return Scaffold(
28 29
      body: ListView(
         children: _allPages.map((PageWidget p) => _buildPageListTile(context, p)).toList(),
30 31 32 33
      ),
    );
  }

34 35 36 37 38 39 40 41
  Widget _buildPageListTile(BuildContext context, PageWidget page) {
    return ListTile(
      title: Text(page.title),
      key: page.tileKey,
      onTap: () { _pushPage(context, page); },
    );
  }

42
  void _pushPage(BuildContext context, PageWidget page) {
43 44 45 46
    Navigator.of(context).push(MaterialPageRoute<void>(
        builder: (_) => Scaffold(
              body: page,
            )));
47 48
  }
}