mirror of
https://github.com/flutter/samples.git
synced 2025-11-12 15:58:32 +00:00
Samples maintenance (#435)
This commit is contained in:
@@ -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',
|
||||
),
|
||||
];
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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),
|
||||
),
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -19,6 +19,7 @@ class ExpandCardDemo extends StatelessWidget {
|
||||
}
|
||||
|
||||
class ExpandCard extends StatefulWidget {
|
||||
@override
|
||||
_ExpandCardState createState() => _ExpandCardState();
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user