main.dart 944 Bytes
Newer Older
1 2
import 'package:flutter/material.dart';
import 'package:flutter_driver/driver_extension.dart';
3 4
import 'motion_events_page.dart';
import 'page.dart';
5

6 7 8
final List<Page> _allPages = <Page>[
  const MotionEventsPage(),
];
9 10 11

void main() {
  enableFlutterDriverExtension(handler: driverDataHandler.handleMessage);
12
  runApp(MaterialApp(home: Home()));
13 14
}

15
class Home extends StatelessWidget {
16 17
  @override
  Widget build(BuildContext context) {
18 19 20 21 22 23 24
    return Scaffold(
      body: ListView.builder(
        itemCount: _allPages.length,
        itemBuilder: (_, int index) => ListTile(
          title: Text(_allPages[index].title),
          key: _allPages[index].tileKey,
          onTap: () => _pushPage(context, _allPages[index]),
25 26 27 28 29
        ),
      ),
    );
  }

30 31 32 33 34
  void _pushPage(BuildContext context, Page page) {
    Navigator.of(context).push(MaterialPageRoute<void>(
        builder: (_) => Scaffold(
              body: page,
            )));
35 36
  }
}