diff --git a/src/_includes/code/layout/tapbox-a/.gitignore b/src/_includes/code/layout/tapbox-a/.gitignore deleted file mode 100644 index 14c7d4c3f7..0000000000 --- a/src/_includes/code/layout/tapbox-a/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -.DS_Store -.atom/ -.idea -.packages -.pub/ -build/ -ios/.generated/ -packages -pubspec.lock diff --git a/src/_includes/code/layout/tapbox-a/main.dart b/src/_includes/code/layout/tapbox-a/main.dart deleted file mode 100644 index 526dff971d..0000000000 --- a/src/_includes/code/layout/tapbox-a/main.dart +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2017 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'; -// Uncomment lines 7 and 10 to view the visual layout at runtime. -//import 'package:flutter/rendering.dart' show debugPaintSizeEnabled; - -void main() { - //debugPaintSizeEnabled = true; - runApp(MyApp()); -} - -// TapboxA manages its own state. - -//------------------------- TapboxA ---------------------------------- - -class TapboxA extends StatefulWidget { - TapboxA({Key key}) : super(key: key); - - @override - _TapboxAState createState() => _TapboxAState(); -} - -class _TapboxAState extends State { - bool _active = false; - - void _handleTap() { - setState(() { - _active = !_active; - }); - } - - Widget build(BuildContext context) { - return GestureDetector( - onTap: _handleTap, - child: Container( - child: Center( - child: Text( - _active ? 'Active' : 'Inactive', - style: TextStyle(fontSize: 32.0, color: Colors.white), - ), - ), - width: 200.0, - height: 200.0, - decoration: BoxDecoration( - color: _active ? Colors.lightGreen[700] : Colors.grey[600], - ), - ), - ); - } -} - -//------------------------- MyApp ---------------------------------- - -class MyApp extends StatelessWidget { - @override - Widget build(BuildContext context) { - return MaterialApp( - title: 'Flutter Demo', - home: Scaffold( - appBar: AppBar( - title: Text('Flutter Demo'), - ), - body: Center( - child: TapboxA(), - ), - ), - ); - } -} diff --git a/src/_includes/code/layout/tapbox-a/pubspec.yaml b/src/_includes/code/layout/tapbox-a/pubspec.yaml deleted file mode 100644 index 055efa27f8..0000000000 --- a/src/_includes/code/layout/tapbox-a/pubspec.yaml +++ /dev/null @@ -1,9 +0,0 @@ -name: tapbox_a -description: Demonstrates a stateful widget that manages its own state. - -dependencies: - flutter: - sdk: flutter - -flutter: - uses-material-design: true diff --git a/src/_includes/code/layout/tapbox-b/.gitignore b/src/_includes/code/layout/tapbox-b/.gitignore deleted file mode 100644 index 14c7d4c3f7..0000000000 --- a/src/_includes/code/layout/tapbox-b/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -.DS_Store -.atom/ -.idea -.packages -.pub/ -build/ -ios/.generated/ -packages -pubspec.lock diff --git a/src/_includes/code/layout/tapbox-b/main.dart b/src/_includes/code/layout/tapbox-b/main.dart deleted file mode 100644 index 8405271a63..0000000000 --- a/src/_includes/code/layout/tapbox-b/main.dart +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2017 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:flutter/foundation.dart'; - -void main() { - runApp(MyApp()); -} - -// ParentWidget manages the state for TapboxB. - -//------------------------ ParentWidget -------------------------------- - -class ParentWidget extends StatefulWidget { - @override - _ParentWidgetState createState() => _ParentWidgetState(); -} - -class _ParentWidgetState extends State { - bool _active = false; - - void _handleTapboxChanged(bool newValue) { - setState(() { - _active = newValue; - }); - } - - @override - Widget build(BuildContext context) { - return Container( - child: TapboxB( - active: _active, - onChanged: _handleTapboxChanged, - ), - ); - } -} - -//------------------------- TapboxB ---------------------------------- - -class TapboxB extends StatelessWidget { - TapboxB({Key key, this.active: false, @required this.onChanged}) - : super(key: key); - - final bool active; - final ValueChanged onChanged; - - void _handleTap() { - onChanged(!active); - } - - Widget build(BuildContext context) { - return GestureDetector( - onTap: _handleTap, - child: Container( - child: Center( - child: Text( - active ? 'Active' : 'Inactive', - style: TextStyle(fontSize: 32.0, color: Colors.white), - ), - ), - width: 200.0, - height: 200.0, - decoration: BoxDecoration( - color: active ? Colors.lightGreen[700] : Colors.grey[600], - ), - ), - ); - } -} - -//------------------------- MyApp -------------------------------------- - -class MyApp extends StatelessWidget { - @override - Widget build(BuildContext context) { - return MaterialApp( - title: 'Flutter Demo', - home: Scaffold( - appBar: AppBar( - title: Text('Flutter Demo'), - ), - body: Center( - child: ParentWidget(), - ), - ), - ); - } -} diff --git a/src/_includes/code/layout/tapbox-b/pubspec.yaml b/src/_includes/code/layout/tapbox-b/pubspec.yaml deleted file mode 100644 index f166e4691f..0000000000 --- a/src/_includes/code/layout/tapbox-b/pubspec.yaml +++ /dev/null @@ -1,9 +0,0 @@ -name: tapbox_b -description: Demonstrates a stateful widget whose parent manages its state. - -dependencies: - flutter: - sdk: flutter - -flutter: - uses-material-design: true diff --git a/src/_includes/code/layout/tapbox-c/.gitignore b/src/_includes/code/layout/tapbox-c/.gitignore deleted file mode 100644 index 14c7d4c3f7..0000000000 --- a/src/_includes/code/layout/tapbox-c/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -.DS_Store -.atom/ -.idea -.packages -.pub/ -build/ -ios/.generated/ -packages -pubspec.lock diff --git a/src/_includes/code/layout/tapbox-c/main.dart b/src/_includes/code/layout/tapbox-c/main.dart deleted file mode 100644 index fb48086833..0000000000 --- a/src/_includes/code/layout/tapbox-c/main.dart +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright 2017 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:flutter/foundation.dart'; - -void main() { - runApp(MyApp()); -} - -//---------------------------- ParentWidget ---------------------------- - -class ParentWidget extends StatefulWidget { - @override - _ParentWidgetState createState() => _ParentWidgetState(); -} - -class _ParentWidgetState extends State { - bool _active = false; - - void _handleTapboxChanged(bool newValue) { - setState(() { - _active = newValue; - }); - } - - @override - Widget build(BuildContext context) { - return Container( - child: TapboxC( - active: _active, - onChanged: _handleTapboxChanged, - ), - ); - } -} - -//----------------------------- TapboxC ------------------------------ - -class TapboxC extends StatefulWidget { - TapboxC({Key key, this.active: false, @required this.onChanged}) - : super(key: key); - - final bool active; - final ValueChanged onChanged; - - _TapboxCState createState() => _TapboxCState(); -} - -class _TapboxCState extends State { - bool _highlight = false; - - void _handleTapDown(TapDownDetails details) { - setState(() { - _highlight = true; - }); - } - - void _handleTapUp(TapUpDetails details) { - setState(() { - _highlight = false; - }); - } - - void _handleTapCancel() { - setState(() { - _highlight = false; - }); - } - - void _handleTap() { - widget.onChanged(!widget.active); - } - - Widget build(BuildContext context) { - // This example adds a green border on tap down. - // On tap up, the square changes to the opposite state. - return GestureDetector( - onTapDown: _handleTapDown, // Handle the tap events in the order that - onTapUp: _handleTapUp, // they occur: down, up, tap, cancel - onTap: _handleTap, - onTapCancel: _handleTapCancel, - child: Container( - child: Center( - child: Text( - widget.active ? 'Active' : 'Inactive', - style: TextStyle(fontSize: 32.0, color: Colors.white), - ), - ), - width: 200.0, - height: 200.0, - decoration: BoxDecoration( - color: - widget.active ? Colors.lightGreen[700] : Colors.grey[600], - border: _highlight - ? Border.all( - color: Colors.teal[700], - width: 10.0, - ) - : null, - ), - ), - ); - } -} - -//------------------------------- MyApp -------------------------------- - -class MyApp extends StatelessWidget { - @override - Widget build(BuildContext context) { - return MaterialApp( - title: 'Flutter Demo', - home: Scaffold( - appBar: AppBar( - title: Text('Flutter Demo'), - ), - body: Center( - child: ParentWidget(), - ), - ), - ); - } -} diff --git a/src/_includes/code/layout/tapbox-c/pubspec.yaml b/src/_includes/code/layout/tapbox-c/pubspec.yaml deleted file mode 100644 index eff42c4f64..0000000000 --- a/src/_includes/code/layout/tapbox-c/pubspec.yaml +++ /dev/null @@ -1,9 +0,0 @@ -name: tapbox_c -description: Demonstrates some state handled by the parent and some state handled by the stateful widget. - -dependencies: - flutter: - sdk: flutter - -flutter: - uses-material-design: true