mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Upgrading samples to flutter_lints, part 1 of n (#804)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
include: package:pedantic/analysis_options.1.9.0.yaml
|
||||
include: package:flutter_lints/flutter.yaml
|
||||
|
||||
analyzer:
|
||||
strong-mode:
|
||||
@@ -7,25 +7,15 @@ analyzer:
|
||||
|
||||
linter:
|
||||
rules:
|
||||
- avoid_types_on_closure_parameters
|
||||
- avoid_void_async
|
||||
- await_only_futures
|
||||
- camel_case_types
|
||||
- cancel_subscriptions
|
||||
- close_sinks
|
||||
- constant_identifier_names
|
||||
- control_flow_in_finally
|
||||
- directives_ordering
|
||||
- empty_statements
|
||||
- hash_and_equals
|
||||
- implementation_imports
|
||||
- non_constant_identifier_names
|
||||
- package_api_docs
|
||||
- package_names
|
||||
- package_prefixed_library_names
|
||||
- test_types_in_equals
|
||||
- throw_in_finally
|
||||
- unnecessary_brace_in_string_interps
|
||||
- unnecessary_getters_setters
|
||||
- unnecessary_new
|
||||
- unnecessary_statements
|
||||
avoid_types_on_closure_parameters: true
|
||||
avoid_void_async: true
|
||||
cancel_subscriptions: true
|
||||
close_sinks: true
|
||||
directives_ordering: true
|
||||
file_names: false
|
||||
package_api_docs: true
|
||||
package_prefixed_library_names: true
|
||||
test_types_in_equals: true
|
||||
throw_in_finally: true
|
||||
unnecessary_statements: true
|
||||
use_key_in_widget_constructors: false
|
||||
|
||||
@@ -151,7 +151,7 @@ class HomePage extends StatelessWidget {
|
||||
final headerStyle = Theme.of(context).textTheme.headline6;
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Animation Samples'),
|
||||
title: const Text('Animation Samples'),
|
||||
),
|
||||
body: ListView(
|
||||
children: [
|
||||
@@ -168,7 +168,7 @@ class HomePage extends StatelessWidget {
|
||||
class DemoTile extends StatelessWidget {
|
||||
final Demo demo;
|
||||
|
||||
DemoTile(this.demo);
|
||||
const DemoTile(this.demo);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -49,13 +49,13 @@ class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
|
||||
// and shrinking cards.
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('AnimatedContainer'),
|
||||
title: const Text('AnimatedContainer'),
|
||||
),
|
||||
body: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: SizedBox(
|
||||
width: 128,
|
||||
height: 128,
|
||||
@@ -70,7 +70,7 @@ class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
child: Text(
|
||||
child: const Text(
|
||||
'change',
|
||||
),
|
||||
onPressed: () => change(),
|
||||
|
||||
@@ -11,11 +11,11 @@ class PageRouteBuilderDemo extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Page 1'),
|
||||
title: const Text('Page 1'),
|
||||
),
|
||||
body: Center(
|
||||
child: ElevatedButton(
|
||||
child: Text('Go!'),
|
||||
child: const Text('Go!'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push<void>(_createRoute());
|
||||
},
|
||||
@@ -29,7 +29,8 @@ Route _createRoute() {
|
||||
return PageRouteBuilder<SlideTransition>(
|
||||
pageBuilder: (context, animation, secondaryAnimation) => _Page2(),
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
||||
var tween = Tween<Offset>(begin: Offset(0.0, 1.0), end: Offset.zero);
|
||||
var tween =
|
||||
Tween<Offset>(begin: const Offset(0.0, 1.0), end: Offset.zero);
|
||||
var curveTween = CurveTween(curve: Curves.ease);
|
||||
|
||||
return SlideTransition(
|
||||
@@ -45,7 +46,7 @@ class _Page2 extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Page 2'),
|
||||
title: const Text('Page 2'),
|
||||
),
|
||||
body: Center(
|
||||
child: Text('Page 2!', style: Theme.of(context).textTheme.headline4),
|
||||
|
||||
@@ -54,22 +54,22 @@ class _AnimationControllerDemoState extends State<AnimationControllerDemo>
|
||||
// has completed.
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Animation Controller'),
|
||||
title: const Text('Animation Controller'),
|
||||
),
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(maxWidth: 200),
|
||||
constraints: const BoxConstraints(maxWidth: 200),
|
||||
child: Text(
|
||||
'${controller.value.toStringAsFixed(2)}',
|
||||
controller.value.toStringAsFixed(2),
|
||||
style: Theme.of(context).textTheme.headline3,
|
||||
textScaleFactor: 1 + controller.value,
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
child: Text('animate'),
|
||||
child: const Text('animate'),
|
||||
onPressed: () {
|
||||
if (controller.status == AnimationStatus.completed) {
|
||||
controller.reverse();
|
||||
|
||||
@@ -40,16 +40,16 @@ class _TweenDemoState extends State<TweenDemo>
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Tweens'),
|
||||
title: const Text('Tweens'),
|
||||
),
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(maxWidth: 200),
|
||||
constraints: const BoxConstraints(maxWidth: 200),
|
||||
child: Text('\$${animation.value.toStringAsFixed(2)}',
|
||||
style: TextStyle(fontSize: 24)),
|
||||
style: const TextStyle(fontSize: 24)),
|
||||
),
|
||||
ElevatedButton(
|
||||
child: Text(
|
||||
|
||||
@@ -15,7 +15,7 @@ class _AnimatedBuilderDemoState extends State<AnimatedBuilderDemo>
|
||||
with SingleTickerProviderStateMixin {
|
||||
static const Color beginColor = Colors.deepPurple;
|
||||
static const Color endColor = Colors.deepOrange;
|
||||
Duration duration = Duration(milliseconds: 800);
|
||||
Duration duration = const Duration(milliseconds: 800);
|
||||
late AnimationController controller;
|
||||
late Animation<Color?> animation;
|
||||
|
||||
@@ -38,7 +38,7 @@ class _AnimatedBuilderDemoState extends State<AnimatedBuilderDemo>
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('AnimatedBuilder'),
|
||||
title: const Text('AnimatedBuilder'),
|
||||
),
|
||||
body: Center(
|
||||
// AnimatedBuilder handles listening to a given animation and calling the builder
|
||||
@@ -66,7 +66,7 @@ class _AnimatedBuilderDemoState extends State<AnimatedBuilderDemo>
|
||||
// if there is a non-animated Widget contained within the animated widget.
|
||||
// This can improve performance since this widget doesn't need to be rebuilt
|
||||
// when the animation changes.
|
||||
child: Text(
|
||||
child: const Text(
|
||||
'Change Color',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
|
||||
@@ -47,7 +47,7 @@ class _CustomTweenDemoState extends State<CustomTweenDemo>
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Custom Tween'),
|
||||
title: const Text('Custom Tween'),
|
||||
actions: [
|
||||
MaterialButton(
|
||||
child: Text(
|
||||
@@ -79,16 +79,18 @@ class _CustomTweenDemoState extends State<CustomTweenDemo>
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Card(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: AnimatedBuilder(
|
||||
animation: animation,
|
||||
builder: (context, child) {
|
||||
return Text('${animation.value}',
|
||||
style: TextStyle(
|
||||
fontSize: 16, fontFamily: 'SpecialElite'));
|
||||
return Text(
|
||||
animation.value,
|
||||
style: const TextStyle(
|
||||
fontSize: 16, fontFamily: 'SpecialElite'),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
@@ -60,7 +60,7 @@ class _TweenSequenceDemoState extends State<TweenSequenceDemo>
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Tween Sequences'),
|
||||
title: const Text('Tween Sequences'),
|
||||
),
|
||||
body: Center(
|
||||
child: AnimatedBuilder(
|
||||
@@ -75,7 +75,7 @@ class _TweenSequenceDemoState extends State<TweenSequenceDemo>
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: Text('Animate', style: TextStyle(color: Colors.white)),
|
||||
child: const Text('Animate', style: TextStyle(color: Colors.white)),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -24,7 +24,7 @@ class _FadeTransitionDemoState extends State<FadeTransitionDemo>
|
||||
super.initState();
|
||||
_controller = AnimationController(
|
||||
vsync: this,
|
||||
duration: Duration(milliseconds: 500),
|
||||
duration: const Duration(milliseconds: 500),
|
||||
);
|
||||
|
||||
_curve = CurvedAnimation(parent: _controller, curve: Curves.easeIn);
|
||||
@@ -45,7 +45,7 @@ class _FadeTransitionDemoState extends State<FadeTransitionDemo>
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
title: const Text(
|
||||
'Fade Transition',
|
||||
),
|
||||
),
|
||||
@@ -55,14 +55,14 @@ class _FadeTransitionDemoState extends State<FadeTransitionDemo>
|
||||
children: <Widget>[
|
||||
FadeTransition(
|
||||
opacity: _animation,
|
||||
child: Icon(
|
||||
child: const Icon(
|
||||
Icons.star,
|
||||
color: Colors.amber,
|
||||
size: 300,
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
child: Text('animate'),
|
||||
child: const Text('animate'),
|
||||
onPressed: () => setState(() {
|
||||
_controller.animateTo(1.0).then<TickerFuture>(
|
||||
(value) => _controller.animateBack(0.0));
|
||||
|
||||
@@ -30,7 +30,7 @@ class _AnimatedListDemoState extends State<AnimatedListDemo> {
|
||||
UserModel(++_maxIdValue, 'New', 'Person'),
|
||||
);
|
||||
_listKey.currentState!
|
||||
.insertItem(index, duration: Duration(milliseconds: 300));
|
||||
.insertItem(index, duration: const Duration(milliseconds: 300));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -42,17 +42,17 @@ class _AnimatedListDemoState extends State<AnimatedListDemo> {
|
||||
index,
|
||||
(context, animation) {
|
||||
return FadeTransition(
|
||||
opacity:
|
||||
CurvedAnimation(parent: animation, curve: Interval(0.5, 1.0)),
|
||||
opacity: CurvedAnimation(
|
||||
parent: animation, curve: const Interval(0.5, 1.0)),
|
||||
child: SizeTransition(
|
||||
sizeFactor:
|
||||
CurvedAnimation(parent: animation, curve: Interval(0.0, 1.0)),
|
||||
sizeFactor: CurvedAnimation(
|
||||
parent: animation, curve: const Interval(0.0, 1.0)),
|
||||
axisAlignment: 0.0,
|
||||
child: _buildItem(user),
|
||||
),
|
||||
);
|
||||
},
|
||||
duration: Duration(milliseconds: 600),
|
||||
duration: const Duration(milliseconds: 600),
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -62,11 +62,11 @@ class _AnimatedListDemoState extends State<AnimatedListDemo> {
|
||||
key: ValueKey<UserModel>(user),
|
||||
title: Text(user.firstName),
|
||||
subtitle: Text(user.lastName),
|
||||
leading: CircleAvatar(
|
||||
leading: const CircleAvatar(
|
||||
child: Icon(Icons.person),
|
||||
),
|
||||
trailing: IconButton(
|
||||
icon: Icon(Icons.delete),
|
||||
icon: const Icon(Icons.delete),
|
||||
onPressed: () => deleteUser(user.id),
|
||||
),
|
||||
);
|
||||
@@ -76,10 +76,10 @@ class _AnimatedListDemoState extends State<AnimatedListDemo> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('AnimatedList'),
|
||||
title: const Text('AnimatedList'),
|
||||
actions: <Widget>[
|
||||
IconButton(
|
||||
icon: Icon(Icons.add),
|
||||
icon: const Icon(Icons.add),
|
||||
onPressed: addUser,
|
||||
),
|
||||
],
|
||||
|
||||
@@ -38,12 +38,12 @@ class _AnimatedPositionedDemoState extends State<AnimatedPositionedDemo> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final size = MediaQuery.of(context).size;
|
||||
final appBar = AppBar(title: Text('AnimatedPositioned'));
|
||||
final appBar = AppBar(title: const Text('AnimatedPositioned'));
|
||||
final topPadding = MediaQuery.of(context).padding.top;
|
||||
// AnimatedPositioned animates changes to a widget's position within a Stack
|
||||
return Scaffold(
|
||||
appBar: appBar,
|
||||
body: Container(
|
||||
body: SizedBox(
|
||||
height: size.height,
|
||||
width: size.width,
|
||||
child: Stack(
|
||||
@@ -51,7 +51,7 @@ class _AnimatedPositionedDemoState extends State<AnimatedPositionedDemo> {
|
||||
AnimatedPositioned(
|
||||
top: topPosition,
|
||||
left: leftPosition,
|
||||
duration: Duration(seconds: 1),
|
||||
duration: const Duration(seconds: 1),
|
||||
child: InkWell(
|
||||
onTap: () => changePosition(
|
||||
size.height -
|
||||
|
||||
@@ -44,7 +44,7 @@ class _AnimatedSwitcherDemoState extends State<AnimatedSwitcherDemo> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('AnimatedSwitcher'),
|
||||
title: const Text('AnimatedSwitcher'),
|
||||
actions: [
|
||||
MaterialButton(
|
||||
onPressed: () => setState(
|
||||
@@ -63,7 +63,7 @@ class _AnimatedSwitcherDemoState extends State<AnimatedSwitcherDemo> {
|
||||
// with a given transition. You can change the transitions by using
|
||||
// transitionBuilder property.
|
||||
child: AnimatedSwitcher(
|
||||
duration: Duration(seconds: 1),
|
||||
duration: const Duration(seconds: 1),
|
||||
child: container,
|
||||
transitionBuilder: (child, animation) => ScaleTransition(
|
||||
child: child,
|
||||
|
||||
@@ -35,7 +35,7 @@ class _CardSwipeDemoState extends State<CardSwipeDemo> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Card Swipe'),
|
||||
title: const Text('Card Swipe'),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
@@ -78,7 +78,7 @@ class _CardSwipeDemoState extends State<CardSwipeDemo> {
|
||||
class Card extends StatelessWidget {
|
||||
final String imageAssetName;
|
||||
|
||||
Card(this.imageAssetName);
|
||||
const Card(this.imageAssetName);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -101,7 +101,7 @@ class SwipeableCard extends StatefulWidget {
|
||||
final String imageAssetName;
|
||||
final VoidCallback onSwiped;
|
||||
|
||||
SwipeableCard({
|
||||
const SwipeableCard({
|
||||
required this.onSwiped,
|
||||
required this.imageAssetName,
|
||||
});
|
||||
@@ -123,7 +123,7 @@ class _SwipeableCardState extends State<SwipeableCard>
|
||||
_controller = AnimationController.unbounded(vsync: this);
|
||||
_animation = _controller.drive(Tween<Offset>(
|
||||
begin: Offset.zero,
|
||||
end: Offset(1, 0),
|
||||
end: const Offset(1, 0),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -184,12 +184,13 @@ class _SwipeableCardState extends State<SwipeableCard>
|
||||
void _updateAnimation(double dragPosition) {
|
||||
_animation = _controller.drive(Tween<Offset>(
|
||||
begin: Offset.zero,
|
||||
end: _isSwipingLeft ? Offset(-1, 0) : Offset(1, 0),
|
||||
end: _isSwipingLeft ? const Offset(-1, 0) : const Offset(1, 0),
|
||||
));
|
||||
}
|
||||
|
||||
void _animate({double velocity = 0}) {
|
||||
var description = SpringDescription(mass: 50, stiffness: 1, damping: 1);
|
||||
var description =
|
||||
const SpringDescription(mass: 50, stiffness: 1, damping: 1);
|
||||
var simulation =
|
||||
SpringSimulation(description, _controller.value, 1, velocity);
|
||||
_controller.animateWith(simulation).then<void>((_) {
|
||||
|
||||
@@ -22,7 +22,7 @@ class CarouselDemo extends StatelessWidget {
|
||||
Widget build(context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Carousel Demo'),
|
||||
title: const Text('Carousel Demo'),
|
||||
),
|
||||
body: Center(
|
||||
child: Padding(
|
||||
|
||||
@@ -25,7 +25,7 @@ class _CurvedAnimationDemoState extends State<CurvedAnimationDemo>
|
||||
late final Animation<double> animationRotation;
|
||||
late final Animation<Offset> animationTranslation;
|
||||
static const _duration = Duration(seconds: 4);
|
||||
List<CurveChoice> curves = [
|
||||
List<CurveChoice> curves = const [
|
||||
CurveChoice(curve: Curves.bounceIn, name: 'Bounce In'),
|
||||
CurveChoice(curve: Curves.bounceOut, name: 'Bounce Out'),
|
||||
CurveChoice(curve: Curves.easeInCubic, name: 'Ease In Cubic'),
|
||||
@@ -69,8 +69,8 @@ class _CurvedAnimationDemoState extends State<CurvedAnimationDemo>
|
||||
}
|
||||
});
|
||||
animationTranslation = Tween<Offset>(
|
||||
begin: Offset(-1, 0),
|
||||
end: Offset(1, 0),
|
||||
begin: const Offset(-1, 0),
|
||||
end: const Offset(1, 0),
|
||||
).animate(curvedAnimation)
|
||||
..addListener(() {
|
||||
setState(() {});
|
||||
@@ -86,11 +86,11 @@ class _CurvedAnimationDemoState extends State<CurvedAnimationDemo>
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Curved Animation'),
|
||||
title: const Text('Curved Animation'),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
SizedBox(height: 20.0),
|
||||
const SizedBox(height: 20.0),
|
||||
Text(
|
||||
'Select Curve for forward motion',
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
@@ -110,7 +110,7 @@ class _CurvedAnimationDemoState extends State<CurvedAnimationDemo>
|
||||
},
|
||||
value: selectedForwardCurve,
|
||||
),
|
||||
SizedBox(height: 15.0),
|
||||
const SizedBox(height: 15.0),
|
||||
Text(
|
||||
'Select Curve for reverse motion',
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
@@ -130,32 +130,28 @@ class _CurvedAnimationDemoState extends State<CurvedAnimationDemo>
|
||||
},
|
||||
value: selectedReverseCurve,
|
||||
),
|
||||
SizedBox(height: 35.0),
|
||||
const SizedBox(height: 35.0),
|
||||
Transform.rotate(
|
||||
angle: animationRotation.value,
|
||||
child: Center(
|
||||
child: Container(
|
||||
child: FlutterLogo(
|
||||
size: 100,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 35.0),
|
||||
FractionalTranslation(
|
||||
translation: animationTranslation.value,
|
||||
child: Container(
|
||||
child: const Center(
|
||||
child: FlutterLogo(
|
||||
size: 100,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 25.0),
|
||||
const SizedBox(height: 35.0),
|
||||
FractionalTranslation(
|
||||
translation: animationTranslation.value,
|
||||
child: const FlutterLogo(
|
||||
size: 100,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25.0),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
controller.forward();
|
||||
},
|
||||
child: Text('Animate'),
|
||||
child: const Text('Animate'),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -11,7 +11,7 @@ class ExpandCardDemo extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Expandable Card'),
|
||||
title: const Text('Expandable Card'),
|
||||
),
|
||||
body: Center(
|
||||
child: ExpandCard(),
|
||||
|
||||
@@ -10,7 +10,7 @@ class FocusImageDemo extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text('Focus Image')),
|
||||
appBar: AppBar(title: const Text('Focus Image')),
|
||||
body: Grid(),
|
||||
);
|
||||
}
|
||||
@@ -23,11 +23,11 @@ class Grid extends StatelessWidget {
|
||||
body: GridView.builder(
|
||||
itemCount: 40,
|
||||
gridDelegate:
|
||||
SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4),
|
||||
const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4),
|
||||
itemBuilder: (context, index) {
|
||||
return (index >= 20)
|
||||
? SmallCard('assets/eat_cape_town_sm.jpg')
|
||||
: SmallCard('assets/eat_new_orleans_sm.jpg');
|
||||
? const SmallCard('assets/eat_cape_town_sm.jpg')
|
||||
: const SmallCard('assets/eat_new_orleans_sm.jpg');
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -68,7 +68,7 @@ Tween<RelativeRect> _createTween(BuildContext context) {
|
||||
class SmallCard extends StatelessWidget {
|
||||
final String imageAssetName;
|
||||
|
||||
SmallCard(this.imageAssetName);
|
||||
const SmallCard(this.imageAssetName);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -92,7 +92,7 @@ class SmallCard extends StatelessWidget {
|
||||
class _SecondPage extends StatelessWidget {
|
||||
final String imageAssetName;
|
||||
|
||||
_SecondPage(this.imageAssetName);
|
||||
const _SecondPage(this.imageAssetName);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -11,7 +11,7 @@ class HeroAnimationDemo extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Hero Animation'),
|
||||
title: const Text('Hero Animation'),
|
||||
),
|
||||
body: GestureDetector(
|
||||
child: Hero(
|
||||
@@ -54,12 +54,12 @@ StatelessWidget _createHeroContainer({
|
||||
return Container(
|
||||
height: size,
|
||||
width: size,
|
||||
padding: EdgeInsets.all(10.0),
|
||||
margin: size < 100.0 ? EdgeInsets.all(10.0) : EdgeInsets.all(0),
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
margin: size < 100.0 ? const EdgeInsets.all(10.0) : const EdgeInsets.all(0),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: color,
|
||||
),
|
||||
child: FlutterLogo(),
|
||||
child: const FlutterLogo(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ class PhysicsCardDragDemo extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Spring Physics'),
|
||||
title: const Text('Spring Physics'),
|
||||
),
|
||||
body: DraggableCard(
|
||||
body: const DraggableCard(
|
||||
child: FlutterLogo(
|
||||
size: 128,
|
||||
),
|
||||
@@ -27,7 +27,7 @@ class PhysicsCardDragDemo extends StatelessWidget {
|
||||
/// released.
|
||||
class DraggableCard extends StatefulWidget {
|
||||
final Widget child;
|
||||
DraggableCard({required this.child});
|
||||
const DraggableCard({required this.child});
|
||||
|
||||
@override
|
||||
_DraggableCardState createState() => _DraggableCardState();
|
||||
|
||||
@@ -33,7 +33,7 @@ class RepeatingAnimationDemoState extends State<RepeatingAnimationDemo>
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text('Repeating Animation')),
|
||||
appBar: AppBar(title: const Text('Repeating Animation')),
|
||||
body: Center(
|
||||
child: AnimatedBuilder(
|
||||
animation: _borderRadius,
|
||||
|
||||
@@ -26,10 +26,6 @@
|
||||
33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; };
|
||||
33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; };
|
||||
33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; };
|
||||
33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; };
|
||||
33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
D73912F022F37F9E000D13A0 /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; };
|
||||
D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -49,8 +45,6 @@
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */,
|
||||
33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */,
|
||||
);
|
||||
name = "Bundle Framework";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -69,13 +63,11 @@
|
||||
33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = "<group>"; };
|
||||
33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = "<group>"; };
|
||||
33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = "<group>"; };
|
||||
33D1A10322148B71006C7A3E /* FlutterMacOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FlutterMacOS.framework; path = Flutter/ephemeral/FlutterMacOS.framework; sourceTree = SOURCE_ROOT; };
|
||||
33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = "<group>"; };
|
||||
33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = "<group>"; };
|
||||
33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = "<group>"; };
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
|
||||
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; };
|
||||
D73912EF22F37F9E000D13A0 /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/ephemeral/App.framework; sourceTree = SOURCE_ROOT; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -83,8 +75,6 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
D73912F022F37F9E000D13A0 /* App.framework in Frameworks */,
|
||||
33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -138,8 +128,6 @@
|
||||
33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */,
|
||||
33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */,
|
||||
33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */,
|
||||
D73912EF22F37F9E000D13A0 /* App.framework */,
|
||||
33D1A10322148B71006C7A3E /* FlutterMacOS.framework */,
|
||||
);
|
||||
path = Flutter;
|
||||
sourceTree = "<group>";
|
||||
@@ -260,7 +248,7 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename\n";
|
||||
shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n";
|
||||
};
|
||||
33CC111E2044C6BF0003C045 /* ShellScript */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
|
||||
@@ -49,7 +49,7 @@ packages:
|
||||
name: cupertino_icons
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
version: "1.0.3"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -62,11 +62,25 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_lints:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: flutter_lints
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.3"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
lints:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: lints
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -88,13 +102,6 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.0"
|
||||
pedantic:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: pedantic
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.10.0"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
|
||||
@@ -3,7 +3,7 @@ description: A new Flutter project.
|
||||
version: 1.0.0+1
|
||||
|
||||
environment:
|
||||
sdk: ">=2.12.0-0 <3.0.0"
|
||||
sdk: ">=2.12.0 <3.0.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
@@ -13,7 +13,7 @@ dependencies:
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
pedantic: ^1.9.0
|
||||
flutter_lints: ^1.0.0
|
||||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
|
||||
@@ -20,7 +20,8 @@ void main() {
|
||||
var totalCards = tester.widgetList(find.byType(SwipeableCard)).length;
|
||||
|
||||
// Swipe out one card.
|
||||
await tester.drag(find.byType(SwipeableCard).first, Offset(100.0, 0.0));
|
||||
await tester.drag(
|
||||
find.byType(SwipeableCard).first, const Offset(100.0, 0.0));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Check if removed properly.
|
||||
@@ -37,7 +38,8 @@ void main() {
|
||||
// Swipe out all cards.
|
||||
for (var i = 0; i < totalCards; i++) {
|
||||
// Swipe out one by one.
|
||||
await tester.drag(find.byType(SwipeableCard).first, Offset(100.0, 0.0));
|
||||
await tester.drag(
|
||||
find.byType(SwipeableCard).first, const Offset(100.0, 0.0));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
@@ -52,7 +54,8 @@ void main() {
|
||||
var totalCards = tester.widgetList(find.byType(SwipeableCard)).length;
|
||||
|
||||
// Swipe out one card.
|
||||
await tester.drag(find.byType(SwipeableCard).first, Offset(100.0, 0.0));
|
||||
await tester.drag(
|
||||
find.byType(SwipeableCard).first, const Offset(100.0, 0.0));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Tap the Refill button.
|
||||
|
||||
@@ -20,7 +20,7 @@ void main() {
|
||||
expect(imageList.length, 2);
|
||||
|
||||
// Swipe the Carousel.
|
||||
await tester.fling(find.byType(CarouselDemo), Offset(-400, 0), 800);
|
||||
await tester.fling(find.byType(CarouselDemo), const Offset(-400, 0), 800);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Get the images available on the screen after swipe.
|
||||
|
||||
Reference in New Issue
Block a user