flutter/dev/manual_tests/raw_keyboard.dart
Ian Hickson 1b9cd52081 Enable ALL THE LINTS
Well, all the easy ones, anyway.

For some reason `// ignore:` isn't working for me so I've disabled
lints that need that. Also disabled those that require a ton of work
(which I'm doing, but not in this PR, to keep it reviewable).

This adds:
- avoid_init_to_null
- library_names
- package_api_docs
- package_names
- package_prefixed_library_names
- prefer_is_not_empty
- sort_constructors_first
- sort_unnamed_constructors_first
- unnecessary_getters_setters
2016-03-10 23:15:31 -08:00

80 lines
2.0 KiB
Dart

// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:sky_services/sky/input_event.mojom.dart' as mojom;
GlobalKey _key = new GlobalKey();
void main() {
runApp(
new MaterialApp(
title: "Hardware Key Demo",
routes: <String, RouteBuilder>{
'/': (RouteArguments args) {
return new Scaffold(
toolBar: new ToolBar(
center: new Text("Hardware Key Demo")
),
body: new Material(
child: new RawKeyboardDemo(
key: _key
)
)
);
}
}
)
);
}
class RawKeyboardDemo extends StatefulComponent {
RawKeyboardDemo({ GlobalKey key }) : super(key: key);
_HardwareKeyDemoState createState() => new _HardwareKeyDemoState();
}
class _HardwareKeyDemoState extends State<RawKeyboardDemo> {
mojom.InputEvent _event;
void _handleKey(mojom.InputEvent event) {
setState(() {
_event = event;
});
}
Widget build(BuildContext context) {
bool focused = Focus.at(context);
Widget child;
if (!focused) {
child = new GestureDetector(
onTap: () {
Focus.moveTo(config.key);
},
child: new Center(
child: new Text('Tap to focus', style: Typography.black.display1)
)
);
} else if (_event == null) {
child = new Center(
child: new Text('Press a key', style: Typography.black.display1)
);
} else {
child = new Column(
children: <Widget>[
new Text('${_event.type}', style: Typography.black.body2),
new Text('${_event.keyData.keyCode}', style: Typography.black.display4)
],
justifyContent: FlexJustifyContent.center
);
}
return new RawKeyboardListener(
focused: focused,
onKey: _handleKey,
child: child
);
}
}