mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Landing beta changes in master for the new stable release (#747)
This commit is contained in:
@@ -9,11 +9,7 @@
|
||||
/* Begin PBXBuildFile section */
|
||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
||||
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
|
||||
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
|
||||
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
|
||||
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
||||
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
|
||||
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
|
||||
@@ -26,8 +22,6 @@
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
|
||||
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
|
||||
);
|
||||
name = "Embed Frameworks";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -38,13 +32,11 @@
|
||||
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
|
||||
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
|
||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
||||
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
|
||||
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
|
||||
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
|
||||
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
|
||||
9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = "<group>"; };
|
||||
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
@@ -57,8 +49,6 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
|
||||
3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -68,9 +58,7 @@
|
||||
9740EEB11CF90186004384FC /* Flutter */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3B80C3931E831B6300D905FE /* App.framework */,
|
||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
|
||||
9740EEBA1CF902C7004384FC /* Flutter.framework */,
|
||||
9740EEB21CF90195004384FC /* Debug.xcconfig */,
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
|
||||
9740EEB31CF90195004384FC /* Generated.xcconfig */,
|
||||
@@ -201,7 +189,7 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
|
||||
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
|
||||
};
|
||||
9740EEB61CF901F6004384FC /* Run Script */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
@@ -253,7 +241,6 @@
|
||||
/* Begin XCBuildConfiguration section */
|
||||
249021D3217E4FDB00AE95B9 /* Profile */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
@@ -330,7 +317,6 @@
|
||||
};
|
||||
97C147031CF9000F007C117D /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
@@ -386,7 +372,6 @@
|
||||
};
|
||||
97C147041CF9000F007C117D /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:Runner.xcodeproj">
|
||||
location = "self:">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
|
||||
@@ -31,7 +31,11 @@ class Demo {
|
||||
final String route;
|
||||
final WidgetBuilder builder;
|
||||
|
||||
const Demo({this.name, this.route, this.builder});
|
||||
const Demo({
|
||||
required this.name,
|
||||
required this.route,
|
||||
required this.builder,
|
||||
});
|
||||
}
|
||||
|
||||
final basicDemos = [
|
||||
|
||||
@@ -18,9 +18,9 @@ class AnimatedContainerDemo extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
|
||||
Color color;
|
||||
double borderRadius;
|
||||
double margin;
|
||||
late Color color;
|
||||
late double borderRadius;
|
||||
late double margin;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
||||
@@ -20,7 +20,7 @@ class _AnimationControllerDemoState extends State<AnimationControllerDemo>
|
||||
// Widget is not visible.
|
||||
|
||||
static const Duration _duration = Duration(seconds: 1);
|
||||
AnimationController controller;
|
||||
late final AnimationController controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
||||
@@ -15,8 +15,8 @@ class _TweenDemoState extends State<TweenDemo>
|
||||
with SingleTickerProviderStateMixin {
|
||||
static const Duration _duration = Duration(seconds: 1);
|
||||
static const double accountBalance = 1000000;
|
||||
AnimationController controller;
|
||||
Animation<double> animation;
|
||||
late final AnimationController controller;
|
||||
late final Animation<double> animation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
||||
@@ -16,8 +16,8 @@ class _AnimatedBuilderDemoState extends State<AnimatedBuilderDemo>
|
||||
static const Color beginColor = Colors.deepPurple;
|
||||
static const Color endColor = Colors.deepOrange;
|
||||
Duration duration = Duration(milliseconds: 800);
|
||||
AnimationController controller;
|
||||
Animation<Color> animation;
|
||||
late AnimationController controller;
|
||||
late Animation<Color?> animation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class TypewriterTween extends Tween<String> {
|
||||
TypewriterTween({String begin = '', String end})
|
||||
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);
|
||||
var cutoff = (end!.length * t).round();
|
||||
return end!.substring(0, cutoff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ class _CustomTweenDemoState extends State<CustomTweenDemo>
|
||||
with SingleTickerProviderStateMixin {
|
||||
static const Duration _duration = Duration(seconds: 3);
|
||||
static const String message = loremIpsum;
|
||||
AnimationController controller;
|
||||
Animation<String> animation;
|
||||
late final AnimationController controller;
|
||||
late final Animation<String> animation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
||||
@@ -14,8 +14,8 @@ class TweenSequenceDemo extends StatefulWidget {
|
||||
class _TweenSequenceDemoState extends State<TweenSequenceDemo>
|
||||
with SingleTickerProviderStateMixin {
|
||||
static const Duration duration = Duration(seconds: 3);
|
||||
AnimationController controller;
|
||||
Animation<Color> animation;
|
||||
late final AnimationController controller;
|
||||
late final Animation<Color?> animation;
|
||||
|
||||
static final colors = [
|
||||
Colors.red,
|
||||
@@ -31,7 +31,7 @@ class _TweenSequenceDemoState extends State<TweenSequenceDemo>
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
final sequenceItems = <TweenSequenceItem<Color>>[];
|
||||
final sequenceItems = <TweenSequenceItem<Color?>>[];
|
||||
|
||||
for (var i = 0; i < colors.length; i++) {
|
||||
final beginColor = colors[i];
|
||||
@@ -39,7 +39,7 @@ class _TweenSequenceDemoState extends State<TweenSequenceDemo>
|
||||
final weight = 1 / colors.length;
|
||||
|
||||
sequenceItems.add(
|
||||
TweenSequenceItem<Color>(
|
||||
TweenSequenceItem<Color?>(
|
||||
tween: ColorTween(begin: beginColor, end: endColor),
|
||||
weight: weight,
|
||||
),
|
||||
@@ -47,7 +47,7 @@ class _TweenSequenceDemoState extends State<TweenSequenceDemo>
|
||||
}
|
||||
|
||||
controller = AnimationController(duration: duration, vsync: this);
|
||||
animation = TweenSequence<Color>(sequenceItems).animate(controller);
|
||||
animation = TweenSequence<Color?>(sequenceItems).animate(controller);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -15,9 +15,9 @@ class FadeTransitionDemo extends StatefulWidget {
|
||||
|
||||
class _FadeTransitionDemoState extends State<FadeTransitionDemo>
|
||||
with SingleTickerProviderStateMixin {
|
||||
AnimationController _controller;
|
||||
Animation<double> _animation;
|
||||
CurvedAnimation _curve;
|
||||
late final AnimationController _controller;
|
||||
late final Animation<double> _animation;
|
||||
late final CurvedAnimation _curve;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
||||
@@ -14,23 +14,31 @@ class AnimatedListDemo extends StatefulWidget {
|
||||
|
||||
class _AnimatedListDemoState extends State<AnimatedListDemo> {
|
||||
final GlobalKey<AnimatedListState> _listKey = GlobalKey();
|
||||
final listData = initialListData;
|
||||
final listData = [
|
||||
UserModel(0, 'Govind', 'Dixit'),
|
||||
UserModel(1, 'Greta', 'Stoll'),
|
||||
UserModel(2, 'Monty', 'Carlo'),
|
||||
UserModel(3, 'Petey', 'Cruiser'),
|
||||
UserModel(4, 'Barry', 'Cade'),
|
||||
];
|
||||
final initialListSize = 5;
|
||||
|
||||
void addUser() {
|
||||
setState(() {
|
||||
var index = listData.length;
|
||||
listData.add(
|
||||
UserModel(firstName: 'New', lastName: 'Person'),
|
||||
UserModel(++_maxIdValue, 'New', 'Person'),
|
||||
);
|
||||
_listKey.currentState
|
||||
_listKey.currentState!
|
||||
.insertItem(index, duration: Duration(milliseconds: 300));
|
||||
});
|
||||
}
|
||||
|
||||
void deleteUser(int index) {
|
||||
void deleteUser(int id) {
|
||||
setState(() {
|
||||
final index = listData.indexWhere((u) => u.id == id);
|
||||
var user = listData.removeAt(index);
|
||||
_listKey.currentState.removeItem(
|
||||
_listKey.currentState!.removeItem(
|
||||
index,
|
||||
(context, animation) {
|
||||
return FadeTransition(
|
||||
@@ -49,7 +57,7 @@ class _AnimatedListDemoState extends State<AnimatedListDemo> {
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildItem(UserModel user, [int index]) {
|
||||
Widget _buildItem(UserModel user) {
|
||||
return ListTile(
|
||||
key: ValueKey<UserModel>(user),
|
||||
title: Text(user.firstName),
|
||||
@@ -59,7 +67,7 @@ class _AnimatedListDemoState extends State<AnimatedListDemo> {
|
||||
),
|
||||
trailing: IconButton(
|
||||
icon: Icon(Icons.delete),
|
||||
onPressed: () => deleteUser(index),
|
||||
onPressed: () => deleteUser(user.id),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -79,11 +87,11 @@ class _AnimatedListDemoState extends State<AnimatedListDemo> {
|
||||
body: SafeArea(
|
||||
child: AnimatedList(
|
||||
key: _listKey,
|
||||
initialItemCount: initialListData.length,
|
||||
initialItemCount: 5,
|
||||
itemBuilder: (context, index, animation) {
|
||||
return FadeTransition(
|
||||
opacity: animation,
|
||||
child: _buildItem(listData[index], index),
|
||||
child: _buildItem(listData[index]),
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -93,31 +101,15 @@ class _AnimatedListDemoState extends State<AnimatedListDemo> {
|
||||
}
|
||||
|
||||
class UserModel {
|
||||
const UserModel({this.firstName, this.lastName});
|
||||
UserModel(
|
||||
this.id,
|
||||
this.firstName,
|
||||
this.lastName,
|
||||
);
|
||||
|
||||
final int id;
|
||||
final String firstName;
|
||||
final String lastName;
|
||||
}
|
||||
|
||||
List<UserModel> initialListData = [
|
||||
UserModel(
|
||||
firstName: 'Govind',
|
||||
lastName: 'Dixit',
|
||||
),
|
||||
UserModel(
|
||||
firstName: 'Greta',
|
||||
lastName: 'Stoll',
|
||||
),
|
||||
UserModel(
|
||||
firstName: 'Monty',
|
||||
lastName: 'Carlo',
|
||||
),
|
||||
UserModel(
|
||||
firstName: 'Petey',
|
||||
lastName: 'Cruiser',
|
||||
),
|
||||
UserModel(
|
||||
firstName: 'Barry',
|
||||
lastName: 'Cade',
|
||||
),
|
||||
];
|
||||
int _maxIdValue = 4;
|
||||
|
||||
@@ -14,8 +14,8 @@ class AnimatedPositionedDemo extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _AnimatedPositionedDemoState extends State<AnimatedPositionedDemo> {
|
||||
double topPosition;
|
||||
double leftPosition;
|
||||
late double topPosition;
|
||||
late double leftPosition;
|
||||
|
||||
double generateTopPosition(double top) => Random().nextDouble() * top;
|
||||
|
||||
@@ -41,40 +41,38 @@ class _AnimatedPositionedDemoState extends State<AnimatedPositionedDemo> {
|
||||
final appBar = AppBar(title: Text('AnimatedPositioned'));
|
||||
final topPadding = MediaQuery.of(context).padding.top;
|
||||
// AnimatedPositioned animates changes to a widget's position within a Stack
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: appBar,
|
||||
body: Container(
|
||||
height: size.height,
|
||||
width: size.width,
|
||||
child: Stack(
|
||||
children: [
|
||||
AnimatedPositioned(
|
||||
top: topPosition,
|
||||
left: leftPosition,
|
||||
duration: Duration(seconds: 1),
|
||||
child: InkWell(
|
||||
onTap: () => changePosition(
|
||||
size.height -
|
||||
(appBar.preferredSize.height + topPadding + 50),
|
||||
size.width - 150),
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
width: 150,
|
||||
height: 50,
|
||||
child: Text(
|
||||
'Click Me',
|
||||
style: TextStyle(
|
||||
color:
|
||||
Theme.of(context).buttonTheme.colorScheme.onPrimary,
|
||||
),
|
||||
return Scaffold(
|
||||
appBar: appBar,
|
||||
body: Container(
|
||||
height: size.height,
|
||||
width: size.width,
|
||||
child: Stack(
|
||||
children: [
|
||||
AnimatedPositioned(
|
||||
top: topPosition,
|
||||
left: leftPosition,
|
||||
duration: Duration(seconds: 1),
|
||||
child: InkWell(
|
||||
onTap: () => changePosition(
|
||||
size.height -
|
||||
(appBar.preferredSize.height + topPadding + 50),
|
||||
size.width - 150),
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
width: 150,
|
||||
height: 50,
|
||||
child: Text(
|
||||
'Click Me',
|
||||
style: TextStyle(
|
||||
color:
|
||||
Theme.of(context).buttonTheme.colorScheme!.onPrimary,
|
||||
),
|
||||
color: Theme.of(context).primaryColor,
|
||||
),
|
||||
color: Theme.of(context).primaryColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -30,8 +30,8 @@ class AnimatedSwitcherDemo extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _AnimatedSwitcherDemoState extends State<AnimatedSwitcherDemo> {
|
||||
Widget container;
|
||||
int keyCount;
|
||||
late Widget container;
|
||||
late int keyCount;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -53,7 +53,7 @@ class _AnimatedSwitcherDemoState extends State<AnimatedSwitcherDemo> {
|
||||
child: Text(
|
||||
'Change Widget',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).buttonTheme.colorScheme.onPrimary),
|
||||
color: Theme.of(context).buttonTheme.colorScheme!.onPrimary),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -15,7 +15,7 @@ class CardSwipeDemo extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _CardSwipeDemoState extends State<CardSwipeDemo> {
|
||||
List<String> fileNames;
|
||||
late List<String> fileNames;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -102,8 +102,8 @@ class SwipeableCard extends StatefulWidget {
|
||||
final VoidCallback onSwiped;
|
||||
|
||||
SwipeableCard({
|
||||
this.onSwiped,
|
||||
this.imageAssetName,
|
||||
required this.onSwiped,
|
||||
required this.imageAssetName,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -112,9 +112,9 @@ class SwipeableCard extends StatefulWidget {
|
||||
|
||||
class _SwipeableCardState extends State<SwipeableCard>
|
||||
with SingleTickerProviderStateMixin {
|
||||
AnimationController _controller;
|
||||
Animation<Offset> _animation;
|
||||
double _dragStartX;
|
||||
late AnimationController _controller;
|
||||
late Animation<Offset> _animation;
|
||||
late double _dragStartX;
|
||||
bool _isSwipingLeft = false;
|
||||
|
||||
@override
|
||||
@@ -155,18 +155,29 @@ class _SwipeableCardState extends State<SwipeableCard>
|
||||
}
|
||||
|
||||
setState(() {
|
||||
final size = context.size;
|
||||
|
||||
if (size == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate the amount dragged in unit coordinates (between 0 and 1)
|
||||
// using this widgets width.
|
||||
_controller.value =
|
||||
(details.localPosition.dx - _dragStartX).abs() / context.size.width;
|
||||
(details.localPosition.dx - _dragStartX).abs() / size.width;
|
||||
});
|
||||
}
|
||||
|
||||
/// Runs the fling / spring animation using the final velocity of the drag
|
||||
/// gesture.
|
||||
void _dragEnd(DragEndDetails details) {
|
||||
var velocity =
|
||||
(details.velocity.pixelsPerSecond.dx / context.size.width).abs();
|
||||
final size = context.size;
|
||||
|
||||
if (size == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var velocity = (details.velocity.pixelsPerSecond.dx / size.width).abs();
|
||||
_animate(velocity: velocity);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,15 +46,15 @@ typedef OnCurrentItemChangedCallback = void Function(int currentItem);
|
||||
class Carousel extends StatefulWidget {
|
||||
final IndexedWidgetBuilder itemBuilder;
|
||||
|
||||
const Carousel({Key key, @required this.itemBuilder});
|
||||
const Carousel({Key? key, required this.itemBuilder}) : super(key: key);
|
||||
|
||||
@override
|
||||
_CarouselState createState() => _CarouselState();
|
||||
}
|
||||
|
||||
class _CarouselState extends State<Carousel> {
|
||||
PageController _controller;
|
||||
int _currentPage;
|
||||
late final PageController _controller;
|
||||
late int _currentPage;
|
||||
bool _pageHasChanged = false;
|
||||
|
||||
@override
|
||||
@@ -81,11 +81,11 @@ class _CarouselState extends State<Carousel> {
|
||||
itemBuilder: (context, index) => AnimatedBuilder(
|
||||
animation: _controller,
|
||||
builder: (context, child) {
|
||||
var result = _pageHasChanged ? _controller.page : _currentPage * 1.0;
|
||||
var result = _pageHasChanged ? _controller.page! : _currentPage * 1.0;
|
||||
|
||||
// The horizontal position of the page between a 1 and 0
|
||||
var value = result - index;
|
||||
value = (1 - (value.abs() * .5)).clamp(0.0, 1.0) as double;
|
||||
value = (1 - (value.abs() * .5)).clamp(0.0, 1.0);
|
||||
|
||||
return Center(
|
||||
child: SizedBox(
|
||||
|
||||
@@ -15,14 +15,15 @@ class CurvedAnimationDemo extends StatefulWidget {
|
||||
class CurveChoice {
|
||||
final Curve curve;
|
||||
final String name;
|
||||
const CurveChoice({this.curve, this.name});
|
||||
|
||||
const CurveChoice({required this.curve, required this.name});
|
||||
}
|
||||
|
||||
class _CurvedAnimationDemoState extends State<CurvedAnimationDemo>
|
||||
with SingleTickerProviderStateMixin {
|
||||
AnimationController controller;
|
||||
Animation<double> animationRotation;
|
||||
Animation<Offset> animationTranslation;
|
||||
late final AnimationController controller;
|
||||
late final Animation<double> animationRotation;
|
||||
late final Animation<Offset> animationTranslation;
|
||||
static const _duration = Duration(seconds: 4);
|
||||
List<CurveChoice> curves = [
|
||||
CurveChoice(curve: Curves.bounceIn, name: 'Bounce In'),
|
||||
@@ -38,8 +39,8 @@ class _CurvedAnimationDemoState extends State<CurvedAnimationDemo>
|
||||
CurveChoice(curve: Curves.easeInCirc, name: 'Ease In Circle'),
|
||||
CurveChoice(curve: Curves.easeOutCirc, name: 'Ease Out Circle'),
|
||||
];
|
||||
CurveChoice selectedForwardCurve, selectedReverseCurve;
|
||||
CurvedAnimation curvedAnimation;
|
||||
late CurveChoice selectedForwardCurve, selectedReverseCurve;
|
||||
late final CurvedAnimation curvedAnimation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -100,10 +101,12 @@ class _CurvedAnimationDemoState extends State<CurvedAnimationDemo>
|
||||
value: curve, child: Text(curve.name));
|
||||
}).toList(),
|
||||
onChanged: (newCurve) {
|
||||
setState(() {
|
||||
selectedForwardCurve = newCurve;
|
||||
curvedAnimation.curve = selectedForwardCurve.curve;
|
||||
});
|
||||
if (newCurve != null) {
|
||||
setState(() {
|
||||
selectedForwardCurve = newCurve;
|
||||
curvedAnimation.curve = selectedForwardCurve.curve;
|
||||
});
|
||||
}
|
||||
},
|
||||
value: selectedForwardCurve,
|
||||
),
|
||||
@@ -118,10 +121,12 @@ class _CurvedAnimationDemoState extends State<CurvedAnimationDemo>
|
||||
value: curve, child: Text(curve.name));
|
||||
}).toList(),
|
||||
onChanged: (newCurve) {
|
||||
setState(() {
|
||||
selectedReverseCurve = newCurve;
|
||||
curvedAnimation.reverseCurve = selectedReverseCurve.curve;
|
||||
});
|
||||
if (newCurve != null) {
|
||||
setState(() {
|
||||
selectedReverseCurve = newCurve;
|
||||
curvedAnimation.reverseCurve = selectedReverseCurve.curve;
|
||||
});
|
||||
}
|
||||
},
|
||||
value: selectedReverseCurve,
|
||||
),
|
||||
|
||||
@@ -18,7 +18,7 @@ class HeroAnimationDemo extends StatelessWidget {
|
||||
tag: 'hero-page-child',
|
||||
child: _createHeroContainer(
|
||||
size: 50.0,
|
||||
color: Colors.grey[300],
|
||||
color: Colors.grey.shade300,
|
||||
),
|
||||
),
|
||||
onTap: () => Navigator.of(context)
|
||||
@@ -47,7 +47,10 @@ class HeroPage extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
StatelessWidget _createHeroContainer({double size, Color color}) {
|
||||
StatelessWidget _createHeroContainer({
|
||||
required double size,
|
||||
required Color color,
|
||||
}) {
|
||||
return Container(
|
||||
height: size,
|
||||
width: size,
|
||||
|
||||
@@ -27,7 +27,7 @@ class PhysicsCardDragDemo extends StatelessWidget {
|
||||
/// released.
|
||||
class DraggableCard extends StatefulWidget {
|
||||
final Widget child;
|
||||
DraggableCard({this.child});
|
||||
DraggableCard({required this.child});
|
||||
|
||||
@override
|
||||
_DraggableCardState createState() => _DraggableCardState();
|
||||
@@ -35,7 +35,7 @@ class DraggableCard extends StatefulWidget {
|
||||
|
||||
class _DraggableCardState extends State<DraggableCard>
|
||||
with SingleTickerProviderStateMixin {
|
||||
AnimationController _controller;
|
||||
late final AnimationController _controller;
|
||||
|
||||
/// The alignment of the card as it is dragged or being animated.
|
||||
///
|
||||
@@ -44,7 +44,7 @@ class _DraggableCardState extends State<DraggableCard>
|
||||
/// this value is set to the value of the [_animation].
|
||||
var _dragAlignment = Alignment.center;
|
||||
|
||||
Animation<Alignment> _animation;
|
||||
late Animation<Alignment> _animation;
|
||||
|
||||
final _spring = const SpringDescription(
|
||||
mass: 10,
|
||||
|
||||
@@ -13,8 +13,8 @@ class RepeatingAnimationDemo extends StatefulWidget {
|
||||
|
||||
class RepeatingAnimationDemoState extends State<RepeatingAnimationDemo>
|
||||
with SingleTickerProviderStateMixin {
|
||||
AnimationController _controller;
|
||||
Animation<BorderRadius> _borderRadius;
|
||||
late final AnimationController _controller;
|
||||
late final Animation<BorderRadius> _borderRadius;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
||||
@@ -94,7 +94,7 @@ packages:
|
||||
name: pedantic
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.9.2"
|
||||
version: "1.10.0"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
|
||||
@@ -3,12 +3,12 @@ description: A new Flutter project.
|
||||
version: 1.0.0+1
|
||||
|
||||
environment:
|
||||
sdk: ">=2.10.0 <3.0.0"
|
||||
sdk: ">=2.12.0-0 <3.0.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
cupertino_icons: ^1.0.0
|
||||
cupertino_icons: ^1.0.2
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
Reference in New Issue
Block a user