mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 22:09:06 +00:00
update slide_puzzle (#420)
* update slide_puzzle * run createThumbnails before build-release grind task * add license headers
This commit is contained in:
@@ -23,7 +23,7 @@ void analyze() {
|
||||
}
|
||||
|
||||
@Task('deploy')
|
||||
@Depends(analyze, testCli, generate, createThumbnails, buildRelease)
|
||||
@Depends(analyze, testCli, generate, buildRelease)
|
||||
void deploy() {
|
||||
print('All tasks completed. To deploy to Firebase, run:');
|
||||
print('');
|
||||
@@ -32,9 +32,10 @@ void deploy() {
|
||||
}
|
||||
|
||||
@Task('Run build_runner to public/ directory')
|
||||
@Depends(createThumbnails)
|
||||
Future buildRelease() async {
|
||||
var app = PubApp.local('build_runner');
|
||||
await app.runAsync('build --release --output web:public'.split(' ').toList());
|
||||
await app.runAsync('build --release --output web:public --delete-conflicting-outputs'.split(' ').toList());
|
||||
}
|
||||
|
||||
@DefaultTask('Build the project.')
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'src/core/puzzle_animator.dart';
|
||||
import 'src/flutter.dart';
|
||||
import 'src/puzzle_home_state.dart';
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. 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/foundation.dart';
|
||||
|
||||
import 'core/puzzle_proxy.dart';
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'dart:math' show Point;
|
||||
|
||||
const zeroPoint = Point<double>(0, 0);
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'dart:math' as math;
|
||||
|
||||
class Point extends math.Point<int> {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'dart:collection';
|
||||
import 'dart:convert';
|
||||
import 'dart:math' show Random, max;
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:math' show Point, Random;
|
||||
|
||||
|
||||
25
web/slide_puzzle/lib/src/core/puzzle_proxy.dart
Normal file
25
web/slide_puzzle/lib/src/core/puzzle_proxy.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'dart:math' show Point;
|
||||
|
||||
enum PuzzleEvent { click, random, reset, noop }
|
||||
|
||||
abstract class PuzzleProxy {
|
||||
int get width;
|
||||
|
||||
int get height;
|
||||
|
||||
int get length;
|
||||
|
||||
bool get solved;
|
||||
|
||||
void clickOrShake(int tileValue);
|
||||
|
||||
int get tileCount;
|
||||
|
||||
Point<double> location(int index);
|
||||
|
||||
bool isCorrectPosition(int value);
|
||||
}
|
||||
@@ -1,3 +1,7 @@
|
||||
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of 'puzzle.dart';
|
||||
|
||||
class _PuzzleSimple extends Puzzle {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of 'puzzle.dart';
|
||||
|
||||
mixin _SliceListMixin on ListMixin<int> {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
void requireArgument(bool truth, String argName, [String message]) {
|
||||
if (!truth) {
|
||||
if (message == null || message.isEmpty) {
|
||||
|
||||
6
web/slide_puzzle/lib/src/flutter.dart
Normal file
6
web/slide_puzzle/lib/src/flutter.dart
Normal file
@@ -0,0 +1,6 @@
|
||||
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
export 'package:flutter/material.dart';
|
||||
export 'package:flutter/scheduler.dart' show Ticker;
|
||||
17
web/slide_puzzle/lib/src/puzzle_controls.dart
Normal file
17
web/slide_puzzle/lib/src/puzzle_controls.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. 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/foundation.dart';
|
||||
|
||||
abstract class PuzzleControls implements Listenable {
|
||||
void reset();
|
||||
|
||||
int get clickCount;
|
||||
|
||||
int get incorrectTiles;
|
||||
|
||||
bool get autoPlay;
|
||||
|
||||
void Function(bool newValue) get setAutoPlayFunction;
|
||||
}
|
||||
@@ -1,3 +1,7 @@
|
||||
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'core/puzzle_proxy.dart';
|
||||
import 'flutter.dart';
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'core/puzzle_proxy.dart';
|
||||
import 'flutter.dart';
|
||||
import 'puzzle_controls.dart';
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'core/puzzle_proxy.dart';
|
||||
import 'flutter.dart';
|
||||
import 'shared_theme.dart';
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'core/puzzle_proxy.dart';
|
||||
import 'flutter.dart';
|
||||
import 'shared_theme.dart';
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'core/puzzle_proxy.dart';
|
||||
import 'flutter.dart';
|
||||
import 'shared_theme.dart';
|
||||
|
||||
13
web/slide_puzzle/lib/src/themes.dart
Normal file
13
web/slide_puzzle/lib/src/themes.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'theme_plaster.dart';
|
||||
import 'theme_seattle.dart';
|
||||
import 'theme_simple.dart';
|
||||
|
||||
const themes = [
|
||||
ThemeSimple(),
|
||||
ThemeSeattle(),
|
||||
ThemePlaster(),
|
||||
];
|
||||
92
web/slide_puzzle/lib/src/value_tab_controller.dart
Normal file
92
web/slide_puzzle/lib/src/value_tab_controller.dart
Normal file
@@ -0,0 +1,92 @@
|
||||
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. 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:provider/provider.dart';
|
||||
|
||||
class ValueTabController<T> extends StatefulWidget {
|
||||
/// Creates a default tab controller for the given [child] widget.
|
||||
const ValueTabController({
|
||||
Key key,
|
||||
@required this.child,
|
||||
@required this.values,
|
||||
}) : super(key: key);
|
||||
|
||||
/// The widget below this widget in the tree.
|
||||
///
|
||||
/// Typically a [Scaffold] whose [AppBar] includes a [TabBar].
|
||||
///
|
||||
/// {@macro flutter.widgets.child}
|
||||
final Widget child;
|
||||
|
||||
final List<T> values;
|
||||
|
||||
/// The closest instance of this class that encloses the given context.
|
||||
///
|
||||
/// Typical usage:
|
||||
///
|
||||
/// ```dart
|
||||
/// TabController controller = DefaultTabBarController.of(context);
|
||||
/// ```
|
||||
static TabController of(BuildContext context) {
|
||||
final scope = context.inheritFromWidgetOfExactType(_ValueTabControllerScope)
|
||||
as _ValueTabControllerScope;
|
||||
return scope?.controller;
|
||||
}
|
||||
|
||||
@override
|
||||
_ValueTabControllerState<T> createState() => _ValueTabControllerState<T>();
|
||||
}
|
||||
|
||||
class _ValueTabControllerState<T> extends State<ValueTabController<T>>
|
||||
with SingleTickerProviderStateMixin {
|
||||
final _notifier = ValueNotifier<T>(null);
|
||||
|
||||
TabController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = TabController(
|
||||
vsync: this,
|
||||
length: widget.values.length,
|
||||
initialIndex: 0,
|
||||
);
|
||||
|
||||
_notifier.value = widget.values.first;
|
||||
|
||||
_controller.addListener(() {
|
||||
_notifier.value = widget.values[_controller.index];
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => _ValueTabControllerScope(
|
||||
controller: _controller,
|
||||
enabled: TickerMode.of(context),
|
||||
child: ValueListenableProvider.value(
|
||||
valueListenable: _notifier,
|
||||
child: widget.child,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class _ValueTabControllerScope extends InheritedWidget {
|
||||
const _ValueTabControllerScope(
|
||||
{Key key, this.controller, this.enabled, Widget child})
|
||||
: super(key: key, child: child);
|
||||
|
||||
final TabController controller;
|
||||
final bool enabled;
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(_ValueTabControllerScope old) =>
|
||||
enabled != old.enabled || controller != old.controller;
|
||||
}
|
||||
@@ -1,3 +1,7 @@
|
||||
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// ignore_for_file: omit_local_variable_types, annotate_overrides
|
||||
|
||||
import 'dart:developer' as developer;
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import '../flutter.dart';
|
||||
|
||||
// Copied from
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
# Generated by pub
|
||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||
packages:
|
||||
_fe_analyzer_shared:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: _fe_analyzer_shared
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
analyzer:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: analyzer
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.36.4"
|
||||
version: "0.39.7"
|
||||
archive:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -88,13 +95,6 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
front_end:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: front_end
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.19"
|
||||
glob:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -115,21 +115,21 @@ packages:
|
||||
name: http
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.12.0+2"
|
||||
version: "0.12.0+4"
|
||||
http_multi_server:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http_multi_server
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
version: "2.2.0"
|
||||
http_parser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http_parser
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.1.3"
|
||||
version: "3.1.4"
|
||||
image:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -143,7 +143,7 @@ packages:
|
||||
name: io
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.3.3"
|
||||
version: "0.3.4"
|
||||
js:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -151,13 +151,6 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.6.1+1"
|
||||
kernel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: kernel
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.3.19"
|
||||
logging:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -221,13 +214,6 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.9.3"
|
||||
package_resolver:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: package_resolver
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.10"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -241,7 +227,7 @@ packages:
|
||||
name: pedantic
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.0+1"
|
||||
version: "1.9.0"
|
||||
petitparser:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -269,7 +255,7 @@ packages:
|
||||
name: pub_semver
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.4.2"
|
||||
version: "1.4.4"
|
||||
quiver:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -290,7 +276,7 @@ packages:
|
||||
name: shelf_packages_handler
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
version: "2.0.0"
|
||||
shelf_static:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -323,7 +309,7 @@ packages:
|
||||
name: source_maps
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.10.8"
|
||||
version: "0.10.9"
|
||||
source_span:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -407,7 +393,7 @@ packages:
|
||||
name: watcher
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.9.7+12"
|
||||
version: "0.9.7+15"
|
||||
web_socket_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
Reference in New Issue
Block a user