1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 13:58:47 +00:00

Samples maintenance (#435)

This commit is contained in:
Brett Morgan
2020-05-13 09:18:26 +10:00
committed by GitHub
parent 941ebebfad
commit baa1f976b2
94 changed files with 492 additions and 349 deletions

View File

@@ -1,4 +1,4 @@
include: package:pedantic/analysis_options.1.8.0.yaml
include: package:pedantic/analysis_options.1.9.0.yaml
analyzer:
strong-mode:

View File

@@ -128,6 +128,7 @@ final allRoutes = <String, WidgetBuilder>{
};
class AnimationSamples extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Animation Samples',
@@ -141,6 +142,7 @@ class AnimationSamples extends StatelessWidget {
}
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final headerStyle = Theme.of(context).textTheme.headline6;
return Scaffold(
@@ -164,6 +166,7 @@ class DemoTile extends StatelessWidget {
DemoTile(this.demo);
@override
Widget build(BuildContext context) {
return ListTile(
title: Text(demo.name),

View File

@@ -13,6 +13,7 @@ Color generateColor() => Color(0xFFFFFFFF & Random().nextInt(0xFFFFFFFF));
class AnimatedContainerDemo extends StatefulWidget {
static String routeName = '/basics/01_animated_container';
@override
_AnimatedContainerDemoState createState() => _AnimatedContainerDemoState();
}
@@ -21,6 +22,7 @@ class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
double borderRadius;
double margin;
@override
void initState() {
super.initState();
color = Colors.deepPurple;
@@ -36,6 +38,7 @@ class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
});
}
@override
Widget build(BuildContext context) {
// This widget is built using an AnimatedContainer, one of the easiest to use
// animated Widgets. Whenever the AnimatedContainer's properties, such as decoration,

View File

@@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
class PageRouteBuilderDemo extends StatelessWidget {
static const String routeName = '/basics/page_route_builder';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
@@ -38,6 +39,7 @@ Route _createRoute() {
}
class _Page2 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),

View File

@@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
class TweenDemo extends StatefulWidget {
static const String routeName = '/basics/tweens';
@override
_TweenDemoState createState() => _TweenDemoState();
}
@@ -17,6 +18,7 @@ class _TweenDemoState extends State<TweenDemo>
AnimationController controller;
Animation<double> animation;
@override
void initState() {
super.initState();
@@ -28,11 +30,13 @@ class _TweenDemoState extends State<TweenDemo>
animation = Tween(begin: 0.0, end: accountBalance).animate(controller);
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),

View File

@@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
class AnimatedBuilderDemo extends StatefulWidget {
static const String routeName = '/basics/animated_builder';
@override
_AnimatedBuilderDemoState createState() => _AnimatedBuilderDemoState();
}
@@ -18,6 +19,7 @@ class _AnimatedBuilderDemoState extends State<AnimatedBuilderDemo>
AnimationController controller;
Animation<Color> animation;
@override
void initState() {
super.initState();
@@ -26,11 +28,13 @@ class _AnimatedBuilderDemoState extends State<AnimatedBuilderDemo>
ColorTween(begin: beginColor, end: endColor).animate(controller);
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),

View File

@@ -8,6 +8,7 @@ class TypewriterTween extends Tween<String> {
TypewriterTween({String begin = '', String end})
: super(begin: begin, end: end);
@override
String lerp(double t) {
var cutoff = (end.length * t).round();
return end.substring(0, cutoff);
@@ -17,6 +18,7 @@ class TypewriterTween extends Tween<String> {
class CustomTweenDemo extends StatefulWidget {
static const String routeName = '/basics/custom_tweens';
@override
_CustomTweenDemoState createState() => _CustomTweenDemoState();
}
@@ -27,6 +29,7 @@ class _CustomTweenDemoState extends State<CustomTweenDemo>
AnimationController controller;
Animation<String> animation;
@override
void initState() {
super.initState();
@@ -34,11 +37,13 @@ class _CustomTweenDemoState extends State<CustomTweenDemo>
animation = TypewriterTween(end: message).animate(controller);
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(

View File

@@ -27,6 +27,7 @@ class _TweenSequenceDemoState extends State<TweenSequenceDemo>
Colors.purple,
];
@override
void initState() {
super.initState();
@@ -49,6 +50,7 @@ class _TweenSequenceDemoState extends State<TweenSequenceDemo>
animation = TweenSequence<Color>(sequenceItems).animate(controller);
}
@override
void dispose() {
controller.dispose();
super.dispose();

View File

@@ -8,6 +8,7 @@ import 'package:flutter/widgets.dart';
class AnimatedListDemo extends StatefulWidget {
static String routeName = '/misc/animated_list';
@override
_AnimatedListDemoState createState() => _AnimatedListDemoState();
}
@@ -17,9 +18,9 @@ class _AnimatedListDemoState extends State<AnimatedListDemo> {
void addUser() {
setState(() {
int index = listData.length;
var index = listData.length;
listData.add(
UserModel(firstName: "New", lastName: "Person"),
UserModel(firstName: 'New', lastName: 'Person'),
);
_listKey.currentState
.insertItem(index, duration: Duration(milliseconds: 300));
@@ -96,23 +97,23 @@ class UserModel {
List<UserModel> initialListData = [
UserModel(
firstName: "Govind",
lastName: "Dixit",
firstName: 'Govind',
lastName: 'Dixit',
),
UserModel(
firstName: "Greta",
lastName: "Stoll",
firstName: 'Greta',
lastName: 'Stoll',
),
UserModel(
firstName: "Monty",
lastName: "Carlo",
firstName: 'Monty',
lastName: 'Carlo',
),
UserModel(
firstName: "Petey",
lastName: "Cruiser",
firstName: 'Petey',
lastName: 'Cruiser',
),
UserModel(
firstName: "Barry",
lastName: "Cade",
firstName: 'Barry',
lastName: 'Cade',
),
];

View File

@@ -9,6 +9,7 @@ import 'package:flutter/material.dart';
class AnimatedPositionedDemo extends StatefulWidget {
static String routeName = '/basics/09_animated_positioned';
@override
_AnimatedPositionedDemoState createState() => _AnimatedPositionedDemoState();
}
@@ -20,6 +21,7 @@ class _AnimatedPositionedDemoState extends State<AnimatedPositionedDemo> {
double generateLeftPosition(double left) => Random().nextDouble() * left;
@override
void initState() {
super.initState();
topPosition = generateTopPosition(30);
@@ -33,6 +35,7 @@ class _AnimatedPositionedDemoState extends State<AnimatedPositionedDemo> {
});
}
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
final appBar = AppBar();
@@ -60,7 +63,7 @@ class _AnimatedPositionedDemoState extends State<AnimatedPositionedDemo> {
width: 150,
height: 50,
child: Text(
"Click Me",
'Click Me',
style: TextStyle(
color:
Theme.of(context).buttonTheme.colorScheme.onPrimary,

View File

@@ -25,6 +25,7 @@ Widget generateContainer(int keyCount) => Container(
class AnimatedSwitcherDemo extends StatefulWidget {
static String routeName = '/basics/10_animated_switcher';
@override
_AnimatedSwitcherDemoState createState() => _AnimatedSwitcherDemoState();
}
@@ -32,12 +33,14 @@ class _AnimatedSwitcherDemoState extends State<AnimatedSwitcherDemo> {
Widget container;
int keyCount;
@override
void initState() {
super.initState();
keyCount = 0;
container = generateContainer(keyCount);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
@@ -47,7 +50,7 @@ class _AnimatedSwitcherDemoState extends State<AnimatedSwitcherDemo> {
() => container = generateContainer(++keyCount),
),
child: Text(
"Change Widget",
'Change Widget',
style: TextStyle(
color: Theme.of(context).buttonTheme.colorScheme.onPrimary),
),

View File

@@ -17,6 +17,7 @@ class CardSwipeDemo extends StatefulWidget {
class _CardSwipeDemoState extends State<CardSwipeDemo> {
List<String> fileNames;
@override
void initState() {
super.initState();
_resetCards();
@@ -30,6 +31,7 @@ class _CardSwipeDemoState extends State<CardSwipeDemo> {
];
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
@@ -79,6 +81,7 @@ class Card extends StatelessWidget {
Card(this.imageAssetName);
@override
Widget build(BuildContext context) {
return AspectRatio(
aspectRatio: 3 / 5,
@@ -104,6 +107,7 @@ class SwipeableCard extends StatefulWidget {
this.imageAssetName,
});
@override
_SwipeableCardState createState() => _SwipeableCardState();
}
@@ -114,6 +118,7 @@ class _SwipeableCardState extends State<SwipeableCard>
double _dragStartX;
bool _isSwipingLeft = false;
@override
void initState() {
super.initState();
_controller = AnimationController.unbounded(vsync: this);
@@ -123,6 +128,7 @@ class _SwipeableCardState extends State<SwipeableCard>
));
}
@override
Widget build(BuildContext context) {
return SlideTransition(
position: _animation,
@@ -181,6 +187,7 @@ class _SwipeableCardState extends State<SwipeableCard>
});
}
@override
void dispose() {
_controller.dispose();
super.dispose();

View File

@@ -41,7 +41,7 @@ class CarouselDemo extends StatelessWidget {
}
}
typedef void OnCurrentItemChangedCallback(int currentItem);
typedef OnCurrentItemChangedCallback = void Function(int currentItem);
class Carousel extends StatefulWidget {
final IndexedWidgetBuilder itemBuilder;

View File

@@ -19,6 +19,7 @@ class ExpandCardDemo extends StatelessWidget {
}
class ExpandCard extends StatefulWidget {
@override
_ExpandCardState createState() => _ExpandCardState();
}

View File

@@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
class FocusImageDemo extends StatelessWidget {
static String routeName = '/misc/focus_image';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Focus Image')),
@@ -16,6 +17,7 @@ class FocusImageDemo extends StatelessWidget {
}
class Grid extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: GridView.builder(
@@ -68,6 +70,7 @@ class SmallCard extends StatelessWidget {
SmallCard(this.imageAssetName);
@override
Widget build(BuildContext context) {
return Card(
child: Material(
@@ -91,6 +94,7 @@ class _SecondPage extends StatelessWidget {
_SecondPage(this.imageAssetName);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,

View File

@@ -7,42 +7,42 @@ packages:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.11"
version: "2.0.13"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.2"
version: "1.6.0"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
version: "2.4.1"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
version: "2.0.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.2"
version: "1.1.3"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.11"
version: "1.14.12"
convert:
dependency: transitive
description:
@@ -56,7 +56,7 @@ packages:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
version: "2.1.4"
cupertino_icons:
dependency: "direct main"
description:
@@ -80,7 +80,7 @@ packages:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
version: "2.1.12"
matcher:
dependency: transitive
description:
@@ -108,7 +108,7 @@ packages:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0+1"
version: "1.9.0"
petitparser:
dependency: transitive
description:
@@ -122,7 +122,7 @@ packages:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
version: "2.1.3"
sky_engine:
dependency: transitive
description: flutter
@@ -134,7 +134,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.5"
version: "1.7.0"
stack_trace:
dependency: transitive
description:
@@ -169,7 +169,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.11"
version: "0.2.15"
typed_data:
dependency: transitive
description:
@@ -190,6 +190,6 @@ packages:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.5.0"
version: "3.6.1"
sdks:
dart: ">=2.5.0 <3.0.0"
dart: ">=2.6.0 <3.0.0"

View File

@@ -13,7 +13,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
pedantic: ^1.8.0
pedantic: ^1.9.0
flutter:
uses-material-design: true

View File

@@ -16,7 +16,7 @@ void main() {
await tester.pumpWidget(createExpandCardScreen());
// Get the initial size of ExpandCard.
Size initialSize = tester.getSize(find.byType(ExpandCard));
var initialSize = tester.getSize(find.byType(ExpandCard));
// Tap on the ExpandCard.
await tester.tap(find.byType(ExpandCard));
@@ -33,7 +33,7 @@ void main() {
testWidgets('ExpandCard changes image on tap', (tester) async {
await tester.pumpWidget(createExpandCardScreen());
Image initialImage = tester.widget(find.byType(Image).last);
var initialImage = tester.widget(find.byType(Image).last);
// Tap on ExpandCard.
await tester.tap(find.byType(ExpandCard));