pull/2701/head
Eric Windmill 2 months ago
parent a511846ed4
commit 50ecc5afea

@ -23,7 +23,8 @@ class Cell extends StatefulWidget {
class _CellState extends State<Cell> with WidgetsBindingObserver { class _CellState extends State<Cell> with WidgetsBindingObserver {
static const double gravity = 9.81; static const double gravity = 9.81;
static final AccelerometerEvent defaultPosition = AccelerometerEvent(0, 0, 0); static final AccelerometerEvent defaultPosition =
AccelerometerEvent(0, 0, 0);
int cellNumber = 0; int cellNumber = 0;
Random? _random; Random? _random;
@ -82,7 +83,8 @@ class _CellState extends State<Cell> with WidgetsBindingObserver {
builder: (context) { builder: (context) {
return Card( return Card(
// Mimic the platform Material look. // Mimic the platform Material look.
margin: const EdgeInsets.symmetric(horizontal: 36, vertical: 24), margin:
const EdgeInsets.symmetric(horizontal: 36, vertical: 24),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16), borderRadius: BorderRadius.circular(16),
), ),
@ -112,7 +114,8 @@ class _CellState extends State<Cell> with WidgetsBindingObserver {
child: StreamBuilder<AccelerometerEvent>( child: StreamBuilder<AccelerometerEvent>(
// Don't continuously rebuild for nothing when the // Don't continuously rebuild for nothing when the
// cell isn't visible. // cell isn't visible.
stream: appLifecycleState == AppLifecycleState.resumed stream:
appLifecycleState == AppLifecycleState.resumed
? accelerometerEventStream() ? accelerometerEventStream()
: Stream.value(defaultPosition), : Stream.value(defaultPosition),
initialData: defaultPosition, initialData: defaultPosition,
@ -120,8 +123,7 @@ class _CellState extends State<Cell> with WidgetsBindingObserver {
return Transform( return Transform(
// Figure out the phone's orientation relative // Figure out the phone's orientation relative
// to gravity's direction. Ignore the z vector. // to gravity's direction. Ignore the z vector.
transform: transform: Matrix4.rotationX(
Matrix4.rotationX(
snapshot.data!.y / gravity * pi / 2, snapshot.data!.y / gravity * pi / 2,
)..multiply( )..multiply(
Matrix4.rotationY( Matrix4.rotationY(

@ -4,7 +4,7 @@ version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: ^3.9.0-0
dependencies: dependencies:
flutter: flutter:

@ -24,7 +24,8 @@ class Book {
pigeonMap['summary'] = summary; pigeonMap['summary'] = summary;
pigeonMap['publishDate'] = publishDate; pigeonMap['publishDate'] = publishDate;
pigeonMap['pageCount'] = pageCount; pigeonMap['pageCount'] = pageCount;
pigeonMap['thumbnail'] = thumbnail == null ? null : thumbnail!.encode(); pigeonMap['thumbnail'] =
thumbnail == null ? null : thumbnail!.encode();
return pigeonMap; return pigeonMap;
} }
@ -167,7 +168,8 @@ class HostBookApi {
} }
Future<void> finishEditingBook(Book arg_book) async { Future<void> finishEditingBook(Book arg_book) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( final BasicMessageChannel<Object?> channel =
BasicMessageChannel<Object?>(
'dev.flutter.pigeon.HostBookApi.finishEditingBook', codec, 'dev.flutter.pigeon.HostBookApi.finishEditingBook', codec,
binaryMessenger: _binaryMessenger); binaryMessenger: _binaryMessenger);
final Map<Object?, Object?>? replyMap = final Map<Object?, Object?>? replyMap =

@ -6,7 +6,7 @@ version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: ^3.9.0-0
dependencies: dependencies:
flutter: flutter:

@ -20,7 +20,8 @@ void main() {
expect(mockHostApi.cancelCalls, 1); expect(mockHostApi.cancelCalls, 1);
}); });
testWidgets('Pressing done calls the finish editing API', (tester) async { testWidgets('Pressing done calls the finish editing API',
(tester) async {
MockHostBookApi mockHostApi = MockHostBookApi(); MockHostBookApi mockHostApi = MockHostBookApi();
await tester.pumpWidget( await tester.pumpWidget(

@ -4,7 +4,7 @@ version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: ^3.9.0-0
dependencies: dependencies:
flutter: flutter:

@ -82,7 +82,8 @@ class _MyHomePageState extends State<MyHomePage> {
'$_counter', '$_counter',
style: Theme.of(context).textTheme.headlineMedium, style: Theme.of(context).textTheme.headlineMedium,
), ),
TextButton(onPressed: _incrementCounter, child: const Text('Add')), TextButton(
onPressed: _incrementCounter, child: const Text('Add')),
TextButton( TextButton(
onPressed: () { onPressed: () {
_channel.invokeMethod<void>("next", _counter); _channel.invokeMethod<void>("next", _counter);

@ -4,7 +4,7 @@ version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: ^3.9.0-0
dependencies: dependencies:
flutter: flutter:

@ -23,7 +23,8 @@ class Cell extends StatefulWidget {
class _CellState extends State<Cell> with WidgetsBindingObserver { class _CellState extends State<Cell> with WidgetsBindingObserver {
static const double gravity = 9.81; static const double gravity = 9.81;
static final AccelerometerEvent defaultPosition = AccelerometerEvent(0, 0, 0); static final AccelerometerEvent defaultPosition =
AccelerometerEvent(0, 0, 0);
int cellNumber = 0; int cellNumber = 0;
Random? _random; Random? _random;
@ -82,7 +83,8 @@ class _CellState extends State<Cell> with WidgetsBindingObserver {
builder: (context) { builder: (context) {
return Card( return Card(
// Mimic the platform Material look. // Mimic the platform Material look.
margin: const EdgeInsets.symmetric(horizontal: 36, vertical: 24), margin:
const EdgeInsets.symmetric(horizontal: 36, vertical: 24),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16), borderRadius: BorderRadius.circular(16),
), ),
@ -112,23 +114,25 @@ class _CellState extends State<Cell> with WidgetsBindingObserver {
child: StreamBuilder<AccelerometerEvent>( child: StreamBuilder<AccelerometerEvent>(
// Don't continuously rebuild for nothing when the // Don't continuously rebuild for nothing when the
// cell isn't visible. // cell isn't visible.
stream: appLifecycleState == AppLifecycleState.resumed stream:
appLifecycleState == AppLifecycleState.resumed
? accelerometerEventStream() ? accelerometerEventStream()
: Stream.value(defaultPosition), : Stream.value(defaultPosition),
initialData: defaultPosition, initialData: defaultPosition,
builder: (context, snapshot) { builder: (context, snapshot) {
final data = snapshot.data; final data = snapshot.data;
if (data == null) { if (data == null) {
return const CircularProgressIndicator.adaptive(); return const CircularProgressIndicator
.adaptive();
} }
return Transform( return Transform(
// Figure out the phone's orientation relative // Figure out the phone's orientation relative
// to gravity's direction. Ignore the z vector. // to gravity's direction. Ignore the z vector.
transform: transform: Matrix4.rotationX(
Matrix4.rotationX(
data.y / gravity * pi / 2, data.y / gravity * pi / 2,
)..multiply( )..multiply(
Matrix4.rotationY(data.x / gravity * pi / 2), Matrix4.rotationY(
data.x / gravity * pi / 2),
), ),
alignment: Alignment.center, alignment: Alignment.center,
child: const FlutterLogo(size: 72), child: const FlutterLogo(size: 72),

@ -4,7 +4,7 @@ version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -4,7 +4,7 @@ version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -4,7 +4,7 @@ publish_to: none
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
# NOTE: Code is not allowed in this package. Do not add more dependencies. # NOTE: Code is not allowed in this package. Do not add more dependencies.
# The `flutter_lints` dependency is required for `lib/flutter.yaml`. # The `flutter_lints` dependency is required for `lib/flutter.yaml`.

@ -5,7 +5,7 @@ version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -21,7 +21,8 @@ const double windowWidth = 480;
const double windowHeight = 854; const double windowHeight = 854;
void setupWindow() { void setupWindow() {
if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { if (!kIsWeb &&
(Platform.isWindows || Platform.isLinux || Platform.isMacOS)) {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
setWindowTitle('Animation Samples'); setWindowTitle('Animation Samples');
setWindowMinSize(const Size(windowWidth, windowHeight)); setWindowMinSize(const Size(windowWidth, windowHeight));
@ -43,7 +44,8 @@ class Demo {
final String route; final String route;
final WidgetBuilder builder; final WidgetBuilder builder;
const Demo({required this.name, required this.route, required this.builder}); const Demo(
{required this.name, required this.route, required this.builder});
} }
final basicDemos = [ final basicDemos = [

@ -49,7 +49,8 @@ class _AnimatedBuilderDemoState extends State<AnimatedBuilderDemo>
animation: animation, animation: animation,
builder: (context, child) { builder: (context, child) {
return ElevatedButton( return ElevatedButton(
style: ElevatedButton.styleFrom(backgroundColor: animation.value), style: ElevatedButton.styleFrom(
backgroundColor: animation.value),
child: child, child: child,
onPressed: () { onPressed: () {
switch (controller.status) { switch (controller.status) {

@ -15,7 +15,8 @@ class AnimatedContainerDemo extends StatefulWidget {
static String routeName = 'basics/animated_container'; static String routeName = 'basics/animated_container';
@override @override
State<AnimatedContainerDemo> createState() => _AnimatedContainerDemoState(); State<AnimatedContainerDemo> createState() =>
_AnimatedContainerDemoState();
} }
class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> { class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {

@ -49,14 +49,13 @@ class _FadeTransitionDemoState extends State<FadeTransitionDemo>
children: [ children: [
FadeTransition( FadeTransition(
opacity: _animation, opacity: _animation,
child: const Icon(Icons.star, color: Colors.amber, size: 300), child:
const Icon(Icons.star, color: Colors.amber, size: 300),
), ),
ElevatedButton( ElevatedButton(
child: const Text('animate'), child: const Text('animate'),
onPressed: () => setState(() { onPressed: () => setState(() {
_controller _controller.animateTo(1.0).then<TickerFuture>(
.animateTo(1.0)
.then<TickerFuture>(
(value) => _controller.animateBack(0.0), (value) => _controller.animateBack(0.0),
); );
}), }),

@ -74,7 +74,8 @@ class _TweenSequenceDemoState extends State<TweenSequenceDemo>
child: child, child: child,
); );
}, },
child: const Text('Animate', style: TextStyle(color: Colors.white)), child:
const Text('Animate', style: TextStyle(color: Colors.white)),
), ),
), ),
); );

@ -75,7 +75,9 @@ class _AnimatedListDemoState extends State<AnimatedListDemo> {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text('AnimatedList'), title: const Text('AnimatedList'),
actions: [IconButton(icon: const Icon(Icons.add), onPressed: addUser)], actions: [
IconButton(icon: const Icon(Icons.add), onPressed: addUser)
],
), ),
body: SafeArea( body: SafeArea(
child: AnimatedList( child: AnimatedList(

@ -11,7 +11,8 @@ class AnimatedPositionedDemo extends StatefulWidget {
static String routeName = 'misc/animated_positioned'; static String routeName = 'misc/animated_positioned';
@override @override
State<AnimatedPositionedDemo> createState() => _AnimatedPositionedDemoState(); State<AnimatedPositionedDemo> createState() =>
_AnimatedPositionedDemoState();
} }
class _AnimatedPositionedDemoState extends State<AnimatedPositionedDemo> { class _AnimatedPositionedDemoState extends State<AnimatedPositionedDemo> {
@ -55,7 +56,8 @@ class _AnimatedPositionedDemoState extends State<AnimatedPositionedDemo> {
duration: const Duration(seconds: 1), duration: const Duration(seconds: 1),
child: InkWell( child: InkWell(
onTap: () => changePosition( onTap: () => changePosition(
size.height - (appBar.preferredSize.height + topPadding + 50), size.height -
(appBar.preferredSize.height + topPadding + 50),
size.width - 150, size.width - 150,
), ),
child: Container( child: Container(

@ -27,7 +27,8 @@ class AnimatedSwitcherDemo extends StatefulWidget {
static String routeName = 'misc/animated_switcher'; static String routeName = 'misc/animated_switcher';
@override @override
State<AnimatedSwitcherDemo> createState() => _AnimatedSwitcherDemoState(); State<AnimatedSwitcherDemo> createState() =>
_AnimatedSwitcherDemoState();
} }
class _AnimatedSwitcherDemoState extends State<AnimatedSwitcherDemo> { class _AnimatedSwitcherDemoState extends State<AnimatedSwitcherDemo> {

@ -174,7 +174,8 @@ class _SwipeableCardState extends State<SwipeableCard>
return; return;
} }
var velocity = (details.velocity.pixelsPerSecond.dx / size.width).abs(); var velocity =
(details.velocity.pixelsPerSecond.dx / size.width).abs();
_animate(velocity: velocity); _animate(velocity: velocity);
} }

@ -78,12 +78,16 @@ class _CarouselState extends State<Carousel> {
}, },
controller: _controller, controller: _controller,
scrollBehavior: ScrollConfiguration.of(context).copyWith( scrollBehavior: ScrollConfiguration.of(context).copyWith(
dragDevices: {ui.PointerDeviceKind.touch, ui.PointerDeviceKind.mouse}, dragDevices: {
ui.PointerDeviceKind.touch,
ui.PointerDeviceKind.mouse
},
), ),
itemBuilder: (context, index) => AnimatedBuilder( itemBuilder: (context, index) => AnimatedBuilder(
animation: _controller, animation: _controller,
builder: (context, child) { 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 // The horizontal position of the page between a 1 and 0
var value = result - index; var value = result - index;

@ -64,8 +64,7 @@ class _CurvedAnimationDemoState extends State<CurvedAnimationDemo>
controller.reverse(); controller.reverse();
} }
}); });
animationTranslation = animationTranslation = Tween<Offset>(
Tween<Offset>(
begin: const Offset(-1, 0), begin: const Offset(-1, 0),
end: const Offset(1, 0), end: const Offset(1, 0),
).animate(curvedAnimation) ).animate(curvedAnimation)
@ -123,7 +122,8 @@ class _CurvedAnimationDemoState extends State<CurvedAnimationDemo>
if (newCurve != null) { if (newCurve != null) {
setState(() { setState(() {
selectedReverseCurve = newCurve; selectedReverseCurve = newCurve;
curvedAnimation.reverseCurve = selectedReverseCurve.curve; curvedAnimation.reverseCurve =
selectedReverseCurve.curve;
}); });
} }
}, },

@ -18,8 +18,7 @@ class FlutterAnimateDemo extends StatelessWidget {
body: Center( body: Center(
child: Padding( child: Padding(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
child: child: Text(
Text(
"Hello Flutter Animate", "Hello Flutter Animate",
style: Theme.of(context).textTheme.headlineLarge, style: Theme.of(context).textTheme.headlineLarge,
) )

@ -29,7 +29,8 @@ class Grid extends StatelessWidget {
), ),
itemBuilder: (context, index) { itemBuilder: (context, index) {
return (index >= 20) return (index >= 20)
? const SmallCard(imageAssetName: 'assets/eat_cape_town_sm.jpg') ? const SmallCard(
imageAssetName: 'assets/eat_cape_town_sm.jpg')
: const SmallCard( : const SmallCard(
imageAssetName: 'assets/eat_new_orleans_sm.jpg', imageAssetName: 'assets/eat_new_orleans_sm.jpg',
); );
@ -50,7 +51,9 @@ Route _createRoute(BuildContext parentContext, String image) {
).chain(CurveTween(curve: Curves.ease)).animate(animation); ).chain(CurveTween(curve: Curves.ease)).animate(animation);
return Stack( return Stack(
children: [PositionedTransition(rect: rectAnimation, child: child)], children: [
PositionedTransition(rect: rectAnimation, child: child)
],
); );
}, },
); );

@ -15,11 +15,13 @@ class HeroAnimationDemo extends StatelessWidget {
body: GestureDetector( body: GestureDetector(
child: Hero( child: Hero(
tag: 'hero-page-child', tag: 'hero-page-child',
child: _createHeroContainer(size: 50.0, color: Colors.grey.shade300), child: _createHeroContainer(
size: 50.0, color: Colors.grey.shade300),
), ),
onTap: () => Navigator.of( onTap: () => Navigator.of(
context, context,
).push<void>(MaterialPageRoute(builder: (context) => const HeroPage())), ).push<void>(
MaterialPageRoute(builder: (context) => const HeroPage())),
), ),
); );
} }
@ -51,7 +53,9 @@ StatelessWidget _createHeroContainer({
height: size, height: size,
width: size, width: size,
padding: const EdgeInsets.all(10.0), padding: const EdgeInsets.all(10.0),
margin: size < 100.0 ? const EdgeInsets.all(10.0) : const EdgeInsets.all(0), margin: size < 100.0
? const EdgeInsets.all(10.0)
: const EdgeInsets.all(0),
decoration: BoxDecoration(shape: BoxShape.circle, color: color), decoration: BoxDecoration(shape: BoxShape.circle, color: color),
child: const FlutterLogo(), child: const FlutterLogo(),
); );

@ -78,7 +78,8 @@ class _DraggableCardState extends State<DraggableCard>
void initState() { void initState() {
super.initState(); super.initState();
_controller = AnimationController.unbounded(vsync: this) _controller = AnimationController.unbounded(vsync: this)
..addListener(() => setState(() => _dragAlignment = _animation.value)); ..addListener(
() => setState(() => _dragAlignment = _animation.value));
} }
@override @override

@ -9,7 +9,8 @@ class RepeatingAnimationDemo extends StatefulWidget {
static String routeName = 'misc/repeating_animation'; static String routeName = 'misc/repeating_animation';
@override @override
State<RepeatingAnimationDemo> createState() => _RepeatingAnimationDemoState(); State<RepeatingAnimationDemo> createState() =>
_RepeatingAnimationDemoState();
} }
class _RepeatingAnimationDemoState extends State<RepeatingAnimationDemo> class _RepeatingAnimationDemoState extends State<RepeatingAnimationDemo>

@ -5,7 +5,7 @@ publish_to: none
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -16,7 +16,8 @@ void main() {
// Get the initial color of the button. // Get the initial color of the button.
ElevatedButton button = tester.widget(find.byType(ElevatedButton)); ElevatedButton button = tester.widget(find.byType(ElevatedButton));
WidgetStateProperty<Color?>? initialColor = button.style!.backgroundColor; WidgetStateProperty<Color?>? initialColor =
button.style!.backgroundColor;
// Tap the button. // Tap the button.
await tester.tap(find.byType(ElevatedButton)); await tester.tap(find.byType(ElevatedButton));
@ -24,7 +25,8 @@ void main() {
// Get the updated color of the button. // Get the updated color of the button.
button = tester.widget(find.byType(ElevatedButton)); button = tester.widget(find.byType(ElevatedButton));
WidgetStateProperty<Color?>? updatedColor = button.style!.backgroundColor; WidgetStateProperty<Color?>? updatedColor =
button.style!.backgroundColor;
// Check if the color has changed. // Check if the color has changed.
expect(initialColor, isNot(updatedColor)); expect(initialColor, isNot(updatedColor));
@ -35,7 +37,8 @@ void main() {
// Get the initial color of the button. // Get the initial color of the button.
ElevatedButton button = tester.widget(find.byType(ElevatedButton)); ElevatedButton button = tester.widget(find.byType(ElevatedButton));
WidgetStateProperty<Color?>? initialColor = button.style!.backgroundColor; WidgetStateProperty<Color?>? initialColor =
button.style!.backgroundColor;
// Tap the button to trigger the animation but don't wait for it to finish. // Tap the button to trigger the animation but don't wait for it to finish.
await tester.tap(find.byType(ElevatedButton)); await tester.tap(find.byType(ElevatedButton));
@ -44,7 +47,8 @@ void main() {
// Check that the color has changed but not to the final color. // Check that the color has changed but not to the final color.
button = tester.widget(find.byType(ElevatedButton)); button = tester.widget(find.byType(ElevatedButton));
WidgetStateProperty<Color?>? changedColor = button.style!.backgroundColor; WidgetStateProperty<Color?>? changedColor =
button.style!.backgroundColor;
expect(initialColor, isNot(changedColor)); expect(initialColor, isNot(changedColor));
// Wait for the animation to finish. // Wait for the animation to finish.
@ -52,7 +56,8 @@ void main() {
// Check that the color has changed to the final color. // Check that the color has changed to the final color.
button = tester.widget(find.byType(ElevatedButton)); button = tester.widget(find.byType(ElevatedButton));
WidgetStateProperty<Color?>? finalColor = button.style!.backgroundColor; WidgetStateProperty<Color?>? finalColor =
button.style!.backgroundColor;
expect(changedColor, isNot(finalColor)); expect(changedColor, isNot(finalColor));
}); });
}); });

@ -46,7 +46,8 @@ void main() {
await tester.pumpWidget(createAnimatedListDemoScreen()); await tester.pumpWidget(createAnimatedListDemoScreen());
// Get the initial length of list. // Get the initial length of list.
var initialLength = tester.widgetList(find.byType(ListTile)).length; var initialLength =
tester.widgetList(find.byType(ListTile)).length;
// Tap on the Delete Icon Button at middle index. // Tap on the Delete Icon Button at middle index.
await tester.tap(find.byIcon(Icons.delete).at(initialLength ~/ 2)); await tester.tap(find.byIcon(Icons.delete).at(initialLength ~/ 2));
@ -66,7 +67,8 @@ void main() {
await tester.pumpWidget(createAnimatedListDemoScreen()); await tester.pumpWidget(createAnimatedListDemoScreen());
// Get the initial length of list. // Get the initial length of list.
var initialLength = tester.widgetList(find.byType(ListTile)).length; var initialLength =
tester.widgetList(find.byType(ListTile)).length;
// Tap on the Delete Icon Button at start index. // Tap on the Delete Icon Button at start index.
await tester.tap(find.byIcon(Icons.delete).at(0)); await tester.tap(find.byIcon(Icons.delete).at(0));
@ -86,7 +88,8 @@ void main() {
await tester.pumpWidget(createAnimatedListDemoScreen()); await tester.pumpWidget(createAnimatedListDemoScreen());
// Get the initial length of list. // Get the initial length of list.
var initialLength = tester.widgetList(find.byType(ListTile)).length; var initialLength =
tester.widgetList(find.byType(ListTile)).length;
// Tap on the Delete Icon Button at end index. // Tap on the Delete Icon Button at end index.
await tester.tap(find.byIcon(Icons.delete).at(initialLength - 1)); await tester.tap(find.byIcon(Icons.delete).at(initialLength - 1));

@ -24,7 +24,8 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// Check if removed properly. // Check if removed properly.
expect(tester.widgetList(find.byType(Card)).length, lessThan(totalCards)); expect(tester.widgetList(find.byType(Card)).length,
lessThan(totalCards));
}); });
testWidgets('All cards swiped out', (tester) async { testWidgets('All cards swiped out', (tester) async {
@ -36,7 +37,8 @@ void main() {
// Swipe out all cards. // Swipe out all cards.
for (var i = 0; i < totalCards; i++) { for (var i = 0; i < totalCards; i++) {
// Swipe out one by one. // Swipe out one by one.
await tester.drag(find.byType(Card).last, const Offset(100.0, 0.0)); await tester.drag(
find.byType(Card).last, const Offset(100.0, 0.0));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
} }

@ -18,7 +18,8 @@ void main() {
expect(imageList.length, 2); expect(imageList.length, 2);
// Swipe the Carousel. // Swipe the Carousel.
await tester.fling(find.byType(CarouselDemo), const Offset(-400, 0), 800); await tester.fling(
find.byType(CarouselDemo), const Offset(-400, 0), 800);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// Get the images available on the screen after swipe. // Get the images available on the screen after swipe.

@ -6,7 +6,8 @@ import 'package:animations/src/misc/expand_card.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
Widget createExpandCardScreen() => const MaterialApp(home: ExpandCardDemo()); Widget createExpandCardScreen() =>
const MaterialApp(home: ExpandCardDemo());
void main() { void main() {
group('ExpandCard Tests', () { group('ExpandCard Tests', () {
@ -22,7 +23,8 @@ void main() {
// The size of ExpandCard must change once tapped. // The size of ExpandCard must change once tapped.
// The initialSize should be less than current ExpandCard size. // The initialSize should be less than current ExpandCard size.
expect(initialSize, lessThan(tester.getSize(find.byType(ExpandCard)))); expect(
initialSize, lessThan(tester.getSize(find.byType(ExpandCard))));
}); });
testWidgets('ExpandCard changes image on tap', (tester) async { testWidgets('ExpandCard changes image on tap', (tester) async {

@ -6,7 +6,8 @@ import 'package:animations/src/misc/focus_image.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
Widget createFocusImageScreen() => const MaterialApp(home: FocusImageDemo()); Widget createFocusImageScreen() =>
const MaterialApp(home: FocusImageDemo());
void main() { void main() {
group('FocusImage Tests', () { group('FocusImage Tests', () {
@ -33,7 +34,8 @@ void main() {
expect(finalSize, greaterThan(initialSize)); expect(finalSize, greaterThan(initialSize));
}); });
testWidgets('Final inkwell on tap goes back to the grid', (tester) async { testWidgets('Final inkwell on tap goes back to the grid',
(tester) async {
await tester.pumpWidget(createFocusImageScreen()); await tester.pumpWidget(createFocusImageScreen());
// Tap on the ink well at index 0. // Tap on the ink well at index 0.

@ -58,7 +58,8 @@ void main() {
// Final color should not be same as initial color. // Final color should not be same as initial color.
expect( expect(
(finalContainer.decoration as BoxDecoration).color, (finalContainer.decoration as BoxDecoration).color,
isNot(equals((initialContainer.decoration as BoxDecoration).color)), isNot(
equals((initialContainer.decoration as BoxDecoration).color)),
); );
}); });
@ -66,7 +67,8 @@ void main() {
await tester.pumpWidget(createHeroAnimationDemoScreen()); await tester.pumpWidget(createHeroAnimationDemoScreen());
// Get the initial Screen. // Get the initial Screen.
final initialScreen = tester.firstWidget(find.byType(HeroAnimationDemo)); final initialScreen =
tester.firstWidget(find.byType(HeroAnimationDemo));
// Tap on the GestureDetector. // Tap on the GestureDetector.
await tester.tap(find.byType(GestureDetector)); await tester.tap(find.byType(GestureDetector));

@ -3,7 +3,7 @@ description: A sample command-line application.
version: 1.0.0 version: 1.0.0
environment: environment:
sdk: '>=3.9.0-0 <4.0.0' sdk: ^3.9.0-0
dependencies: dependencies:
args: ^2.4.2 args: ^2.4.2

@ -5,7 +5,7 @@ version: 0.1.0
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -65,12 +65,12 @@ class _MyHomePageState extends State<MyHomePage> {
// Write the value to [SharedPreferences] which will get read on the // Write the value to [SharedPreferences] which will get read on the
// [SimpleDatabase]'s isolate. For this example the value is always true // [SimpleDatabase]'s isolate. For this example the value is always true
// just for demonstration purposes. // just for demonstration purposes.
final Future<void> sharedPreferencesSet = SharedPreferences.getInstance() final Future<void> sharedPreferencesSet =
.then( SharedPreferences.getInstance().then(
(sharedPreferences) => sharedPreferences.setBool('isDebug', true), (sharedPreferences) => sharedPreferences.setBool('isDebug', true),
); );
final Future<Directory> tempDirFuture = path_provider final Future<Directory> tempDirFuture =
.getTemporaryDirectory(); path_provider.getTemporaryDirectory();
// Wait until the [SharedPreferences] value is set and the temporary // Wait until the [SharedPreferences] value is set and the temporary
// directory is received before opening the database. If // directory is received before opening the database. If

@ -181,14 +181,16 @@ class _SimpleDatabaseServer {
// obtained on the root isolate and passed into the background isolate via // obtained on the root isolate and passed into the background isolate via
// a [SendPort]. // a [SendPort].
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
RootIsolateToken rootIsolateToken = command.arg1 as RootIsolateToken; RootIsolateToken rootIsolateToken =
command.arg1 as RootIsolateToken;
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// [BackgroundIsolateBinaryMessenger.ensureInitialized] for each // [BackgroundIsolateBinaryMessenger.ensureInitialized] for each
// background isolate that will use plugins. This sets up the // background isolate that will use plugins. This sets up the
// [BinaryMessenger] that the Platform Channels will communicate with on // [BinaryMessenger] that the Platform Channels will communicate with on
// the background isolate. // the background isolate.
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
BackgroundIsolateBinaryMessenger.ensureInitialized(rootIsolateToken); BackgroundIsolateBinaryMessenger.ensureInitialized(
rootIsolateToken);
_sendPort.send(const _Command(_Codes.ack, arg0: null)); _sendPort.send(const _Command(_Codes.ack, arg0: null));
case _Codes.add: case _Codes.add:
_doAddEntry(command.arg0 as String); _doAddEntry(command.arg0 as String);

@ -7,7 +7,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1 version: 1.0.0+1
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
cupertino_icons: ^1.0.2 cupertino_icons: ^1.0.2

@ -5,7 +5,7 @@ version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
cupertino_icons: ^1.0.2 cupertino_icons: ^1.0.2

@ -5,7 +5,7 @@ publish_to: "none"
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
args: ^2.0.0 args: ^2.0.0

@ -4,7 +4,7 @@ version: 1.0.0
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
freezed_annotation: ">=2.1.0 <4.0.0" freezed_annotation: ">=2.1.0 <4.0.0"

@ -5,7 +5,7 @@ publish_to: none
version: 0.1.0 version: 0.1.0
environment: environment:
sdk: '>=3.9.0-0 <4.0.0' sdk: ^3.9.0-0
dependencies: dependencies:
cached_network_image: ^3.4.1 cached_network_image: ^3.4.1

@ -4,7 +4,7 @@ publish_to: 'none'
version: 1.0.0 version: 1.0.0
environment: environment:
sdk: '>=3.9.0-0 <4.0.0' sdk: ^3.9.0-0
dependencies: dependencies:
args: ^2.4.0 args: ^2.4.0

@ -22,7 +22,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
# Dependencies specify other packages that your package needs in order to work. # Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions # To automatically upgrade your package dependencies to the latest versions

@ -5,7 +5,7 @@ version: 0.1.0
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -22,7 +22,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
# Dependencies specify other packages that your package needs in order to work. # Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions # To automatically upgrade your package dependencies to the latest versions

@ -5,7 +5,7 @@ version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
built_collection: ^5.1.1 built_collection: ^5.1.1

@ -5,7 +5,7 @@ version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
built_collection: ^5.1.1 built_collection: ^5.1.1

@ -4,7 +4,7 @@ publish_to: 'none'
version: 1.0.0+1 version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -5,7 +5,7 @@ version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -8,7 +8,7 @@ publish_to: 'none'
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -4,7 +4,7 @@ publish_to: 'none'
version: 1.0.0+1 version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -5,7 +5,7 @@ publish_to: 'none'
version: 1.0.0+1 version: 1.0.0+1
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -6,7 +6,7 @@ resolution: workspace
version: 1.0.0+1 version: 1.0.0+1
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -5,7 +5,7 @@ version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -5,7 +5,7 @@ publish_to: none
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -7,7 +7,7 @@ version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -5,7 +5,7 @@ version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
adaptive_navigation: ^0.0.3 adaptive_navigation: ^0.0.3

@ -22,7 +22,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
# Dependencies specify other packages that your package needs in order to work. # Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions # To automatically upgrade your package dependencies to the latest versions

@ -5,7 +5,7 @@ publish_to: none
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -4,7 +4,7 @@ version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -4,7 +4,7 @@ version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -4,7 +4,7 @@ version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
english_words: ^4.0.0 english_words: ^4.0.0

@ -4,7 +4,7 @@ version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -6,7 +6,7 @@ version: 1.0.0
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -5,7 +5,7 @@ version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -2,7 +2,7 @@ name: samples
description: A collection of samples for Dart and Flutter. description: A collection of samples for Dart and Flutter.
environment: environment:
sdk: '^3.5.0' sdk: ^3.9.0-0
workspace: workspace:
- add_to_app/android_view/flutter_module_using_plugin - add_to_app/android_view/flutter_module_using_plugin

@ -5,7 +5,7 @@ version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -5,7 +5,7 @@ version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
auto_size_text: ^3.0.0 auto_size_text: ^3.0.0

@ -20,7 +20,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
# Dependencies specify other packages that your package needs in order to work. # Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions # To automatically upgrade your package dependencies to the latest versions

@ -4,7 +4,7 @@ version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -1,7 +1,7 @@
name: release_cleaner name: release_cleaner
description: A tool to automate release cleanup for the samples monorepo. description: A tool to automate release cleanup for the samples monorepo.
environment: environment:
sdk: '>=3.0.0 <4.0.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
args: ^2.4.2 args: ^2.4.2

@ -91,14 +91,14 @@ void setupLogging() {
logsDir.createSync(recursive: true); logsDir.createSync(recursive: true);
} }
final timestamp = DateTime.now().toIso8601String().replaceAll(':', '-'); final timestamp = DateTime.now().toIso8601String().replaceAll(':', '-');
_logFile = File(p.join(logDir, 'flutter_update_$timestamp.log')); _logFile = File(p.join(logDir, 'release_logs_$timestamp.log'));
} }
void log(String? message, IOSink sink) { void log(String? message, IOSink sink) {
if (message == null) return; if (message == null) return;
sink.writeln(message); sink.writeln(message);
_logFile.writeAsStringSync( _logFile.writeAsStringSync(
'${overrideAnsiOutput(false, () => message)}\n', resetAll.wrap('$message\n')!,
mode: FileMode.append, mode: FileMode.append,
); );
} }
@ -207,9 +207,7 @@ Future<bool> updateSdkConstraints(
} }
try { try {
final version = Version.parse(versionString); final newConstraint = '^${versionString}-0';
final nextMajor = version.major + 1;
final newConstraint = "'>=${version} <$nextMajor.0.0'";
final content = await pubspecFile.readAsString(); final content = await pubspecFile.readAsString();
final editor = YamlEditor(content); final editor = YamlEditor(content);

@ -5,7 +5,7 @@ version: 1.2.0
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -5,7 +5,7 @@ version: 1.0.0+1
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -5,7 +5,7 @@ version: 1.0.0
resolution: workspace resolution: workspace
environment: environment:
sdk: '^3.5.0' sdk: '>=3.9.0 <4.0.0'
dependencies: dependencies:
flutter: flutter:

@ -1,6 +1,8 @@
You are a Dart developer that maintains packages. Your current task is to incrementally update monorepos to use pub workspaces. You are a Dart developer that maintains this monorepo of Flutter sample projects.
- Read https://dart.dev/tools/pub/workspaces - Read https://dart.dev/tools/pub/workspaces
- Create a gloabl pubspec.yaml and populate it - Create a gloabl pubspec.yaml and populate it
- Determine 5 packages in this repository that could easily be migrated to workspaces. - Determine 5 packages in this repository that could easily be migrated to workspaces.
- Migrate those 5 packages. - Migrate those 5 packages.

Loading…
Cancel
Save