Flutter 3.29 beta (#2571)

pull/2583/head
Eric Windmill 7 months ago committed by GitHub
parent d62c784789
commit 719fd72c38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -62,8 +62,12 @@ class _CellState extends State<Cell> with WidgetsBindingObserver {
Color randomLightColor() { Color randomLightColor() {
_random ??= Random(cellNumber); _random ??= Random(cellNumber);
return Color.fromARGB(255, _random!.nextInt(50) + 205, return Color.fromARGB(
_random!.nextInt(50) + 205, _random!.nextInt(50) + 205); 255,
_random!.nextInt(50) + 205,
_random!.nextInt(50) + 205,
_random!.nextInt(50) + 205,
);
} }
@override @override
@ -108,7 +112,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,
@ -117,11 +122,15 @@ class _CellState extends State<Cell> with WidgetsBindingObserver {
// 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: Matrix4.rotationX( transform: Matrix4.rotationX(
snapshot.data!.y / gravity * pi / 2) snapshot.data!.y / gravity * pi / 2,
..multiply(Matrix4.rotationY( )..multiply(
snapshot.data!.x / gravity * pi / 2)), Matrix4.rotationY(
snapshot.data!.x / gravity * pi / 2,
),
),
alignment: Alignment.center, alignment: Alignment.center,
child: const FlutterLogo(size: 72)); child: const FlutterLogo(size: 72),
);
}, },
), ),
), ),

@ -17,12 +17,7 @@ void main() {
final model = CounterModel(); final model = CounterModel();
runApp( runApp(ChangeNotifierProvider.value(value: model, child: const MyApp()));
ChangeNotifierProvider.value(
value: model,
child: const MyApp(),
),
);
} }
/// This is on alternate entrypoint for this module to display Flutter UI in /// This is on alternate entrypoint for this module to display Flutter UI in
@ -76,9 +71,7 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
title: 'Flutter Module Title', title: 'Flutter Module Title',
theme: ThemeData( theme: ThemeData(colorSchemeSeed: Colors.blue),
colorSchemeSeed: Colors.blue,
),
routes: { routes: {
'/': (context) => const FullScreenView(), '/': (context) => const FullScreenView(),
'/mini': (context) => const Contents(), '/mini': (context) => const Contents(),
@ -95,9 +88,7 @@ class FullScreenView extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: const Text('Full-screen Flutter with plugin')),
title: const Text('Full-screen Flutter with plugin'),
),
body: const Contents(showExit: true), body: const Contents(showExit: true),
); );
} }
@ -131,10 +122,7 @@ class Contents extends StatelessWidget {
const Positioned.fill( const Positioned.fill(
child: Opacity( child: Opacity(
opacity: .25, opacity: .25,
child: FittedBox( child: FittedBox(fit: BoxFit.cover, child: FlutterLogo()),
fit: BoxFit.cover,
child: FlutterLogo(),
),
), ),
), ),
Center( Center(

@ -4,7 +4,7 @@ description: An example Flutter module that uses a plugin.
version: 1.0.0+1 version: 1.0.0+1
environment: environment:
sdk: ^3.5.0 sdk: ^3.7.0-0
dependencies: dependencies:
flutter: flutter:

@ -13,9 +13,7 @@ class MyApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
theme: ThemeData( theme: ThemeData(primaryColor: const Color(0xff6200ee)),
primaryColor: const Color(0xff6200ee),
),
home: const BookDetail(), home: const BookDetail(),
); );
} }
@ -70,7 +68,8 @@ class _BookDetailState extends State<BookDetail> {
// calls from the platform. // calls from the platform.
// TODO(gaaclarke): make the setup method an instance method so it's // TODO(gaaclarke): make the setup method an instance method so it's
// injectable https://github.com/flutter/flutter/issues/59119. // injectable https://github.com/flutter/flutter/issues/59119.
FlutterBookApi.setup(FlutterBookApiHandler( FlutterBookApi.setup(
FlutterBookApiHandler(
// The `FlutterBookApi` just has one method. Just give a closure for that // The `FlutterBookApi` just has one method. Just give a closure for that
// method to the handler class. // method to the handler class.
(book) { (book) {
@ -93,7 +92,9 @@ class _BookDetailState extends State<BookDetail> {
this.book!.author = authorTextController.text; this.book!.author = authorTextController.text;
}); });
}); });
})); },
),
);
} }
// Not overriding didUpdateWidget because the Android program can't change // Not overriding didUpdateWidget because the Android program can't change
@ -124,7 +125,8 @@ class _BookDetailState extends State<BookDetail> {
IconButton( IconButton(
icon: const Icon(Icons.check), icon: const Icon(Icons.check),
// Pressing save sends the updated book to the platform. // Pressing save sends the updated book to the platform.
onPressed: book != null onPressed:
book != null
? () { ? () {
hostApi.finishEditingBook(book!); hostApi.finishEditingBook(book!);
clear(); clear();
@ -133,7 +135,8 @@ class _BookDetailState extends State<BookDetail> {
), ),
], ],
), ),
body: book == null body:
book == null
// Draw a spinner until the platform gives us the book to show details // Draw a spinner until the platform gives us the book to show details
// for. // for.
? const Center(child: CircularProgressIndicator()) ? const Center(child: CircularProgressIndicator())
@ -207,15 +210,14 @@ class BookForm extends StatelessWidget {
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Text( child: Text(
'${book.pageCount} pages ~ published ${book.publishDate}'), '${book.pageCount} pages ~ published ${book.publishDate}',
),
), ),
), ),
const Divider(), const Divider(),
const SizedBox(height: 32), const SizedBox(height: 32),
if (book.thumbnail?.url != null) ...[ if (book.thumbnail?.url != null) ...[
Center( Center(child: Image.network(book.thumbnail!.url!)),
child: Image.network(book.thumbnail!.url!),
),
const SizedBox(height: 32), const SizedBox(height: 32),
], ],
if (book.summary != null) ...[ if (book.summary != null) ...[
@ -234,7 +236,7 @@ class BookForm extends StatelessWidget {
book.summary ?? '', book.summary ?? '',
style: TextStyle(color: Colors.grey.shade600, height: 1.24), style: TextStyle(color: Colors.grey.shade600, height: 1.24),
), ),
] ],
], ],
), ),
); );

@ -6,7 +6,7 @@ description: A Flutter module using the Pigeon package to demonstrate
version: 1.0.0+1 version: 1.0.0+1
environment: environment:
sdk: ^3.5.0 sdk: ^3.7.0-0
dependencies: dependencies:
flutter: flutter:

@ -12,9 +12,7 @@ void main() {
MockHostBookApi mockHostApi = MockHostBookApi(); MockHostBookApi mockHostApi = MockHostBookApi();
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(home: BookDetail(hostApi: mockHostApi)),
home: BookDetail(hostApi: mockHostApi),
),
); );
await tester.tap(find.byIcon(Icons.clear)); await tester.tap(find.byIcon(Icons.clear));
@ -26,9 +24,7 @@ void main() {
MockHostBookApi mockHostApi = MockHostBookApi(); MockHostBookApi mockHostApi = MockHostBookApi();
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(home: BookDetail(book: Book(), hostApi: mockHostApi)),
home: BookDetail(book: Book(), hostApi: mockHostApi),
),
); );
await tester.tap(find.byIcon(Icons.check)); await tester.tap(find.byIcon(Icons.check));

@ -14,12 +14,7 @@ void main() {
final model = CounterModel(); final model = CounterModel();
runApp( runApp(ChangeNotifierProvider.value(value: model, child: const MyApp()));
ChangeNotifierProvider.value(
value: model,
child: const MyApp(),
),
);
} }
/// A simple model that uses a [MethodChannel] as the source of truth for the /// A simple model that uses a [MethodChannel] as the source of truth for the
@ -81,9 +76,7 @@ class FullScreenView extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: const Text('Full-screen Flutter')),
title: const Text('Full-screen Flutter'),
),
body: const Contents(showExit: true), body: const Contents(showExit: true),
); );
} }
@ -116,10 +109,7 @@ class Contents extends StatelessWidget {
const Positioned.fill( const Positioned.fill(
child: Opacity( child: Opacity(
opacity: .25, opacity: .25,
child: FittedBox( child: FittedBox(fit: BoxFit.cover, child: FlutterLogo()),
fit: BoxFit.cover,
child: FlutterLogo(),
),
), ),
), ),
Center( Center(

@ -4,7 +4,7 @@ description: An example Flutter module.
version: 1.0.0+1 version: 1.0.0+1
environment: environment:
sdk: ^3.5.0 sdk: ^3.7.0-0
dependencies: dependencies:
flutter: flutter:

@ -72,24 +72,17 @@ class _MyHomePageState extends State<MyHomePage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: Text(widget.title)),
title: Text(widget.title),
),
body: Center( body: Center(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
const Text( const Text('You have pushed the button this many times:'),
'You have pushed the button this many times:',
),
Text( Text(
'$_counter', '$_counter',
style: Theme.of(context).textTheme.headlineMedium, style: Theme.of(context).textTheme.headlineMedium,
), ),
TextButton( TextButton(onPressed: _incrementCounter, child: const Text('Add')),
onPressed: _incrementCounter,
child: const Text('Add'),
),
TextButton( TextButton(
onPressed: () { onPressed: () {
_channel.invokeMethod<void>("next", _counter); _channel.invokeMethod<void>("next", _counter);

@ -4,7 +4,7 @@ description: A module that is embedded in the multiple_flutters_ios and multiple
version: 1.0.0+1 version: 1.0.0+1
environment: environment:
sdk: ^3.5.0 sdk: ^3.7.0-0
dependencies: dependencies:
flutter: flutter:

@ -62,8 +62,12 @@ class _CellState extends State<Cell> with WidgetsBindingObserver {
Color randomLightColor() { Color randomLightColor() {
_random ??= Random(cellNumber); _random ??= Random(cellNumber);
return Color.fromARGB(255, _random!.nextInt(50) + 205, return Color.fromARGB(
_random!.nextInt(50) + 205, _random!.nextInt(50) + 205); 255,
_random!.nextInt(50) + 205,
_random!.nextInt(50) + 205,
_random!.nextInt(50) + 205,
);
} }
@override @override
@ -108,7 +112,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,
@ -123,7 +128,8 @@ class _CellState extends State<Cell> with WidgetsBindingObserver {
transform: Matrix4.rotationX( transform: 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),
); );

@ -17,12 +17,7 @@ void main() {
final model = CounterModel(); final model = CounterModel();
runApp( runApp(ChangeNotifierProvider.value(value: model, child: const MyApp()));
ChangeNotifierProvider.value(
value: model,
child: const MyApp(),
),
);
} }
/// This is on alternate entrypoint for this module to display Flutter UI in /// This is on alternate entrypoint for this module to display Flutter UI in
@ -92,9 +87,7 @@ class FullScreenView extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: const Text('Full-screen Flutter with plugin')),
title: const Text('Full-screen Flutter with plugin'),
),
body: const Contents(showExit: true), body: const Contents(showExit: true),
); );
} }
@ -128,10 +121,7 @@ class Contents extends StatelessWidget {
const Positioned.fill( const Positioned.fill(
child: Opacity( child: Opacity(
opacity: .25, opacity: .25,
child: FittedBox( child: FittedBox(fit: BoxFit.cover, child: FlutterLogo()),
fit: BoxFit.cover,
child: FlutterLogo(),
),
), ),
), ),
Center( Center(

@ -4,7 +4,7 @@ description: An example Flutter module that uses a plugin.
version: 1.0.0+1 version: 1.0.0+1
environment: environment:
sdk: ^3.5.0 sdk: ^3.7.0-0
dependencies: dependencies:
flutter: flutter:

@ -14,12 +14,7 @@ void main() {
final model = CounterModel(); final model = CounterModel();
runApp( runApp(ChangeNotifierProvider.value(value: model, child: const MyApp()));
ChangeNotifierProvider.value(
value: model,
child: const MyApp(),
),
);
} }
/// A simple model that uses a [MethodChannel] as the source of truth for the /// A simple model that uses a [MethodChannel] as the source of truth for the
@ -81,9 +76,7 @@ class FullScreenView extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: const Text('Full-screen Flutter')),
title: const Text('Full-screen Flutter'),
),
body: const Contents(showExit: true), body: const Contents(showExit: true),
); );
} }
@ -116,10 +109,7 @@ class Contents extends StatelessWidget {
const Positioned.fill( const Positioned.fill(
child: Opacity( child: Opacity(
opacity: .25, opacity: .25,
child: FittedBox( child: FittedBox(fit: BoxFit.cover, child: FlutterLogo()),
fit: BoxFit.cover,
child: FlutterLogo(),
),
), ),
), ),
Center( Center(

@ -4,7 +4,7 @@ description: An example Flutter module.
version: 1.0.0+1 version: 1.0.0+1
environment: environment:
sdk: ^3.5.0 sdk: ^3.7.0-0
dependencies: dependencies:
flutter: flutter:

@ -3,7 +3,7 @@ description: Analysis defaults for flutter/samples
publish_to: none publish_to: none
environment: environment:
sdk: ^3.5.0 sdk: ^3.7.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`.

@ -28,9 +28,7 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
title: 'Flutter Demo', title: 'Flutter Demo',
theme: ThemeData( theme: ThemeData(primarySwatch: Colors.blue),
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'), home: const MyHomePage(title: 'Flutter Demo Home Page'),
); );
} }
@ -63,10 +61,11 @@ class _MyHomePageState extends State<MyHomePage> {
const Padding( const Padding(
padding: EdgeInsets.only(top: 42, bottom: 250), padding: EdgeInsets.only(top: 42, bottom: 250),
child: Align( child: Align(
alignment: Alignment.topCenter, child: CustomAppBar())), alignment: Alignment.topCenter,
const Text( child: CustomAppBar(),
'You have pushed the button this many times:', ),
), ),
const Text('You have pushed the button this many times:'),
Text( Text(
'$_counter', '$_counter',
style: Theme.of(context).textTheme.headlineMedium, style: Theme.of(context).textTheme.headlineMedium,
@ -105,8 +104,10 @@ class CustomAppBar extends StatelessWidget {
), ),
const Padding( const Padding(
padding: EdgeInsets.only(top: 3), padding: EdgeInsets.only(top: 3),
child: Text("Super Splash Screen Demo", child: Text(
style: TextStyle(color: Colors.black54, fontSize: 24)), "Super Splash Screen Demo",
style: TextStyle(color: Colors.black54, fontSize: 24),
),
), ),
], ],
); );

@ -6,7 +6,7 @@ publish_to: "none"
version: 1.0.0+1 version: 1.0.0+1
environment: environment:
sdk: ^3.5.0 sdk: ^3.7.0-0
dependencies: dependencies:
flutter: flutter:

@ -27,11 +27,13 @@ void setupWindow() {
setWindowMinSize(const Size(windowWidth, windowHeight)); setWindowMinSize(const Size(windowWidth, windowHeight));
setWindowMaxSize(const Size(windowWidth, windowHeight)); setWindowMaxSize(const Size(windowWidth, windowHeight));
getCurrentScreen().then((screen) { getCurrentScreen().then((screen) {
setWindowFrame(Rect.fromCenter( setWindowFrame(
Rect.fromCenter(
center: screen!.frame.center, center: screen!.frame.center,
width: windowWidth, width: windowWidth,
height: windowHeight, height: windowHeight,
)); ),
);
}); });
} }
} }
@ -41,11 +43,7 @@ class Demo {
final String route; final String route;
final WidgetBuilder builder; final WidgetBuilder builder;
const Demo({ const Demo({required this.name, required this.route, required this.builder});
required this.name,
required this.route,
required this.builder,
});
} }
final basicDemos = [ final basicDemos = [
@ -182,9 +180,7 @@ class AnimationSamples extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp.router( return MaterialApp.router(
title: 'Animation Samples', title: 'Animation Samples',
theme: ThemeData( theme: ThemeData(colorSchemeSeed: Colors.deepPurple),
colorSchemeSeed: Colors.deepPurple,
),
routerConfig: router, routerConfig: router,
); );
} }
@ -197,9 +193,7 @@ class HomePage extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final headerStyle = Theme.of(context).textTheme.titleLarge; final headerStyle = Theme.of(context).textTheme.titleLarge;
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: const Text('Animation Samples')),
title: const Text('Animation Samples'),
),
body: ListView( body: ListView(
children: [ children: [
ListTile(title: Text('Basics', style: headerStyle)), ListTile(title: Text('Basics', style: headerStyle)),

@ -24,8 +24,10 @@ class _AnimatedBuilderDemoState extends State<AnimatedBuilderDemo>
void initState() { void initState() {
super.initState(); super.initState();
controller = AnimationController(vsync: this, duration: duration); controller = AnimationController(vsync: this, duration: duration);
animation = animation = ColorTween(
ColorTween(begin: beginColor, end: endColor).animate(controller); begin: beginColor,
end: endColor,
).animate(controller);
} }
@override @override
@ -37,9 +39,7 @@ class _AnimatedBuilderDemoState extends State<AnimatedBuilderDemo>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: const Text('AnimatedBuilder')),
title: const Text('AnimatedBuilder'),
),
body: Center( body: Center(
// AnimatedBuilder handles listening to a given animation and calling the builder // AnimatedBuilder handles listening to a given animation and calling the builder
// whenever the value of the animation change. This can be useful when a Widget // whenever the value of the animation change. This can be useful when a Widget
@ -49,9 +49,7 @@ class _AnimatedBuilderDemoState extends State<AnimatedBuilderDemo>
animation: animation, animation: animation,
builder: (context, child) { builder: (context, child) {
return ElevatedButton( return ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(backgroundColor: animation.value),
backgroundColor: animation.value,
),
child: child, child: child,
onPressed: () { onPressed: () {
switch (controller.status) { switch (controller.status) {

@ -49,9 +49,7 @@ class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
// the properties of a container. For example, you could use this to design expanding // the properties of a container. For example, you could use this to design expanding
// and shrinking cards. // and shrinking cards.
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: const Text('AnimatedContainer')),
title: const Text('AnimatedContainer'),
),
body: Center( body: Center(
child: Column( child: Column(
children: [ children: [
@ -71,9 +69,7 @@ class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
), ),
), ),
ElevatedButton( ElevatedButton(
child: const Text( child: const Text('change'),
'change',
),
onPressed: () => change(), onPressed: () => change(),
), ),
], ],

@ -54,9 +54,7 @@ class _AnimationControllerDemoState extends State<AnimationControllerDemo>
// when building child widgets. You can also check the status to see if the animation // when building child widgets. You can also check the status to see if the animation
// has completed. // has completed.
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: const Text('Animation Controller')),
title: const Text('Animation Controller'),
),
body: Center( body: Center(
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@ -79,7 +77,7 @@ class _AnimationControllerDemoState extends State<AnimationControllerDemo>
controller.forward(); controller.forward();
} }
}, },
) ),
], ],
), ),
), ),

@ -89,7 +89,9 @@ class _CustomTweenDemoState extends State<CustomTweenDemo>
return Text( return Text(
animation.value, animation.value,
style: const TextStyle( style: const TextStyle(
fontSize: 16, fontFamily: 'SpecialElite'), fontSize: 16,
fontFamily: 'SpecialElite',
),
); );
}, },
), ),

@ -30,10 +30,7 @@ class _FadeTransitionDemoState extends State<FadeTransitionDemo>
_curve = CurvedAnimation(parent: _controller, curve: Curves.easeIn); _curve = CurvedAnimation(parent: _controller, curve: Curves.easeIn);
_animation = Tween( _animation = Tween(begin: 1.0, end: 0.0).animate(_curve);
begin: 1.0,
end: 0.0,
).animate(_curve);
} }
@override @override
@ -45,28 +42,24 @@ class _FadeTransitionDemoState extends State<FadeTransitionDemo>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: const Text('Fade Transition')),
title: const Text(
'Fade Transition',
),
),
body: Center( body: Center(
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
FadeTransition( FadeTransition(
opacity: _animation, opacity: _animation,
child: const Icon( child: const Icon(Icons.star, color: Colors.amber, size: 300),
Icons.star,
color: Colors.amber,
size: 300,
),
), ),
ElevatedButton( ElevatedButton(
child: const Text('animate'), child: const Text('animate'),
onPressed: () => setState(() { onPressed:
_controller.animateTo(1.0).then<TickerFuture>( () => setState(() {
(value) => _controller.animateBack(0.0)); _controller
.animateTo(1.0)
.then<TickerFuture>(
(value) => _controller.animateBack(0.0),
);
}), }),
), ),
], ],

@ -11,9 +11,7 @@ class PageRouteBuilderDemo extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: const Text('Page 1')),
title: const Text('Page 1'),
),
body: Center( body: Center(
child: ElevatedButton( child: ElevatedButton(
child: const Text('Go!'), child: const Text('Go!'),
@ -30,8 +28,10 @@ Route _createRoute() {
return PageRouteBuilder<SlideTransition>( return PageRouteBuilder<SlideTransition>(
pageBuilder: (context, animation, secondaryAnimation) => _Page2(), pageBuilder: (context, animation, secondaryAnimation) => _Page2(),
transitionsBuilder: (context, animation, secondaryAnimation, child) { transitionsBuilder: (context, animation, secondaryAnimation, child) {
var tween = var tween = Tween<Offset>(
Tween<Offset>(begin: const Offset(0.0, 1.0), end: Offset.zero); begin: const Offset(0.0, 1.0),
end: Offset.zero,
);
var curveTween = CurveTween(curve: Curves.ease); var curveTween = CurveTween(curve: Curves.ease);
return SlideTransition( return SlideTransition(
@ -46,12 +46,12 @@ class _Page2 extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: const Text('Page 2')),
title: const Text('Page 2'),
),
body: Center( body: Center(
child: child: Text(
Text('Page 2!', style: Theme.of(context).textTheme.headlineMedium), 'Page 2!',
style: Theme.of(context).textTheme.headlineMedium,
),
), ),
); );
} }

@ -60,9 +60,7 @@ class _TweenSequenceDemoState extends State<TweenSequenceDemo>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: const Text('Tween Sequences')),
title: const Text('Tween Sequences'),
),
body: Center( body: Center(
child: AnimatedBuilder( child: AnimatedBuilder(
animation: animation, animation: animation,

@ -40,27 +40,25 @@ class _TweenDemoState extends State<TweenDemo>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: const Text('Tweens')),
title: const Text('Tweens'),
),
body: Center( body: Center(
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
ConstrainedBox( ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 200), constraints: const BoxConstraints(maxWidth: 200),
child: Text('\$${animation.value.toStringAsFixed(2)}', child: Text(
style: const TextStyle(fontSize: 24)), '\$${animation.value.toStringAsFixed(2)}',
style: const TextStyle(fontSize: 24),
),
), ),
ElevatedButton( ElevatedButton(
child: Text( child: Text(switch (controller.status) {
switch (controller.status) {
AnimationStatus.completed => 'Buy a Mansion', AnimationStatus.completed => 'Buy a Mansion',
AnimationStatus.forward => 'Accruing...', AnimationStatus.forward => 'Accruing...',
AnimationStatus.reverse => 'Spending...', AnimationStatus.reverse => 'Spending...',
_ => 'Win the lottery', _ => 'Win the lottery',
}, }),
),
onPressed: () { onPressed: () {
switch (controller.status) { switch (controller.status) {
case AnimationStatus.completed: case AnimationStatus.completed:
@ -69,7 +67,7 @@ class _TweenDemoState extends State<TweenDemo>
controller.forward(); controller.forward();
} }
}, },
) ),
], ],
), ),
), ),

@ -26,11 +26,11 @@ class _AnimatedListDemoState extends State<AnimatedListDemo> {
void addUser() { void addUser() {
setState(() { setState(() {
var index = listData.length; var index = listData.length;
listData.add( listData.add(UserModel(++_maxIdValue, 'New', 'Person'));
UserModel(++_maxIdValue, 'New', 'Person'), _listKey.currentState!.insertItem(
index,
duration: const Duration(milliseconds: 300),
); );
_listKey.currentState!
.insertItem(index, duration: const Duration(milliseconds: 300));
}); });
} }
@ -38,22 +38,22 @@ class _AnimatedListDemoState extends State<AnimatedListDemo> {
setState(() { setState(() {
final index = listData.indexWhere((u) => u.id == id); final index = listData.indexWhere((u) => u.id == id);
var user = listData.removeAt(index); var user = listData.removeAt(index);
_listKey.currentState!.removeItem( _listKey.currentState!.removeItem(index, (context, animation) {
index,
(context, animation) {
return FadeTransition( return FadeTransition(
opacity: CurvedAnimation( opacity: CurvedAnimation(
parent: animation, curve: const Interval(0.5, 1.0)), parent: animation,
curve: const Interval(0.5, 1.0),
),
child: SizeTransition( child: SizeTransition(
sizeFactor: CurvedAnimation( sizeFactor: CurvedAnimation(
parent: animation, curve: const Interval(0.0, 1.0)), parent: animation,
curve: const Interval(0.0, 1.0),
),
axisAlignment: 0.0, axisAlignment: 0.0,
child: _buildItem(user), child: _buildItem(user),
), ),
); );
}, }, duration: const Duration(milliseconds: 600));
duration: const Duration(milliseconds: 600),
);
}); });
} }
@ -62,9 +62,7 @@ class _AnimatedListDemoState extends State<AnimatedListDemo> {
key: ValueKey<UserModel>(user), key: ValueKey<UserModel>(user),
title: Text(user.firstName), title: Text(user.firstName),
subtitle: Text(user.lastName), subtitle: Text(user.lastName),
leading: const CircleAvatar( leading: const CircleAvatar(child: Icon(Icons.person)),
child: Icon(Icons.person),
),
trailing: IconButton( trailing: IconButton(
icon: const Icon(Icons.delete), icon: const Icon(Icons.delete),
onPressed: () => deleteUser(user.id), onPressed: () => deleteUser(user.id),
@ -77,12 +75,7 @@ class _AnimatedListDemoState extends State<AnimatedListDemo> {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text('AnimatedList'), title: const Text('AnimatedList'),
actions: [ actions: [IconButton(icon: const Icon(Icons.add), onPressed: addUser)],
IconButton(
icon: const Icon(Icons.add),
onPressed: addUser,
),
],
), ),
body: SafeArea( body: SafeArea(
child: AnimatedList( child: AnimatedList(
@ -101,11 +94,7 @@ class _AnimatedListDemoState extends State<AnimatedListDemo> {
} }
class UserModel { class UserModel {
UserModel( UserModel(this.id, this.firstName, this.lastName);
this.id,
this.firstName,
this.lastName,
);
final int id; final int id;
final String firstName; final String firstName;

@ -54,10 +54,12 @@ class _AnimatedPositionedDemoState extends State<AnimatedPositionedDemo> {
left: leftPosition, left: leftPosition,
duration: const Duration(seconds: 1), duration: const Duration(seconds: 1),
child: InkWell( child: InkWell(
onTap: () => changePosition( onTap:
() => changePosition(
size.height - size.height -
(appBar.preferredSize.height + topPadding + 50), (appBar.preferredSize.height + topPadding + 50),
size.width - 150), size.width - 150,
),
child: Container( child: Container(
alignment: Alignment.center, alignment: Alignment.center,
width: 150, width: 150,

@ -48,9 +48,8 @@ class _AnimatedSwitcherDemoState extends State<AnimatedSwitcherDemo> {
title: const Text('AnimatedSwitcher'), title: const Text('AnimatedSwitcher'),
actions: [ actions: [
TextButton( TextButton(
onPressed: () => setState( onPressed:
() => container = generateContainer(++keyCount), () => setState(() => container = generateContainer(++keyCount)),
),
child: const Text('Change Widget'), child: const Text('Change Widget'),
), ),
], ],
@ -62,10 +61,9 @@ class _AnimatedSwitcherDemoState extends State<AnimatedSwitcherDemo> {
child: AnimatedSwitcher( child: AnimatedSwitcher(
duration: const Duration(seconds: 1), duration: const Duration(seconds: 1),
child: container, child: container,
transitionBuilder: (child, animation) => ScaleTransition( transitionBuilder:
scale: animation, (child, animation) =>
child: child, ScaleTransition(scale: animation, child: child),
),
), ),
), ),
); );

@ -33,9 +33,7 @@ class _CardSwipeDemoState extends State<CardSwipeDemo> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: const Text('Card Swipe')),
title: const Text('Card Swipe'),
),
body: Padding( body: Padding(
padding: const EdgeInsets.all(12.0), padding: const EdgeInsets.all(12.0),
child: Center( child: Center(
@ -100,8 +98,11 @@ class SwipeableCard extends StatefulWidget {
final String imageAssetName; final String imageAssetName;
final VoidCallback onSwiped; final VoidCallback onSwiped;
const SwipeableCard( const SwipeableCard({
{required this.onSwiped, required this.imageAssetName, super.key}); required this.onSwiped,
required this.imageAssetName,
super.key,
});
@override @override
State<SwipeableCard> createState() => _SwipeableCardState(); State<SwipeableCard> createState() => _SwipeableCardState();
@ -118,10 +119,9 @@ class _SwipeableCardState extends State<SwipeableCard>
void initState() { void initState() {
super.initState(); super.initState();
_controller = AnimationController.unbounded(vsync: this); _controller = AnimationController.unbounded(vsync: this);
_animation = _controller.drive(Tween<Offset>( _animation = _controller.drive(
begin: Offset.zero, Tween<Offset>(begin: Offset.zero, end: const Offset(1, 0)),
end: const Offset(1, 0), );
));
} }
@override @override
@ -179,17 +179,26 @@ class _SwipeableCardState extends State<SwipeableCard>
} }
void _updateAnimation(double dragPosition) { void _updateAnimation(double dragPosition) {
_animation = _controller.drive(Tween<Offset>( _animation = _controller.drive(
Tween<Offset>(
begin: Offset.zero, begin: Offset.zero,
end: _isSwipingLeft ? const Offset(-1, 0) : const Offset(1, 0), end: _isSwipingLeft ? const Offset(-1, 0) : const Offset(1, 0),
)); ),
);
} }
void _animate({double velocity = 0}) { void _animate({double velocity = 0}) {
var description = var description = const SpringDescription(
const SpringDescription(mass: 50, stiffness: 1, damping: 1); mass: 50,
var simulation = stiffness: 1,
SpringSimulation(description, _controller.value, 1, velocity); damping: 1,
);
var simulation = SpringSimulation(
description,
_controller.value,
1,
velocity,
);
_controller.animateWith(simulation).then<void>((_) { _controller.animateWith(simulation).then<void>((_) {
widget.onSwiped(); widget.onSwiped();
}); });

@ -21,9 +21,7 @@ class CarouselDemo extends StatelessWidget {
@override @override
Widget build(context) { Widget build(context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: const Text('Carousel Demo')),
title: const Text('Carousel Demo'),
),
body: Center( body: Center(
child: Padding( child: Padding(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
@ -79,15 +77,14 @@ class _CarouselState extends State<Carousel> {
}, },
controller: _controller, controller: _controller,
scrollBehavior: ScrollConfiguration.of(context).copyWith( scrollBehavior: ScrollConfiguration.of(context).copyWith(
dragDevices: { dragDevices: {ui.PointerDeviceKind.touch, ui.PointerDeviceKind.mouse},
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;

@ -46,10 +46,7 @@ class _CurvedAnimationDemoState extends State<CurvedAnimationDemo>
@override @override
void initState() { void initState() {
super.initState(); super.initState();
controller = AnimationController( controller = AnimationController(duration: _duration, vsync: this);
duration: _duration,
vsync: this,
);
selectedForwardCurve = curves[0]; selectedForwardCurve = curves[0];
selectedReverseCurve = curves[0]; selectedReverseCurve = curves[0];
curvedAnimation = CurvedAnimation( curvedAnimation = CurvedAnimation(
@ -57,10 +54,8 @@ class _CurvedAnimationDemoState extends State<CurvedAnimationDemo>
curve: selectedForwardCurve.curve, curve: selectedForwardCurve.curve,
reverseCurve: selectedReverseCurve.curve, reverseCurve: selectedReverseCurve.curve,
); );
animationRotation = Tween<double>( animationRotation =
begin: 0, Tween<double>(begin: 0, end: 2 * math.pi).animate(curvedAnimation)
end: 2 * math.pi,
).animate(curvedAnimation)
..addListener(() { ..addListener(() {
setState(() {}); setState(() {});
}) })
@ -69,7 +64,8 @@ class _CurvedAnimationDemoState extends State<CurvedAnimationDemo>
controller.reverse(); controller.reverse();
} }
}); });
animationTranslation = Tween<Offset>( animationTranslation =
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)
@ -86,9 +82,7 @@ class _CurvedAnimationDemoState extends State<CurvedAnimationDemo>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: const Text('Curved Animation')),
title: const Text('Curved Animation'),
),
body: Column( body: Column(
children: [ children: [
const SizedBox(height: 20.0), const SizedBox(height: 20.0),
@ -97,9 +91,12 @@ class _CurvedAnimationDemoState extends State<CurvedAnimationDemo>
style: Theme.of(context).textTheme.titleLarge, style: Theme.of(context).textTheme.titleLarge,
), ),
DropdownButton<CurveChoice>( DropdownButton<CurveChoice>(
items: curves.map((curve) { items:
curves.map((curve) {
return DropdownMenuItem<CurveChoice>( return DropdownMenuItem<CurveChoice>(
value: curve, child: Text(curve.name)); value: curve,
child: Text(curve.name),
);
}).toList(), }).toList(),
onChanged: (newCurve) { onChanged: (newCurve) {
if (newCurve != null) { if (newCurve != null) {
@ -117,9 +114,12 @@ class _CurvedAnimationDemoState extends State<CurvedAnimationDemo>
style: Theme.of(context).textTheme.titleLarge, style: Theme.of(context).textTheme.titleLarge,
), ),
DropdownButton<CurveChoice>( DropdownButton<CurveChoice>(
items: curves.map((curve) { items:
curves.map((curve) {
return DropdownMenuItem<CurveChoice>( return DropdownMenuItem<CurveChoice>(
value: curve, child: Text(curve.name)); value: curve,
child: Text(curve.name),
);
}).toList(), }).toList(),
onChanged: (newCurve) { onChanged: (newCurve) {
if (newCurve != null) { if (newCurve != null) {
@ -134,18 +134,12 @@ class _CurvedAnimationDemoState extends State<CurvedAnimationDemo>
const SizedBox(height: 35.0), const SizedBox(height: 35.0),
Transform.rotate( Transform.rotate(
angle: animationRotation.value, angle: animationRotation.value,
child: const Center( child: const Center(child: FlutterLogo(size: 100)),
child: FlutterLogo(
size: 100,
),
),
), ),
const SizedBox(height: 35.0), const SizedBox(height: 35.0),
FractionalTranslation( FractionalTranslation(
translation: animationTranslation.value, translation: animationTranslation.value,
child: const FlutterLogo( child: const FlutterLogo(size: 100),
size: 100,
),
), ),
const SizedBox(height: 25.0), const SizedBox(height: 25.0),
ElevatedButton( ElevatedButton(

@ -11,12 +11,8 @@ class ExpandCardDemo extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: const Text('Expandable Card')),
title: const Text('Expandable Card'), body: const Center(child: ExpandCard()),
),
body: const Center(
child: ExpandCard(),
),
); );
} }
} }
@ -56,24 +52,23 @@ class _ExpandCardState extends State<ExpandCard>
duration: duration, duration: duration,
firstCurve: Curves.easeInOutCubic, firstCurve: Curves.easeInOutCubic,
secondCurve: Curves.easeInOutCubic, secondCurve: Curves.easeInOutCubic,
crossFadeState: selected crossFadeState:
selected
? CrossFadeState.showSecond ? CrossFadeState.showSecond
: CrossFadeState.showFirst, : CrossFadeState.showFirst,
// Use Positioned.fill() to pass the constraints to its children. // Use Positioned.fill() to pass the constraints to its children.
// This allows the Images to use BoxFit.cover to cover the correct // This allows the Images to use BoxFit.cover to cover the correct
// size // size
layoutBuilder: layoutBuilder: (
(topChild, topChildKey, bottomChild, bottomChildKey) { topChild,
topChildKey,
bottomChild,
bottomChildKey,
) {
return Stack( return Stack(
children: [ children: [
Positioned.fill( Positioned.fill(key: bottomChildKey, child: bottomChild),
key: bottomChildKey, Positioned.fill(key: topChildKey, child: topChild),
child: bottomChild,
),
Positioned.fill(
key: topChildKey,
child: topChild,
),
], ],
); );
}, },

@ -14,9 +14,7 @@ class FlutterAnimateDemo extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: const Text('Flutter Animate Demo')),
title: const Text('Flutter Animate Demo'),
),
body: Center( body: Center(
child: Padding( child: Padding(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
@ -24,9 +22,7 @@ class FlutterAnimateDemo extends StatelessWidget {
"Hello Flutter Animate", "Hello Flutter Animate",
style: Theme.of(context).textTheme.headlineLarge, style: Theme.of(context).textTheme.headlineLarge,
) )
.animate( .animate(onPlay: (controller) => controller.repeat())
onPlay: (controller) => controller.repeat(),
)
.then(delay: 250.ms) .then(delay: 250.ms)
.fadeIn(duration: 500.ms) .fadeIn(duration: 500.ms)
.then(delay: 250.ms) .then(delay: 250.ms)

@ -24,13 +24,12 @@ class Grid extends StatelessWidget {
return Scaffold( return Scaffold(
body: GridView.builder( body: GridView.builder(
itemCount: 40, itemCount: 40,
gridDelegate: gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4), crossAxisCount: 4,
),
itemBuilder: (context, index) { itemBuilder: (context, index) {
return (index >= 20) return (index >= 20)
? const SmallCard( ? const SmallCard(imageAssetName: 'assets/eat_cape_town_sm.jpg')
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',
); );
@ -46,14 +45,12 @@ Route _createRoute(BuildContext parentContext, String image) {
return _SecondPage(image); return _SecondPage(image);
}, },
transitionsBuilder: (context, animation, secondaryAnimation, child) { transitionsBuilder: (context, animation, secondaryAnimation, child) {
var rectAnimation = _createTween(parentContext) var rectAnimation = _createTween(
.chain(CurveTween(curve: Curves.ease)) parentContext,
.animate(animation); ).chain(CurveTween(curve: Curves.ease)).animate(animation);
return Stack( return Stack(
children: [ children: [PositionedTransition(rect: rectAnimation, child: child)],
PositionedTransition(rect: rectAnimation, child: child),
],
); );
}, },
); );
@ -65,10 +62,7 @@ Tween<RelativeRect> _createTween(BuildContext context) {
var rect = box.localToGlobal(Offset.zero) & box.size; var rect = box.localToGlobal(Offset.zero) & box.size;
var relativeRect = RelativeRect.fromSize(rect, windowSize); var relativeRect = RelativeRect.fromSize(rect, windowSize);
return RelativeRectTween( return RelativeRectTween(begin: relativeRect, end: RelativeRect.fill);
begin: relativeRect,
end: RelativeRect.fill,
);
} }
class SmallCard extends StatelessWidget { class SmallCard extends StatelessWidget {
@ -84,10 +78,7 @@ class SmallCard extends StatelessWidget {
var nav = Navigator.of(context); var nav = Navigator.of(context);
nav.push<void>(_createRoute(context, imageAssetName)); nav.push<void>(_createRoute(context, imageAssetName));
}, },
child: Image.asset( child: Image.asset(imageAssetName, fit: BoxFit.cover),
imageAssetName,
fit: BoxFit.cover,
),
), ),
), ),
); );
@ -109,10 +100,7 @@ class _SecondPage extends StatelessWidget {
onTap: () => Navigator.of(context).pop(), onTap: () => Navigator.of(context).pop(),
child: AspectRatio( child: AspectRatio(
aspectRatio: 1, aspectRatio: 1,
child: Image.asset( child: Image.asset(imageAssetName, fit: BoxFit.cover),
imageAssetName,
fit: BoxFit.cover,
),
), ),
), ),
), ),

@ -11,19 +11,16 @@ class HeroAnimationDemo extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: const Text('Hero Animation')),
title: const Text('Hero Animation'),
),
body: GestureDetector( body: GestureDetector(
child: Hero( child: Hero(
tag: 'hero-page-child', tag: 'hero-page-child',
child: _createHeroContainer( child: _createHeroContainer(size: 50.0, color: Colors.grey.shade300),
size: 50.0,
color: Colors.grey.shade300,
), ),
onTap:
() => Navigator.of(context).push<void>(
MaterialPageRoute(builder: (context) => const HeroPage()),
), ),
onTap: () => Navigator.of(context).push<void>(
MaterialPageRoute(builder: (context) => const HeroPage())),
), ),
); );
} }
@ -40,10 +37,7 @@ class HeroPage extends StatelessWidget {
body: Center( body: Center(
child: Hero( child: Hero(
tag: 'hero-page-child', tag: 'hero-page-child',
child: _createHeroContainer( child: _createHeroContainer(size: 100.0, color: Colors.white),
size: 100.0,
color: Colors.white,
),
), ),
), ),
); );
@ -59,10 +53,7 @@ StatelessWidget _createHeroContainer({
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( decoration: BoxDecoration(shape: BoxShape.circle, color: color),
shape: BoxShape.circle,
color: color,
),
child: const FlutterLogo(), child: const FlutterLogo(),
); );
} }

@ -12,14 +12,8 @@ class PhysicsCardDragDemo extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: const Text('Spring Physics')),
title: const Text('Spring Physics'), body: const DraggableCard(child: FlutterLogo(size: 128)),
),
body: const DraggableCard(
child: FlutterLogo(
size: 128,
),
),
); );
} }
} }
@ -67,14 +61,15 @@ class _DraggableCardState extends State<DraggableCard>
/// Calculates and runs a [SpringSimulation] /// Calculates and runs a [SpringSimulation]
void _runAnimation(Offset velocity, Size size) { void _runAnimation(Offset velocity, Size size) {
_animation = _controller.drive( _animation = _controller.drive(
AlignmentTween( AlignmentTween(begin: _dragAlignment, end: Alignment.center),
begin: _dragAlignment,
end: Alignment.center,
),
); );
final simulation = final simulation = SpringSimulation(
SpringSimulation(_spring, 0, 1, _normalizeVelocity(velocity, size)); _spring,
0,
1,
_normalizeVelocity(velocity, size),
);
_controller.animateWith(simulation); _controller.animateWith(simulation);
} }
@ -97,20 +92,17 @@ class _DraggableCardState extends State<DraggableCard>
final size = MediaQuery.of(context).size; final size = MediaQuery.of(context).size;
return GestureDetector( return GestureDetector(
onPanStart: (details) => _controller.stop(canceled: true), onPanStart: (details) => _controller.stop(canceled: true),
onPanUpdate: (details) => setState( onPanUpdate:
() => _dragAlignment += Alignment( (details) => setState(
() =>
_dragAlignment += Alignment(
details.delta.dx / (size.width / 2), details.delta.dx / (size.width / 2),
details.delta.dy / (size.height / 2), details.delta.dy / (size.height / 2),
), ),
), ),
onPanEnd: (details) => onPanEnd:
_runAnimation(details.velocity.pixelsPerSecond, size), (details) => _runAnimation(details.velocity.pixelsPerSecond, size),
child: Align( child: Align(alignment: _dragAlignment, child: Card(child: widget.child)),
alignment: _dragAlignment,
child: Card(
child: widget.child,
),
),
); );
} }
} }

@ -21,9 +21,10 @@ class _RepeatingAnimationDemoState extends State<RepeatingAnimationDemo>
void initState() { void initState() {
super.initState(); super.initState();
_controller = _controller = AnimationController(
AnimationController(duration: const Duration(seconds: 2), vsync: this) duration: const Duration(seconds: 2),
..repeat(reverse: true); vsync: this,
)..repeat(reverse: true);
_borderRadius = BorderRadiusTween( _borderRadius = BorderRadiusTween(
begin: BorderRadius.circular(100.0), begin: BorderRadius.circular(100.0),

@ -4,7 +4,7 @@ version: 1.0.0+1
publish_to: none publish_to: none
environment: environment:
sdk: ^3.5.0 sdk: ^3.7.0-0
dependencies: dependencies:
flutter: flutter:

@ -6,9 +6,8 @@ import 'package:animations/src/basics/basics.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 createAnimatedBuilderDemoScreen() => const MaterialApp( Widget createAnimatedBuilderDemoScreen() =>
home: AnimatedBuilderDemo(), const MaterialApp(home: AnimatedBuilderDemo());
);
void main() { void main() {
group('AnimatedBuilder Tests', () { group('AnimatedBuilder Tests', () {

@ -6,9 +6,8 @@ import 'package:animations/src/misc/animated_list.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 createAnimatedListDemoScreen() => const MaterialApp( Widget createAnimatedListDemoScreen() =>
home: AnimatedListDemo(), const MaterialApp(home: AnimatedListDemo());
);
void main() { void main() {
group('Animated List Tests', () { group('Animated List Tests', () {
@ -19,14 +18,12 @@ void main() {
var initialLength = tester.widgetList(find.byType(ListTile)).length; var initialLength = tester.widgetList(find.byType(ListTile)).length;
// Initial length of list should be equal to 5. // Initial length of list should be equal to 5.
expect( expect(initialLength, equals(5));
initialLength,
equals(5),
);
}); });
testWidgets('Length of list increases on Add Icon Button tap', testWidgets('Length of list increases on Add Icon Button tap', (
(tester) async { tester,
) async {
await tester.pumpWidget(createAnimatedListDemoScreen()); await tester.pumpWidget(createAnimatedListDemoScreen());
// Get the initial length of list. // Get the initial length of list.
@ -40,10 +37,7 @@ void main() {
var newLength = tester.widgetList(find.byType(ListTile)).length; var newLength = tester.widgetList(find.byType(ListTile)).length;
// New length should be greater than initial length by one. // New length should be greater than initial length by one.
expect( expect(newLength, equals(initialLength + 1));
newLength,
equals(initialLength + 1),
);
}); });
testWidgets( testWidgets(
@ -62,11 +56,9 @@ void main() {
var newLength = tester.widgetList(find.byType(ListTile)).length; var newLength = tester.widgetList(find.byType(ListTile)).length;
// New length should be less than initial length by one. // New length should be less than initial length by one.
expect( expect(newLength, equals(initialLength - 1));
newLength, },
equals(initialLength - 1),
); );
});
testWidgets( testWidgets(
'Length of list decreases on Delete Icon Button tap at start index', 'Length of list decreases on Delete Icon Button tap at start index',
@ -84,11 +76,9 @@ void main() {
var newLength = tester.widgetList(find.byType(ListTile)).length; var newLength = tester.widgetList(find.byType(ListTile)).length;
// New length should be less than initial length by one. // New length should be less than initial length by one.
expect( expect(newLength, equals(initialLength - 1));
newLength, },
equals(initialLength - 1),
); );
});
testWidgets( testWidgets(
'Length of list decreases on Delete Icon Button tap at end index', 'Length of list decreases on Delete Icon Button tap at end index',
@ -106,11 +96,9 @@ void main() {
var newLength = tester.widgetList(find.byType(ListTile)).length; var newLength = tester.widgetList(find.byType(ListTile)).length;
// New Length should be less than initial length by one. // New Length should be less than initial length by one.
expect( expect(newLength, equals(initialLength - 1));
newLength, },
equals(initialLength - 1),
); );
});
testWidgets('All ListTiles deleted', (tester) async { testWidgets('All ListTiles deleted', (tester) async {
await tester.pumpWidget(createAnimatedListDemoScreen()); await tester.pumpWidget(createAnimatedListDemoScreen());
@ -129,10 +117,7 @@ void main() {
var finalLength = tester.widgetList(find.byType(ListTile)).length; var finalLength = tester.widgetList(find.byType(ListTile)).length;
// New length should be zero. // New length should be zero.
expect( expect(finalLength, equals(0));
finalLength,
equals(0),
);
}); });
}); });
} }

@ -6,9 +6,8 @@ import 'package:animations/src/misc/animated_positioned.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 createAnimatedPositionedDemoScreen() => const MaterialApp( Widget createAnimatedPositionedDemoScreen() =>
home: AnimatedPositionedDemo(), const MaterialApp(home: AnimatedPositionedDemo());
);
void main() { void main() {
group('AnimatedPositioned Tests', () { group('AnimatedPositioned Tests', () {

@ -6,9 +6,7 @@ import 'package:animations/src/misc/card_swipe.dart';
import 'package:flutter/material.dart' hide Card; import 'package:flutter/material.dart' hide Card;
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
Widget createCardSwipeScreen() => const MaterialApp( Widget createCardSwipeScreen() => const MaterialApp(home: CardSwipeDemo());
home: CardSwipeDemo(),
);
void main() { void main() {
group('Card Swipe Tests', () { group('Card Swipe Tests', () {

@ -6,9 +6,7 @@ import 'package:animations/src/misc/carousel.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 createCarouselDemoScreen() => MaterialApp( Widget createCarouselDemoScreen() => MaterialApp(home: CarouselDemo());
home: CarouselDemo(),
);
void main() { void main() {
group('CarouselDemo tests', () { group('CarouselDemo tests', () {

@ -6,9 +6,7 @@ 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( Widget createExpandCardScreen() => const MaterialApp(home: ExpandCardDemo());
home: ExpandCardDemo(),
);
void main() { void main() {
group('ExpandCard Tests', () { group('ExpandCard Tests', () {
@ -24,10 +22,7 @@ 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( expect(initialSize, lessThan(tester.getSize(find.byType(ExpandCard))));
initialSize,
lessThan(tester.getSize(find.byType(ExpandCard))),
);
}); });
testWidgets('ExpandCard changes image on tap', (tester) async { testWidgets('ExpandCard changes image on tap', (tester) async {

@ -6,9 +6,7 @@ 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( Widget createFocusImageScreen() => const MaterialApp(home: FocusImageDemo());
home: FocusImageDemo(),
);
void main() { void main() {
group('FocusImage Tests', () { group('FocusImage Tests', () {
@ -32,10 +30,7 @@ void main() {
var finalSize = tester.getSize(find.byWidget(finalInkwell)); var finalSize = tester.getSize(find.byWidget(finalInkwell));
// Final size should be greater than initial size. // Final size should be greater than initial size.
expect( expect(finalSize, greaterThan(initialSize));
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 {

@ -6,9 +6,8 @@ import 'package:animations/src/misc/hero_animation.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 createHeroAnimationDemoScreen() => const MaterialApp( Widget createHeroAnimationDemoScreen() =>
home: HeroAnimationDemo(), const MaterialApp(home: HeroAnimationDemo());
);
void main() { void main() {
group('Hero Animation Tests', () { group('Hero Animation Tests', () {
@ -32,10 +31,7 @@ void main() {
var finalSize = tester.getSize(find.byWidget(finalContainer)); var finalSize = tester.getSize(find.byWidget(finalContainer));
// initialSize should be less than finalSize. // initialSize should be less than finalSize.
expect( expect(initialSize, lessThan(finalSize));
initialSize,
lessThan(finalSize),
);
}); });
testWidgets('Color of Container changes on Tap', (tester) async { testWidgets('Color of Container changes on Tap', (tester) async {
@ -62,9 +58,7 @@ 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( isNot(equals((initialContainer.decoration as BoxDecoration).color)),
equals((initialContainer.decoration as BoxDecoration).color),
),
); );
}); });
@ -82,10 +76,7 @@ void main() {
final finalScreen = tester.firstWidget(find.byType(HeroPage)); final finalScreen = tester.firstWidget(find.byType(HeroPage));
// initialScreen should not be same as finalScreen. // initialScreen should not be same as finalScreen.
expect( expect(initialScreen, isNot(equals(finalScreen)));
initialScreen,
isNot(equals(finalScreen)),
);
}); });
}); });
} }

@ -11,7 +11,8 @@ int main(List<String> arguments) {
// the `--input` option and one for the `--output` option. // the `--input` option and one for the `--output` option.
// `--input` is the original asset file that this program should transform. // `--input` is the original asset file that this program should transform.
// `--output` is where flutter expects the transformation output to be written to. // `--output` is where flutter expects the transformation output to be written to.
final parser = ArgParser() final parser =
ArgParser()
..addOption(inputOptionName, mandatory: true, abbr: 'i') ..addOption(inputOptionName, mandatory: true, abbr: 'i')
..addOption(outputOptionName, mandatory: true, abbr: 'o'); ..addOption(outputOptionName, mandatory: true, abbr: 'o');
@ -29,8 +30,10 @@ int main(List<String> arguments) {
// The flutter command line tool will see a non-zero exit code (1 in this case) // The flutter command line tool will see a non-zero exit code (1 in this case)
// and fail the build. Anything written to stderr by the asset transformer // and fail the build. Anything written to stderr by the asset transformer
// will be surfaced by flutter. // will be surfaced by flutter.
stderr.writeln('Unexpected exception when producing grayscale image.\n' stderr.writeln(
'Details: $e'); 'Unexpected exception when producing grayscale image.\n'
'Details: $e',
);
return 1; return 1;
} }
} }

@ -3,7 +3,7 @@ description: A sample command-line application.
version: 1.0.0 version: 1.0.0
environment: environment:
sdk: ^3.5.0 sdk: ^3.7.0-0
dependencies: dependencies:
args: ^2.4.2 args: ^2.4.2

@ -4,7 +4,7 @@ publish_to: 'none'
version: 0.1.0 version: 0.1.0
environment: environment:
sdk: ^3.5.0 sdk: ^3.7.0-0
dependencies: dependencies:
flutter: flutter:

@ -29,9 +29,7 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
title: 'Background Isolate Channels', title: 'Background Isolate Channels',
theme: ThemeData( theme: ThemeData(primarySwatch: Colors.blue),
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Background Isolate Channels'), home: const MyHomePage(title: 'Background Isolate Channels'),
); );
} }
@ -69,7 +67,8 @@ class _MyHomePageState extends State<MyHomePage> {
// just for demonstration purposes. // just for demonstration purposes.
final Future<void> sharedPreferencesSet = SharedPreferences.getInstance() final Future<void> sharedPreferencesSet = SharedPreferences.getInstance()
.then( .then(
(sharedPreferences) => sharedPreferences.setBool('isDebug', true)); (sharedPreferences) => sharedPreferences.setBool('isDebug', true),
);
final Future<Directory> tempDirFuture = final Future<Directory> tempDirFuture =
path_provider.getTemporaryDirectory(); path_provider.getTemporaryDirectory();
@ -113,8 +112,9 @@ class _MyHomePageState extends State<MyHomePage> {
/// Adds a UUID and a timestamp to the [SimpleDatabase]. /// Adds a UUID and a timestamp to the [SimpleDatabase].
void _addDate() { void _addDate() {
final DateTime now = DateTime.now(); final DateTime now = DateTime.now();
final DateFormat formatter = final DateFormat formatter = DateFormat(
DateFormat('EEEE MMMM d, HH:mm:ss\n${const uuid.Uuid().v4()}'); 'EEEE MMMM d, HH:mm:ss\n${const uuid.Uuid().v4()}',
);
final String formatted = formatter.format(now); final String formatted = formatter.format(now);
_database!.addEntry(formatted).then((_) => _refresh()); _database!.addEntry(formatted).then((_) => _refresh());
} }

@ -45,14 +45,7 @@ const int _entrySize = 256;
/// All the command codes that can be sent and received between [SimpleDatabase] and /// All the command codes that can be sent and received between [SimpleDatabase] and
/// [_SimpleDatabaseServer]. /// [_SimpleDatabaseServer].
enum _Codes { enum _Codes { init, add, query, ack, result, done }
init,
add,
query,
ack,
result,
done,
}
/// A command sent between [SimpleDatabase] and [_SimpleDatabaseServer]. /// A command sent between [SimpleDatabase] and [_SimpleDatabaseServer].
class _Command { class _Command {
@ -85,8 +78,10 @@ class SimpleDatabase {
/// Open the database at [path] and launch the server on a background isolate.. /// Open the database at [path] and launch the server on a background isolate..
static Future<SimpleDatabase> open(String path) async { static Future<SimpleDatabase> open(String path) async {
final ReceivePort receivePort = ReceivePort(); final ReceivePort receivePort = ReceivePort();
final Isolate isolate = final Isolate isolate = await Isolate.spawn(
await Isolate.spawn(_SimpleDatabaseServer._run, receivePort.sendPort); _SimpleDatabaseServer._run,
receivePort.sendPort,
);
final SimpleDatabase result = SimpleDatabase._(isolate, path); final SimpleDatabase result = SimpleDatabase._(isolate, path);
Completer<void> completer = Completer<void>(); Completer<void> completer = Completer<void>();
result._completers.addFirst(completer); result._completers.addFirst(completer);
@ -130,8 +125,9 @@ class SimpleDatabase {
// invoke [BackgroundIsolateBinaryMessenger.ensureInitialized]. // invoke [BackgroundIsolateBinaryMessenger.ensureInitialized].
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
RootIsolateToken rootIsolateToken = RootIsolateToken.instance!; RootIsolateToken rootIsolateToken = RootIsolateToken.instance!;
_sendPort _sendPort.send(
.send(_Command(_Codes.init, arg0: _path, arg1: rootIsolateToken)); _Command(_Codes.init, arg0: _path, arg1: rootIsolateToken),
);
case _Codes.ack: case _Codes.ack:
_completers.removeLast().complete(); _completers.removeLast().complete();
case _Codes.result: case _Codes.result:
@ -200,7 +196,8 @@ class _SimpleDatabaseServer {
_doFind(command.arg0 as String); _doFind(command.arg0 as String);
default: default:
debugPrint( debugPrint(
'_SimpleDatabaseServer unrecognized command ${command.code}'); '_SimpleDatabaseServer unrecognized command ${command.code}',
);
} }
} }

@ -6,7 +6,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.7.0-0
dependencies: dependencies:
cupertino_icons: ^1.0.2 cupertino_icons: ^1.0.2

@ -10,20 +10,11 @@ final scheme = Platform.environment['SERVER_SCHEME'] ?? 'http';
final serverUrl = Uri.parse('$scheme://$host:$port/'); final serverUrl = Uri.parse('$scheme://$host:$port/');
void main() { void main() {
runApp( runApp(const MyApp(getCount: getCount, increment: increment));
const MyApp(
getCount: getCount,
increment: increment,
),
);
} }
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
const MyApp({ const MyApp({super.key, required this.getCount, required this.increment});
super.key,
required this.getCount,
required this.increment,
});
final Future<int> Function() getCount; final Future<int> Function() getCount;
final Future<int> Function(int) increment; final Future<int> Function(int) increment;
@ -32,9 +23,7 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
title: 'Flutter Demo', title: 'Flutter Demo',
theme: ThemeData( theme: ThemeData(colorSchemeSeed: Colors.blue),
colorSchemeSeed: Colors.blue,
),
home: MyHomePage( home: MyHomePage(
title: 'Flutter Demo Home Page', title: 'Flutter Demo Home Page',
getCount: getCount, getCount: getCount,
@ -74,26 +63,24 @@ class _MyHomePageState extends State<MyHomePage> {
void _incrementCounter() { void _incrementCounter() {
localClicks += 1; localClicks += 1;
setState(() => isWriting = true); setState(() => isWriting = true);
widget.increment(localClicks).then( widget
(int val) => setState( .increment(localClicks)
() { .then(
(int val) => setState(() {
_counter = val; _counter = val;
// Leave this up for at least a split second // Leave this up for at least a split second
Future.delayed( Future.delayed(
const Duration(milliseconds: 200), const Duration(milliseconds: 200),
() => setState(() => isWriting = false), () => setState(() => isWriting = false),
); );
}, }),
),
); );
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: Text(widget.title)),
title: Text(widget.title),
),
body: Center( body: Center(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,

@ -4,7 +4,7 @@ publish_to: "none"
version: 1.0.0+1 version: 1.0.0+1
environment: environment:
sdk: ^3.5.0 sdk: ^3.7.0-0
dependencies: dependencies:
cupertino_icons: ^1.0.2 cupertino_icons: ^1.0.2

@ -9,7 +9,8 @@ import 'package:shelf_router/shelf_router.dart';
int count = 0; int count = 0;
// Configure routes. // Configure routes.
final _router = Router() final _router =
Router()
..post('/', _incrementHandler) ..post('/', _incrementHandler)
..get('/', _getValueHandler); ..get('/', _getValueHandler);
@ -27,8 +28,9 @@ void main(List<String> args) async {
final ip = InternetAddress.anyIPv4; final ip = InternetAddress.anyIPv4;
// Configure a pipeline that logs requests. // Configure a pipeline that logs requests.
final handler = final handler = Pipeline()
Pipeline().addMiddleware(logRequests()).addHandler(_router.call); .addMiddleware(logRequests())
.addHandler(_router.call);
// For running in containers, we respect the PORT environment variable. // For running in containers, we respect the PORT environment variable.
final port = int.parse(Platform.environment['PORT'] ?? '8080'); final port = int.parse(Platform.environment['PORT'] ?? '8080');

@ -4,7 +4,7 @@ version: 1.0.0
publish_to: "none" publish_to: "none"
environment: environment:
sdk: ^3.5.0 sdk: ^3.7.0-0
dependencies: dependencies:
args: ^2.0.0 args: ^2.0.0

@ -42,9 +42,7 @@ void main() {
}); });
}, },
onPlatform: <String, dynamic>{ onPlatform: <String, dynamic>{
'windows': [ 'windows': [Skip('Failing on Windows CI')],
Skip('Failing on Windows CI'),
]
}, },
); );
} }

@ -12,7 +12,8 @@ part of 'models.dart';
T _$identity<T>(T value) => value; T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError( final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods',
);
Increment _$IncrementFromJson(Map<String, dynamic> json) { Increment _$IncrementFromJson(Map<String, dynamic> json) {
return _Increment.fromJson(json); return _Increment.fromJson(json);
@ -48,15 +49,17 @@ class _$IncrementCopyWithImpl<$Res, $Val extends Increment>
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({Object? by = null}) {
Object? by = null, return _then(
}) { _value.copyWith(
return _then(_value.copyWith( by:
by: null == by null == by
? _value.by ? _value.by
: by // ignore: cast_nullable_to_non_nullable : by // ignore: cast_nullable_to_non_nullable
as int, as int,
) as $Val); )
as $Val,
);
} }
} }
@ -64,8 +67,9 @@ class _$IncrementCopyWithImpl<$Res, $Val extends Increment>
abstract class _$$IncrementImplCopyWith<$Res> abstract class _$$IncrementImplCopyWith<$Res>
implements $IncrementCopyWith<$Res> { implements $IncrementCopyWith<$Res> {
factory _$$IncrementImplCopyWith( factory _$$IncrementImplCopyWith(
_$IncrementImpl value, $Res Function(_$IncrementImpl) then) = _$IncrementImpl value,
__$$IncrementImplCopyWithImpl<$Res>; $Res Function(_$IncrementImpl) then,
) = __$$IncrementImplCopyWithImpl<$Res>;
@override @override
@useResult @useResult
$Res call({int by}); $Res call({int by});
@ -76,20 +80,22 @@ class __$$IncrementImplCopyWithImpl<$Res>
extends _$IncrementCopyWithImpl<$Res, _$IncrementImpl> extends _$IncrementCopyWithImpl<$Res, _$IncrementImpl>
implements _$$IncrementImplCopyWith<$Res> { implements _$$IncrementImplCopyWith<$Res> {
__$$IncrementImplCopyWithImpl( __$$IncrementImplCopyWithImpl(
_$IncrementImpl _value, $Res Function(_$IncrementImpl) _then) _$IncrementImpl _value,
: super(_value, _then); $Res Function(_$IncrementImpl) _then,
) : super(_value, _then);
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({Object? by = null}) {
Object? by = null, return _then(
}) { _$IncrementImpl(
return _then(_$IncrementImpl( by:
by: null == by null == by
? _value.by ? _value.by
: by // ignore: cast_nullable_to_non_nullable : by // ignore: cast_nullable_to_non_nullable
as int, as int,
)); ),
);
} }
} }
@ -129,9 +135,7 @@ class _$IncrementImpl implements _Increment {
@override @override
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return _$$IncrementImplToJson( return _$$IncrementImplToJson(this);
this,
);
} }
} }
@ -182,23 +186,26 @@ class _$CountCopyWithImpl<$Res, $Val extends Count>
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({Object? value = null}) {
Object? value = null, return _then(
}) { _value.copyWith(
return _then(_value.copyWith( value:
value: null == value null == value
? _value.value ? _value.value
: value // ignore: cast_nullable_to_non_nullable : value // ignore: cast_nullable_to_non_nullable
as int, as int,
) as $Val); )
as $Val,
);
} }
} }
/// @nodoc /// @nodoc
abstract class _$$CountImplCopyWith<$Res> implements $CountCopyWith<$Res> { abstract class _$$CountImplCopyWith<$Res> implements $CountCopyWith<$Res> {
factory _$$CountImplCopyWith( factory _$$CountImplCopyWith(
_$CountImpl value, $Res Function(_$CountImpl) then) = _$CountImpl value,
__$$CountImplCopyWithImpl<$Res>; $Res Function(_$CountImpl) then,
) = __$$CountImplCopyWithImpl<$Res>;
@override @override
@useResult @useResult
$Res call({int value}); $Res call({int value});
@ -209,20 +216,21 @@ class __$$CountImplCopyWithImpl<$Res>
extends _$CountCopyWithImpl<$Res, _$CountImpl> extends _$CountCopyWithImpl<$Res, _$CountImpl>
implements _$$CountImplCopyWith<$Res> { implements _$$CountImplCopyWith<$Res> {
__$$CountImplCopyWithImpl( __$$CountImplCopyWithImpl(
_$CountImpl _value, $Res Function(_$CountImpl) _then) _$CountImpl _value,
: super(_value, _then); $Res Function(_$CountImpl) _then,
) : super(_value, _then);
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({Object? value = null}) {
Object? value = null, return _then(
}) { _$CountImpl(
return _then(_$CountImpl(
null == value null == value
? _value.value ? _value.value
: value // ignore: cast_nullable_to_non_nullable : value // ignore: cast_nullable_to_non_nullable
as int, as int,
)); ),
);
} }
} }
@ -262,9 +270,7 @@ class _$CountImpl implements _Count {
@override @override
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return _$$CountImplToJson( return _$$CountImplToJson(this);
this,
);
} }
} }

@ -7,20 +7,13 @@ part of 'models.dart';
// ************************************************************************** // **************************************************************************
_$IncrementImpl _$$IncrementImplFromJson(Map<String, dynamic> json) => _$IncrementImpl _$$IncrementImplFromJson(Map<String, dynamic> json) =>
_$IncrementImpl( _$IncrementImpl(by: json['by'] as int);
by: json['by'] as int,
);
Map<String, dynamic> _$$IncrementImplToJson(_$IncrementImpl instance) => Map<String, dynamic> _$$IncrementImplToJson(_$IncrementImpl instance) =>
<String, dynamic>{ <String, dynamic>{'by': instance.by};
'by': instance.by,
};
_$CountImpl _$$CountImplFromJson(Map<String, dynamic> json) => _$CountImpl( _$CountImpl _$$CountImplFromJson(Map<String, dynamic> json) =>
json['value'] as int, _$CountImpl(json['value'] as int);
);
Map<String, dynamic> _$$CountImplToJson(_$CountImpl instance) => Map<String, dynamic> _$$CountImplToJson(_$CountImpl instance) =>
<String, dynamic>{ <String, dynamic>{'value': instance.value};
'value': instance.value,
};

@ -3,7 +3,7 @@ description: Common data models required by our client and server
version: 1.0.0 version: 1.0.0
environment: environment:
sdk: ^3.5.0 sdk: ^3.7.0-0
dependencies: dependencies:
freezed_annotation: ^2.1.0 freezed_annotation: ^2.1.0

@ -24,20 +24,14 @@ void main() {
testWidgets('should load app', (tester) async { testWidgets('should load app', (tester) async {
// Load app widget. // Load app widget.
await tester.pumpWidget( await tester.pumpWidget(
MultiProvider( MultiProvider(providers: providersLocal, child: const MainApp()),
providers: providersLocal,
child: const MainApp(),
),
); );
}); });
testWidgets('Open a booking', (tester) async { testWidgets('Open a booking', (tester) async {
// Load app widget with local configuration // Load app widget with local configuration
await tester.pumpWidget( await tester.pumpWidget(
MultiProvider( MultiProvider(providers: providersLocal, child: const MainApp()),
providers: providersLocal,
child: const MainApp(),
),
); );
await tester.pumpAndSettle(); await tester.pumpAndSettle();
@ -61,10 +55,7 @@ void main() {
testWidgets('Create booking', (tester) async { testWidgets('Create booking', (tester) async {
// Load app widget with local configuration // Load app widget with local configuration
await tester.pumpWidget( await tester.pumpWidget(
MultiProvider( MultiProvider(providers: providersLocal, child: const MainApp()),
providers: providersLocal,
child: const MainApp(),
),
); );
await tester.pumpAndSettle(); await tester.pumpAndSettle();
@ -97,8 +88,10 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// Select guests // Select guests
await tester.tap(find.byKey(const ValueKey(addGuestsKey)), await tester.tap(
warnIfMissed: false); find.byKey(const ValueKey(addGuestsKey)),
warnIfMissed: false,
);
// Refresh screen state // Refresh screen state
await tester.pumpAndSettle(); await tester.pumpAndSettle();

@ -50,10 +50,7 @@ void main() {
testWidgets('should load app', (tester) async { testWidgets('should load app', (tester) async {
// Load app widget. // Load app widget.
await tester.pumpWidget( await tester.pumpWidget(
MultiProvider( MultiProvider(providers: providersRemote, child: const MainApp()),
providers: providersRemote,
child: const MainApp(),
),
); );
await tester.pumpAndSettle(); await tester.pumpAndSettle();
@ -65,10 +62,7 @@ void main() {
testWidgets('Open a booking', (tester) async { testWidgets('Open a booking', (tester) async {
// Load app widget with local configuration // Load app widget with local configuration
await tester.pumpWidget( await tester.pumpWidget(
MultiProvider( MultiProvider(providers: providersRemote, child: const MainApp()),
providers: providersRemote,
child: const MainApp(),
),
); );
await tester.pumpAndSettle(); await tester.pumpAndSettle();
@ -111,10 +105,7 @@ void main() {
testWidgets('Create booking', (tester) async { testWidgets('Create booking', (tester) async {
// Load app widget with local configuration // Load app widget with local configuration
await tester.pumpWidget( await tester.pumpWidget(
MultiProvider( MultiProvider(providers: providersRemote, child: const MainApp()),
providers: providersRemote,
child: const MainApp(),
),
); );
await tester.pumpAndSettle(); await tester.pumpAndSettle();
@ -155,8 +146,10 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// Select guests // Select guests
await tester.tap(find.byKey(const ValueKey('add_guests')), await tester.tap(
warnIfMissed: false); find.byKey(const ValueKey('add_guests')),
warnIfMissed: false,
);
// Refresh screen state // Refresh screen state
await tester.pumpAndSettle(); await tester.pumpAndSettle();

@ -36,7 +36,8 @@ import '../domain/use_cases/booking/booking_share_use_case.dart';
List<SingleChildWidget> _sharedProviders = [ List<SingleChildWidget> _sharedProviders = [
Provider( Provider(
lazy: true, lazy: true,
create: (context) => BookingCreateUseCase( create:
(context) => BookingCreateUseCase(
destinationRepository: context.read(), destinationRepository: context.read(),
activityRepository: context.read(), activityRepository: context.read(),
bookingRepository: context.read(), bookingRepository: context.read(),
@ -52,49 +53,50 @@ List<SingleChildWidget> _sharedProviders = [
/// This dependency list uses repositories that connect to a remote server. /// This dependency list uses repositories that connect to a remote server.
List<SingleChildWidget> get providersRemote { List<SingleChildWidget> get providersRemote {
return [ return [
Provider( Provider(create: (context) => AuthApiClient()),
create: (context) => AuthApiClient(), Provider(create: (context) => ApiClient()),
), Provider(create: (context) => SharedPreferencesService()),
Provider(
create: (context) => ApiClient(),
),
Provider(
create: (context) => SharedPreferencesService(),
),
ChangeNotifierProvider( ChangeNotifierProvider(
create: (context) => AuthRepositoryRemote( create:
(context) =>
AuthRepositoryRemote(
authApiClient: context.read(), authApiClient: context.read(),
apiClient: context.read(), apiClient: context.read(),
sharedPreferencesService: context.read(), sharedPreferencesService: context.read(),
) as AuthRepository, )
as AuthRepository,
), ),
Provider( Provider(
create: (context) => DestinationRepositoryRemote( create:
apiClient: context.read(), (context) =>
) as DestinationRepository, DestinationRepositoryRemote(apiClient: context.read())
as DestinationRepository,
), ),
Provider( Provider(
create: (context) => ContinentRepositoryRemote( create:
apiClient: context.read(), (context) =>
) as ContinentRepository, ContinentRepositoryRemote(apiClient: context.read())
as ContinentRepository,
), ),
Provider( Provider(
create: (context) => ActivityRepositoryRemote( create:
apiClient: context.read(), (context) =>
) as ActivityRepository, ActivityRepositoryRemote(apiClient: context.read())
as ActivityRepository,
), ),
Provider.value( Provider.value(
value: ItineraryConfigRepositoryMemory() as ItineraryConfigRepository, value: ItineraryConfigRepositoryMemory() as ItineraryConfigRepository,
), ),
Provider( Provider(
create: (context) => BookingRepositoryRemote( create:
apiClient: context.read(), (context) =>
) as BookingRepository, BookingRepositoryRemote(apiClient: context.read())
as BookingRepository,
), ),
Provider( Provider(
create: (context) => UserRepositoryRemote( create:
apiClient: context.read(), (context) =>
) as UserRepository, UserRepositoryRemote(apiClient: context.read()) as UserRepository,
), ),
..._sharedProviders, ..._sharedProviders,
]; ];
@ -105,39 +107,40 @@ List<SingleChildWidget> get providersRemote {
/// The user is always logged in. /// The user is always logged in.
List<SingleChildWidget> get providersLocal { List<SingleChildWidget> get providersLocal {
return [ return [
ChangeNotifierProvider.value( ChangeNotifierProvider.value(value: AuthRepositoryDev() as AuthRepository),
value: AuthRepositoryDev() as AuthRepository, Provider.value(value: LocalDataService()),
),
Provider.value(
value: LocalDataService(),
),
Provider( Provider(
create: (context) => DestinationRepositoryLocal( create:
localDataService: context.read(), (context) =>
) as DestinationRepository, DestinationRepositoryLocal(localDataService: context.read())
as DestinationRepository,
), ),
Provider( Provider(
create: (context) => ContinentRepositoryLocal( create:
localDataService: context.read(), (context) =>
) as ContinentRepository, ContinentRepositoryLocal(localDataService: context.read())
as ContinentRepository,
), ),
Provider( Provider(
create: (context) => ActivityRepositoryLocal( create:
localDataService: context.read(), (context) =>
) as ActivityRepository, ActivityRepositoryLocal(localDataService: context.read())
as ActivityRepository,
), ),
Provider( Provider(
create: (context) => BookingRepositoryLocal( create:
localDataService: context.read(), (context) =>
) as BookingRepository, BookingRepositoryLocal(localDataService: context.read())
as BookingRepository,
), ),
Provider.value( Provider.value(
value: ItineraryConfigRepositoryMemory() as ItineraryConfigRepository, value: ItineraryConfigRepositoryMemory() as ItineraryConfigRepository,
), ),
Provider( Provider(
create: (context) => UserRepositoryLocal( create:
localDataService: context.read(), (context) =>
) as UserRepository, UserRepositoryLocal(localDataService: context.read())
as UserRepository,
), ),
..._sharedProviders, ..._sharedProviders,
]; ];

@ -10,16 +10,16 @@ import 'activity_repository.dart';
/// Local implementation of ActivityRepository /// Local implementation of ActivityRepository
/// Uses data from assets folder /// Uses data from assets folder
class ActivityRepositoryLocal implements ActivityRepository { class ActivityRepositoryLocal implements ActivityRepository {
ActivityRepositoryLocal({ ActivityRepositoryLocal({required LocalDataService localDataService})
required LocalDataService localDataService, : _localDataService = localDataService;
}) : _localDataService = localDataService;
final LocalDataService _localDataService; final LocalDataService _localDataService;
@override @override
Future<Result<List<Activity>>> getByDestination(String ref) async { Future<Result<List<Activity>>> getByDestination(String ref) async {
try { try {
final activities = (await _localDataService.getActivities()) final activities =
(await _localDataService.getActivities())
.where((activity) => activity.destinationRef == ref) .where((activity) => activity.destinationRef == ref)
.toList(); .toList();

@ -11,9 +11,8 @@ import 'activity_repository.dart';
/// Implements basic local caching. /// Implements basic local caching.
/// See: https://docs.flutter.dev/get-started/fwe/local-caching /// See: https://docs.flutter.dev/get-started/fwe/local-caching
class ActivityRepositoryRemote implements ActivityRepository { class ActivityRepositoryRemote implements ActivityRepository {
ActivityRepositoryRemote({ ActivityRepositoryRemote({required ApiClient apiClient})
required ApiClient apiClient, : _apiClient = apiClient;
}) : _apiClient = apiClient;
final ApiClient _apiClient; final ApiClient _apiClient;

@ -12,10 +12,7 @@ abstract class AuthRepository extends ChangeNotifier {
Future<bool> get isAuthenticated; Future<bool> get isAuthenticated;
/// Perform login /// Perform login
Future<Result<void>> login({ Future<Result<void>> login({required String email, required String password});
required String email,
required String password,
});
/// Perform logout /// Perform logout
Future<Result<void>> logout(); Future<Result<void>> logout();

@ -64,10 +64,7 @@ class AuthRepositoryRemote extends AuthRepository {
}) async { }) async {
try { try {
final result = await _authApiClient.login( final result = await _authApiClient.login(
LoginRequest( LoginRequest(email: email, password: password),
email: email,
password: password,
),
); );
switch (result) { switch (result) {
case Ok<LoginResponse>(): case Ok<LoginResponse>():

@ -14,9 +14,8 @@ import '../../services/local/local_data_service.dart';
import 'booking_repository.dart'; import 'booking_repository.dart';
class BookingRepositoryLocal implements BookingRepository { class BookingRepositoryLocal implements BookingRepository {
BookingRepositoryLocal({ BookingRepositoryLocal({required LocalDataService localDataService})
required LocalDataService localDataService, : _localDataService = localDataService;
}) : _localDataService = localDataService;
// Only create default booking once // Only create default booking once
bool _isInitialized = false; bool _isInitialized = false;
@ -72,7 +71,8 @@ class BookingRepositoryLocal implements BookingRepository {
// create a default booking the first time // create a default booking the first time
if (_bookings.isEmpty) { if (_bookings.isEmpty) {
final destination = (await _localDataService.getDestinations()).first; final destination = (await _localDataService.getDestinations()).first;
final activities = (await _localDataService.getActivities()) final activities =
(await _localDataService.getActivities())
.where((activity) => activity.destinationRef == destination.ref) .where((activity) => activity.destinationRef == destination.ref)
.take(4) .take(4)
.toList(); .toList();

@ -12,9 +12,8 @@ import '../../services/api/model/booking/booking_api_model.dart';
import 'booking_repository.dart'; import 'booking_repository.dart';
class BookingRepositoryRemote implements BookingRepository { class BookingRepositoryRemote implements BookingRepository {
BookingRepositoryRemote({ BookingRepositoryRemote({required ApiClient apiClient})
required ApiClient apiClient, : _apiClient = apiClient;
}) : _apiClient = apiClient;
final ApiClient _apiClient; final ApiClient _apiClient;
@ -62,16 +61,19 @@ class BookingRepositoryRemote implements BookingRepository {
// Get destination for booking // Get destination for booking
final destination = _cachedDestinations!.firstWhere( final destination = _cachedDestinations!.firstWhere(
(destination) => destination.ref == booking.destinationRef); (destination) => destination.ref == booking.destinationRef,
);
final resultActivities = final resultActivities = await _apiClient.getActivityByDestination(
await _apiClient.getActivityByDestination(destination.ref); destination.ref,
);
switch (resultActivities) { switch (resultActivities) {
case Error<List<Activity>>(): case Error<List<Activity>>():
return Result.error(resultActivities.error); return Result.error(resultActivities.error);
case Ok<List<Activity>>(): case Ok<List<Activity>>():
} }
final activities = resultActivities.value final activities =
resultActivities.value
.where((activity) => booking.activitiesRef.contains(activity.ref)) .where((activity) => booking.activitiesRef.contains(activity.ref))
.toList(); .toList();
@ -96,7 +98,8 @@ class BookingRepositoryRemote implements BookingRepository {
switch (result) { switch (result) {
case Ok<List<BookingApiModel>>(): case Ok<List<BookingApiModel>>():
final bookingsApi = result.value; final bookingsApi = result.value;
return Result.ok(bookingsApi return Result.ok(
bookingsApi
.map( .map(
(bookingApi) => BookingSummary( (bookingApi) => BookingSummary(
id: bookingApi.id!, id: bookingApi.id!,
@ -105,7 +108,8 @@ class BookingRepositoryRemote implements BookingRepository {
endDate: bookingApi.endDate, endDate: bookingApi.endDate,
), ),
) )
.toList()); .toList(),
);
case Error<List<BookingApiModel>>(): case Error<List<BookingApiModel>>():
return Result.error(result.error); return Result.error(result.error);
} }

@ -9,9 +9,8 @@ import 'continent_repository.dart';
/// Local data source with all possible continents. /// Local data source with all possible continents.
class ContinentRepositoryLocal implements ContinentRepository { class ContinentRepositoryLocal implements ContinentRepository {
ContinentRepositoryLocal({ ContinentRepositoryLocal({required LocalDataService localDataService})
required LocalDataService localDataService, : _localDataService = localDataService;
}) : _localDataService = localDataService;
final LocalDataService _localDataService; final LocalDataService _localDataService;

@ -11,9 +11,8 @@ import 'continent_repository.dart';
/// Implements basic local caching. /// Implements basic local caching.
/// See: https://docs.flutter.dev/get-started/fwe/local-caching /// See: https://docs.flutter.dev/get-started/fwe/local-caching
class ContinentRepositoryRemote implements ContinentRepository { class ContinentRepositoryRemote implements ContinentRepository {
ContinentRepositoryRemote({ ContinentRepositoryRemote({required ApiClient apiClient})
required ApiClient apiClient, : _apiClient = apiClient;
}) : _apiClient = apiClient;
final ApiClient _apiClient; final ApiClient _apiClient;

@ -10,9 +10,8 @@ import 'destination_repository.dart';
/// Local implementation of DestinationRepository /// Local implementation of DestinationRepository
/// Uses data from assets folder /// Uses data from assets folder
class DestinationRepositoryLocal implements DestinationRepository { class DestinationRepositoryLocal implements DestinationRepository {
DestinationRepositoryLocal({ DestinationRepositoryLocal({required LocalDataService localDataService})
required LocalDataService localDataService, : _localDataService = localDataService;
}) : _localDataService = localDataService;
final LocalDataService _localDataService; final LocalDataService _localDataService;

@ -11,9 +11,8 @@ import 'destination_repository.dart';
/// Implements basic local caching. /// Implements basic local caching.
/// See: https://docs.flutter.dev/get-started/fwe/local-caching /// See: https://docs.flutter.dev/get-started/fwe/local-caching
class DestinationRepositoryRemote implements DestinationRepository { class DestinationRepositoryRemote implements DestinationRepository {
DestinationRepositoryRemote({ DestinationRepositoryRemote({required ApiClient apiClient})
required ApiClient apiClient, : _apiClient = apiClient;
}) : _apiClient = apiClient;
final ApiClient _apiClient; final ApiClient _apiClient;

@ -8,9 +8,8 @@ import '../../services/local/local_data_service.dart';
import 'user_repository.dart'; import 'user_repository.dart';
class UserRepositoryLocal implements UserRepository { class UserRepositoryLocal implements UserRepository {
UserRepositoryLocal({ UserRepositoryLocal({required LocalDataService localDataService})
required LocalDataService localDataService, : _localDataService = localDataService;
}) : _localDataService = localDataService;
final LocalDataService _localDataService; final LocalDataService _localDataService;

@ -9,9 +9,7 @@ import '../../services/api/model/user/user_api_model.dart';
import 'user_repository.dart'; import 'user_repository.dart';
class UserRepositoryRemote implements UserRepository { class UserRepositoryRemote implements UserRepository {
UserRepositoryRemote({ UserRepositoryRemote({required ApiClient apiClient}) : _apiClient = apiClient;
required ApiClient apiClient,
}) : _apiClient = apiClient;
final ApiClient _apiClient; final ApiClient _apiClient;

@ -16,11 +16,8 @@ import 'model/user/user_api_model.dart';
typedef AuthHeaderProvider = String? Function(); typedef AuthHeaderProvider = String? Function();
class ApiClient { class ApiClient {
ApiClient({ ApiClient({String? host, int? port, HttpClient Function()? clientFactory})
String? host, : _host = host ?? 'localhost',
int? port,
HttpClient Function()? clientFactory,
}) : _host = host ?? 'localhost',
_port = port ?? 8080, _port = port ?? 8080,
_clientFactory = clientFactory ?? HttpClient.new; _clientFactory = clientFactory ?? HttpClient.new;
@ -51,7 +48,8 @@ class ApiClient {
final stringData = await response.transform(utf8.decoder).join(); final stringData = await response.transform(utf8.decoder).join();
final json = jsonDecode(stringData) as List<dynamic>; final json = jsonDecode(stringData) as List<dynamic>;
return Result.ok( return Result.ok(
json.map((element) => Continent.fromJson(element)).toList()); json.map((element) => Continent.fromJson(element)).toList(),
);
} else { } else {
return const Result.error(HttpException("Invalid response")); return const Result.error(HttpException("Invalid response"));
} }
@ -72,7 +70,8 @@ class ApiClient {
final stringData = await response.transform(utf8.decoder).join(); final stringData = await response.transform(utf8.decoder).join();
final json = jsonDecode(stringData) as List<dynamic>; final json = jsonDecode(stringData) as List<dynamic>;
return Result.ok( return Result.ok(
json.map((element) => Destination.fromJson(element)).toList()); json.map((element) => Destination.fromJson(element)).toList(),
);
} else { } else {
return const Result.error(HttpException("Invalid response")); return const Result.error(HttpException("Invalid response"));
} }
@ -86,8 +85,11 @@ class ApiClient {
Future<Result<List<Activity>>> getActivityByDestination(String ref) async { Future<Result<List<Activity>>> getActivityByDestination(String ref) async {
final client = _clientFactory(); final client = _clientFactory();
try { try {
final request = final request = await client.get(
await client.get(_host, _port, '/destination/$ref/activity'); _host,
_port,
'/destination/$ref/activity',
);
await _authHeader(request.headers); await _authHeader(request.headers);
final response = await request.close(); final response = await request.close();
if (response.statusCode == 200) { if (response.statusCode == 200) {

@ -10,11 +10,8 @@ import 'model/login_request/login_request.dart';
import 'model/login_response/login_response.dart'; import 'model/login_response/login_response.dart';
class AuthApiClient { class AuthApiClient {
AuthApiClient({ AuthApiClient({String? host, int? port, HttpClient Function()? clientFactory})
String? host, : _host = host ?? 'localhost',
int? port,
HttpClient Function()? clientFactory,
}) : _host = host ?? 'localhost',
_port = port ?? 8080, _port = port ?? 8080,
_clientFactory = clientFactory ?? HttpClient.new; _clientFactory = clientFactory ?? HttpClient.new;

@ -12,7 +12,8 @@ part of 'booking_api_model.dart';
T _$identity<T>(T value) => value; T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError( final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
);
BookingApiModel _$BookingApiModelFromJson(Map<String, dynamic> json) { BookingApiModel _$BookingApiModelFromJson(Map<String, dynamic> json) {
return _BookingApiModel.fromJson(json); return _BookingApiModel.fromJson(json);
@ -52,16 +53,18 @@ mixin _$BookingApiModel {
/// @nodoc /// @nodoc
abstract class $BookingApiModelCopyWith<$Res> { abstract class $BookingApiModelCopyWith<$Res> {
factory $BookingApiModelCopyWith( factory $BookingApiModelCopyWith(
BookingApiModel value, $Res Function(BookingApiModel) then) = BookingApiModel value,
_$BookingApiModelCopyWithImpl<$Res, BookingApiModel>; $Res Function(BookingApiModel) then,
) = _$BookingApiModelCopyWithImpl<$Res, BookingApiModel>;
@useResult @useResult
$Res call( $Res call({
{int? id, int? id,
DateTime startDate, DateTime startDate,
DateTime endDate, DateTime endDate,
String name, String name,
String destinationRef, String destinationRef,
List<String> activitiesRef}); List<String> activitiesRef,
});
} }
/// @nodoc /// @nodoc
@ -86,50 +89,61 @@ class _$BookingApiModelCopyWithImpl<$Res, $Val extends BookingApiModel>
Object? destinationRef = null, Object? destinationRef = null,
Object? activitiesRef = null, Object? activitiesRef = null,
}) { }) {
return _then(_value.copyWith( return _then(
id: freezed == id _value.copyWith(
id:
freezed == id
? _value.id ? _value.id
: id // ignore: cast_nullable_to_non_nullable : id // ignore: cast_nullable_to_non_nullable
as int?, as int?,
startDate: null == startDate startDate:
null == startDate
? _value.startDate ? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable : startDate // ignore: cast_nullable_to_non_nullable
as DateTime, as DateTime,
endDate: null == endDate endDate:
null == endDate
? _value.endDate ? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable : endDate // ignore: cast_nullable_to_non_nullable
as DateTime, as DateTime,
name: null == name name:
null == name
? _value.name ? _value.name
: name // ignore: cast_nullable_to_non_nullable : name // ignore: cast_nullable_to_non_nullable
as String, as String,
destinationRef: null == destinationRef destinationRef:
null == destinationRef
? _value.destinationRef ? _value.destinationRef
: destinationRef // ignore: cast_nullable_to_non_nullable : destinationRef // ignore: cast_nullable_to_non_nullable
as String, as String,
activitiesRef: null == activitiesRef activitiesRef:
null == activitiesRef
? _value.activitiesRef ? _value.activitiesRef
: activitiesRef // ignore: cast_nullable_to_non_nullable : activitiesRef // ignore: cast_nullable_to_non_nullable
as List<String>, as List<String>,
) as $Val); )
as $Val,
);
} }
} }
/// @nodoc /// @nodoc
abstract class _$$BookingApiModelImplCopyWith<$Res> abstract class _$$BookingApiModelImplCopyWith<$Res>
implements $BookingApiModelCopyWith<$Res> { implements $BookingApiModelCopyWith<$Res> {
factory _$$BookingApiModelImplCopyWith(_$BookingApiModelImpl value, factory _$$BookingApiModelImplCopyWith(
$Res Function(_$BookingApiModelImpl) then) = _$BookingApiModelImpl value,
__$$BookingApiModelImplCopyWithImpl<$Res>; $Res Function(_$BookingApiModelImpl) then,
) = __$$BookingApiModelImplCopyWithImpl<$Res>;
@override @override
@useResult @useResult
$Res call( $Res call({
{int? id, int? id,
DateTime startDate, DateTime startDate,
DateTime endDate, DateTime endDate,
String name, String name,
String destinationRef, String destinationRef,
List<String> activitiesRef}); List<String> activitiesRef,
});
} }
/// @nodoc /// @nodoc
@ -137,8 +151,9 @@ class __$$BookingApiModelImplCopyWithImpl<$Res>
extends _$BookingApiModelCopyWithImpl<$Res, _$BookingApiModelImpl> extends _$BookingApiModelCopyWithImpl<$Res, _$BookingApiModelImpl>
implements _$$BookingApiModelImplCopyWith<$Res> { implements _$$BookingApiModelImplCopyWith<$Res> {
__$$BookingApiModelImplCopyWithImpl( __$$BookingApiModelImplCopyWithImpl(
_$BookingApiModelImpl _value, $Res Function(_$BookingApiModelImpl) _then) _$BookingApiModelImpl _value,
: super(_value, _then); $Res Function(_$BookingApiModelImpl) _then,
) : super(_value, _then);
/// Create a copy of BookingApiModel /// Create a copy of BookingApiModel
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@ -152,46 +167,54 @@ class __$$BookingApiModelImplCopyWithImpl<$Res>
Object? destinationRef = null, Object? destinationRef = null,
Object? activitiesRef = null, Object? activitiesRef = null,
}) { }) {
return _then(_$BookingApiModelImpl( return _then(
id: freezed == id _$BookingApiModelImpl(
id:
freezed == id
? _value.id ? _value.id
: id // ignore: cast_nullable_to_non_nullable : id // ignore: cast_nullable_to_non_nullable
as int?, as int?,
startDate: null == startDate startDate:
null == startDate
? _value.startDate ? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable : startDate // ignore: cast_nullable_to_non_nullable
as DateTime, as DateTime,
endDate: null == endDate endDate:
null == endDate
? _value.endDate ? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable : endDate // ignore: cast_nullable_to_non_nullable
as DateTime, as DateTime,
name: null == name name:
null == name
? _value.name ? _value.name
: name // ignore: cast_nullable_to_non_nullable : name // ignore: cast_nullable_to_non_nullable
as String, as String,
destinationRef: null == destinationRef destinationRef:
null == destinationRef
? _value.destinationRef ? _value.destinationRef
: destinationRef // ignore: cast_nullable_to_non_nullable : destinationRef // ignore: cast_nullable_to_non_nullable
as String, as String,
activitiesRef: null == activitiesRef activitiesRef:
null == activitiesRef
? _value._activitiesRef ? _value._activitiesRef
: activitiesRef // ignore: cast_nullable_to_non_nullable : activitiesRef // ignore: cast_nullable_to_non_nullable
as List<String>, as List<String>,
)); ),
);
} }
} }
/// @nodoc /// @nodoc
@JsonSerializable() @JsonSerializable()
class _$BookingApiModelImpl implements _BookingApiModel { class _$BookingApiModelImpl implements _BookingApiModel {
const _$BookingApiModelImpl( const _$BookingApiModelImpl({
{this.id, this.id,
required this.startDate, required this.startDate,
required this.endDate, required this.endDate,
required this.name, required this.name,
required this.destinationRef, required this.destinationRef,
required final List<String> activitiesRef}) required final List<String> activitiesRef,
: _activitiesRef = activitiesRef; }) : _activitiesRef = activitiesRef;
factory _$BookingApiModelImpl.fromJson(Map<String, dynamic> json) => factory _$BookingApiModelImpl.fromJson(Map<String, dynamic> json) =>
_$$BookingApiModelImplFromJson(json); _$$BookingApiModelImplFromJson(json);
@ -245,14 +268,23 @@ class _$BookingApiModelImpl implements _BookingApiModel {
(identical(other.name, name) || other.name == name) && (identical(other.name, name) || other.name == name) &&
(identical(other.destinationRef, destinationRef) || (identical(other.destinationRef, destinationRef) ||
other.destinationRef == destinationRef) && other.destinationRef == destinationRef) &&
const DeepCollectionEquality() const DeepCollectionEquality().equals(
.equals(other._activitiesRef, _activitiesRef)); other._activitiesRef,
_activitiesRef,
));
} }
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@override @override
int get hashCode => Object.hash(runtimeType, id, startDate, endDate, name, int get hashCode => Object.hash(
destinationRef, const DeepCollectionEquality().hash(_activitiesRef)); runtimeType,
id,
startDate,
endDate,
name,
destinationRef,
const DeepCollectionEquality().hash(_activitiesRef),
);
/// Create a copy of BookingApiModel /// Create a copy of BookingApiModel
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@ -261,24 +293,25 @@ class _$BookingApiModelImpl implements _BookingApiModel {
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
_$$BookingApiModelImplCopyWith<_$BookingApiModelImpl> get copyWith => _$$BookingApiModelImplCopyWith<_$BookingApiModelImpl> get copyWith =>
__$$BookingApiModelImplCopyWithImpl<_$BookingApiModelImpl>( __$$BookingApiModelImplCopyWithImpl<_$BookingApiModelImpl>(
this, _$identity); this,
_$identity,
);
@override @override
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return _$$BookingApiModelImplToJson( return _$$BookingApiModelImplToJson(this);
this,
);
} }
} }
abstract class _BookingApiModel implements BookingApiModel { abstract class _BookingApiModel implements BookingApiModel {
const factory _BookingApiModel( const factory _BookingApiModel({
{final int? id, final int? id,
required final DateTime startDate, required final DateTime startDate,
required final DateTime endDate, required final DateTime endDate,
required final String name, required final String name,
required final String destinationRef, required final String destinationRef,
required final List<String> activitiesRef}) = _$BookingApiModelImpl; required final List<String> activitiesRef,
}) = _$BookingApiModelImpl;
factory _BookingApiModel.fromJson(Map<String, dynamic> json) = factory _BookingApiModel.fromJson(Map<String, dynamic> json) =
_$BookingApiModelImpl.fromJson; _$BookingApiModelImpl.fromJson;

@ -7,21 +7,20 @@ part of 'booking_api_model.dart';
// ************************************************************************** // **************************************************************************
_$BookingApiModelImpl _$$BookingApiModelImplFromJson( _$BookingApiModelImpl _$$BookingApiModelImplFromJson(
Map<String, dynamic> json) => Map<String, dynamic> json,
_$BookingApiModelImpl( ) => _$BookingApiModelImpl(
id: (json['id'] as num?)?.toInt(), id: (json['id'] as num?)?.toInt(),
startDate: DateTime.parse(json['startDate'] as String), startDate: DateTime.parse(json['startDate'] as String),
endDate: DateTime.parse(json['endDate'] as String), endDate: DateTime.parse(json['endDate'] as String),
name: json['name'] as String, name: json['name'] as String,
destinationRef: json['destinationRef'] as String, destinationRef: json['destinationRef'] as String,
activitiesRef: (json['activitiesRef'] as List<dynamic>) activitiesRef:
.map((e) => e as String) (json['activitiesRef'] as List<dynamic>).map((e) => e as String).toList(),
.toList(),
); );
Map<String, dynamic> _$$BookingApiModelImplToJson( Map<String, dynamic> _$$BookingApiModelImplToJson(
_$BookingApiModelImpl instance) => _$BookingApiModelImpl instance,
<String, dynamic>{ ) => <String, dynamic>{
'id': instance.id, 'id': instance.id,
'startDate': instance.startDate.toIso8601String(), 'startDate': instance.startDate.toIso8601String(),
'endDate': instance.endDate.toIso8601String(), 'endDate': instance.endDate.toIso8601String(),

@ -12,7 +12,8 @@ part of 'login_request.dart';
T _$identity<T>(T value) => value; T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError( final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
);
LoginRequest _$LoginRequestFromJson(Map<String, dynamic> json) { LoginRequest _$LoginRequestFromJson(Map<String, dynamic> json) {
return _LoginRequest.fromJson(json); return _LoginRequest.fromJson(json);
@ -39,8 +40,9 @@ mixin _$LoginRequest {
/// @nodoc /// @nodoc
abstract class $LoginRequestCopyWith<$Res> { abstract class $LoginRequestCopyWith<$Res> {
factory $LoginRequestCopyWith( factory $LoginRequestCopyWith(
LoginRequest value, $Res Function(LoginRequest) then) = LoginRequest value,
_$LoginRequestCopyWithImpl<$Res, LoginRequest>; $Res Function(LoginRequest) then,
) = _$LoginRequestCopyWithImpl<$Res, LoginRequest>;
@useResult @useResult
$Res call({String email, String password}); $Res call({String email, String password});
} }
@ -59,20 +61,22 @@ class _$LoginRequestCopyWithImpl<$Res, $Val extends LoginRequest>
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({Object? email = null, Object? password = null}) {
Object? email = null, return _then(
Object? password = null, _value.copyWith(
}) { email:
return _then(_value.copyWith( null == email
email: null == email
? _value.email ? _value.email
: email // ignore: cast_nullable_to_non_nullable : email // ignore: cast_nullable_to_non_nullable
as String, as String,
password: null == password password:
null == password
? _value.password ? _value.password
: password // ignore: cast_nullable_to_non_nullable : password // ignore: cast_nullable_to_non_nullable
as String, as String,
) as $Val); )
as $Val,
);
} }
} }
@ -80,8 +84,9 @@ class _$LoginRequestCopyWithImpl<$Res, $Val extends LoginRequest>
abstract class _$$LoginRequestImplCopyWith<$Res> abstract class _$$LoginRequestImplCopyWith<$Res>
implements $LoginRequestCopyWith<$Res> { implements $LoginRequestCopyWith<$Res> {
factory _$$LoginRequestImplCopyWith( factory _$$LoginRequestImplCopyWith(
_$LoginRequestImpl value, $Res Function(_$LoginRequestImpl) then) = _$LoginRequestImpl value,
__$$LoginRequestImplCopyWithImpl<$Res>; $Res Function(_$LoginRequestImpl) then,
) = __$$LoginRequestImplCopyWithImpl<$Res>;
@override @override
@useResult @useResult
$Res call({String email, String password}); $Res call({String email, String password});
@ -92,27 +97,29 @@ class __$$LoginRequestImplCopyWithImpl<$Res>
extends _$LoginRequestCopyWithImpl<$Res, _$LoginRequestImpl> extends _$LoginRequestCopyWithImpl<$Res, _$LoginRequestImpl>
implements _$$LoginRequestImplCopyWith<$Res> { implements _$$LoginRequestImplCopyWith<$Res> {
__$$LoginRequestImplCopyWithImpl( __$$LoginRequestImplCopyWithImpl(
_$LoginRequestImpl _value, $Res Function(_$LoginRequestImpl) _then) _$LoginRequestImpl _value,
: super(_value, _then); $Res Function(_$LoginRequestImpl) _then,
) : super(_value, _then);
/// Create a copy of LoginRequest /// Create a copy of LoginRequest
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({Object? email = null, Object? password = null}) {
Object? email = null, return _then(
Object? password = null, _$LoginRequestImpl(
}) { email:
return _then(_$LoginRequestImpl( null == email
email: null == email
? _value.email ? _value.email
: email // ignore: cast_nullable_to_non_nullable : email // ignore: cast_nullable_to_non_nullable
as String, as String,
password: null == password password:
null == password
? _value.password ? _value.password
: password // ignore: cast_nullable_to_non_nullable : password // ignore: cast_nullable_to_non_nullable
as String, as String,
)); ),
);
} }
} }
@ -161,16 +168,15 @@ class _$LoginRequestImpl implements _LoginRequest {
@override @override
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return _$$LoginRequestImplToJson( return _$$LoginRequestImplToJson(this);
this,
);
} }
} }
abstract class _LoginRequest implements LoginRequest { abstract class _LoginRequest implements LoginRequest {
const factory _LoginRequest( const factory _LoginRequest({
{required final String email, required final String email,
required final String password}) = _$LoginRequestImpl; required final String password,
}) = _$LoginRequestImpl;
factory _LoginRequest.fromJson(Map<String, dynamic> json) = factory _LoginRequest.fromJson(Map<String, dynamic> json) =
_$LoginRequestImpl.fromJson; _$LoginRequestImpl.fromJson;

@ -13,7 +13,4 @@ _$LoginRequestImpl _$$LoginRequestImplFromJson(Map<String, dynamic> json) =>
); );
Map<String, dynamic> _$$LoginRequestImplToJson(_$LoginRequestImpl instance) => Map<String, dynamic> _$$LoginRequestImplToJson(_$LoginRequestImpl instance) =>
<String, dynamic>{ <String, dynamic>{'email': instance.email, 'password': instance.password};
'email': instance.email,
'password': instance.password,
};

@ -12,7 +12,8 @@ part of 'login_response.dart';
T _$identity<T>(T value) => value; T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError( final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
);
LoginResponse _$LoginResponseFromJson(Map<String, dynamic> json) { LoginResponse _$LoginResponseFromJson(Map<String, dynamic> json) {
return _LoginResponse.fromJson(json); return _LoginResponse.fromJson(json);
@ -39,8 +40,9 @@ mixin _$LoginResponse {
/// @nodoc /// @nodoc
abstract class $LoginResponseCopyWith<$Res> { abstract class $LoginResponseCopyWith<$Res> {
factory $LoginResponseCopyWith( factory $LoginResponseCopyWith(
LoginResponse value, $Res Function(LoginResponse) then) = LoginResponse value,
_$LoginResponseCopyWithImpl<$Res, LoginResponse>; $Res Function(LoginResponse) then,
) = _$LoginResponseCopyWithImpl<$Res, LoginResponse>;
@useResult @useResult
$Res call({String token, String userId}); $Res call({String token, String userId});
} }
@ -59,20 +61,22 @@ class _$LoginResponseCopyWithImpl<$Res, $Val extends LoginResponse>
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({Object? token = null, Object? userId = null}) {
Object? token = null, return _then(
Object? userId = null, _value.copyWith(
}) { token:
return _then(_value.copyWith( null == token
token: null == token
? _value.token ? _value.token
: token // ignore: cast_nullable_to_non_nullable : token // ignore: cast_nullable_to_non_nullable
as String, as String,
userId: null == userId userId:
null == userId
? _value.userId ? _value.userId
: userId // ignore: cast_nullable_to_non_nullable : userId // ignore: cast_nullable_to_non_nullable
as String, as String,
) as $Val); )
as $Val,
);
} }
} }
@ -80,8 +84,9 @@ class _$LoginResponseCopyWithImpl<$Res, $Val extends LoginResponse>
abstract class _$$LoginResponseImplCopyWith<$Res> abstract class _$$LoginResponseImplCopyWith<$Res>
implements $LoginResponseCopyWith<$Res> { implements $LoginResponseCopyWith<$Res> {
factory _$$LoginResponseImplCopyWith( factory _$$LoginResponseImplCopyWith(
_$LoginResponseImpl value, $Res Function(_$LoginResponseImpl) then) = _$LoginResponseImpl value,
__$$LoginResponseImplCopyWithImpl<$Res>; $Res Function(_$LoginResponseImpl) then,
) = __$$LoginResponseImplCopyWithImpl<$Res>;
@override @override
@useResult @useResult
$Res call({String token, String userId}); $Res call({String token, String userId});
@ -92,27 +97,29 @@ class __$$LoginResponseImplCopyWithImpl<$Res>
extends _$LoginResponseCopyWithImpl<$Res, _$LoginResponseImpl> extends _$LoginResponseCopyWithImpl<$Res, _$LoginResponseImpl>
implements _$$LoginResponseImplCopyWith<$Res> { implements _$$LoginResponseImplCopyWith<$Res> {
__$$LoginResponseImplCopyWithImpl( __$$LoginResponseImplCopyWithImpl(
_$LoginResponseImpl _value, $Res Function(_$LoginResponseImpl) _then) _$LoginResponseImpl _value,
: super(_value, _then); $Res Function(_$LoginResponseImpl) _then,
) : super(_value, _then);
/// Create a copy of LoginResponse /// Create a copy of LoginResponse
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({Object? token = null, Object? userId = null}) {
Object? token = null, return _then(
Object? userId = null, _$LoginResponseImpl(
}) { token:
return _then(_$LoginResponseImpl( null == token
token: null == token
? _value.token ? _value.token
: token // ignore: cast_nullable_to_non_nullable : token // ignore: cast_nullable_to_non_nullable
as String, as String,
userId: null == userId userId:
null == userId
? _value.userId ? _value.userId
: userId // ignore: cast_nullable_to_non_nullable : userId // ignore: cast_nullable_to_non_nullable
as String, as String,
)); ),
);
} }
} }
@ -160,16 +167,15 @@ class _$LoginResponseImpl implements _LoginResponse {
@override @override
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return _$$LoginResponseImplToJson( return _$$LoginResponseImplToJson(this);
this,
);
} }
} }
abstract class _LoginResponse implements LoginResponse { abstract class _LoginResponse implements LoginResponse {
const factory _LoginResponse( const factory _LoginResponse({
{required final String token, required final String token,
required final String userId}) = _$LoginResponseImpl; required final String userId,
}) = _$LoginResponseImpl;
factory _LoginResponse.fromJson(Map<String, dynamic> json) = factory _LoginResponse.fromJson(Map<String, dynamic> json) =
_$LoginResponseImpl.fromJson; _$LoginResponseImpl.fromJson;

@ -13,7 +13,4 @@ _$LoginResponseImpl _$$LoginResponseImplFromJson(Map<String, dynamic> json) =>
); );
Map<String, dynamic> _$$LoginResponseImplToJson(_$LoginResponseImpl instance) => Map<String, dynamic> _$$LoginResponseImplToJson(_$LoginResponseImpl instance) =>
<String, dynamic>{ <String, dynamic>{'token': instance.token, 'userId': instance.userId};
'token': instance.token,
'userId': instance.userId,
};

@ -12,7 +12,8 @@ part of 'user_api_model.dart';
T _$identity<T>(T value) => value; T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError( final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
);
UserApiModel _$UserApiModelFromJson(Map<String, dynamic> json) { UserApiModel _$UserApiModelFromJson(Map<String, dynamic> json) {
return _UserApiModel.fromJson(json); return _UserApiModel.fromJson(json);
@ -45,8 +46,9 @@ mixin _$UserApiModel {
/// @nodoc /// @nodoc
abstract class $UserApiModelCopyWith<$Res> { abstract class $UserApiModelCopyWith<$Res> {
factory $UserApiModelCopyWith( factory $UserApiModelCopyWith(
UserApiModel value, $Res Function(UserApiModel) then) = UserApiModel value,
_$UserApiModelCopyWithImpl<$Res, UserApiModel>; $Res Function(UserApiModel) then,
) = _$UserApiModelCopyWithImpl<$Res, UserApiModel>;
@useResult @useResult
$Res call({String id, String name, String email, String picture}); $Res call({String id, String name, String email, String picture});
} }
@ -71,24 +73,31 @@ class _$UserApiModelCopyWithImpl<$Res, $Val extends UserApiModel>
Object? email = null, Object? email = null,
Object? picture = null, Object? picture = null,
}) { }) {
return _then(_value.copyWith( return _then(
id: null == id _value.copyWith(
id:
null == id
? _value.id ? _value.id
: id // ignore: cast_nullable_to_non_nullable : id // ignore: cast_nullable_to_non_nullable
as String, as String,
name: null == name name:
null == name
? _value.name ? _value.name
: name // ignore: cast_nullable_to_non_nullable : name // ignore: cast_nullable_to_non_nullable
as String, as String,
email: null == email email:
null == email
? _value.email ? _value.email
: email // ignore: cast_nullable_to_non_nullable : email // ignore: cast_nullable_to_non_nullable
as String, as String,
picture: null == picture picture:
null == picture
? _value.picture ? _value.picture
: picture // ignore: cast_nullable_to_non_nullable : picture // ignore: cast_nullable_to_non_nullable
as String, as String,
) as $Val); )
as $Val,
);
} }
} }
@ -96,8 +105,9 @@ class _$UserApiModelCopyWithImpl<$Res, $Val extends UserApiModel>
abstract class _$$UserApiModelImplCopyWith<$Res> abstract class _$$UserApiModelImplCopyWith<$Res>
implements $UserApiModelCopyWith<$Res> { implements $UserApiModelCopyWith<$Res> {
factory _$$UserApiModelImplCopyWith( factory _$$UserApiModelImplCopyWith(
_$UserApiModelImpl value, $Res Function(_$UserApiModelImpl) then) = _$UserApiModelImpl value,
__$$UserApiModelImplCopyWithImpl<$Res>; $Res Function(_$UserApiModelImpl) then,
) = __$$UserApiModelImplCopyWithImpl<$Res>;
@override @override
@useResult @useResult
$Res call({String id, String name, String email, String picture}); $Res call({String id, String name, String email, String picture});
@ -108,8 +118,9 @@ class __$$UserApiModelImplCopyWithImpl<$Res>
extends _$UserApiModelCopyWithImpl<$Res, _$UserApiModelImpl> extends _$UserApiModelCopyWithImpl<$Res, _$UserApiModelImpl>
implements _$$UserApiModelImplCopyWith<$Res> { implements _$$UserApiModelImplCopyWith<$Res> {
__$$UserApiModelImplCopyWithImpl( __$$UserApiModelImplCopyWithImpl(
_$UserApiModelImpl _value, $Res Function(_$UserApiModelImpl) _then) _$UserApiModelImpl _value,
: super(_value, _then); $Res Function(_$UserApiModelImpl) _then,
) : super(_value, _then);
/// Create a copy of UserApiModel /// Create a copy of UserApiModel
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@ -121,35 +132,42 @@ class __$$UserApiModelImplCopyWithImpl<$Res>
Object? email = null, Object? email = null,
Object? picture = null, Object? picture = null,
}) { }) {
return _then(_$UserApiModelImpl( return _then(
id: null == id _$UserApiModelImpl(
id:
null == id
? _value.id ? _value.id
: id // ignore: cast_nullable_to_non_nullable : id // ignore: cast_nullable_to_non_nullable
as String, as String,
name: null == name name:
null == name
? _value.name ? _value.name
: name // ignore: cast_nullable_to_non_nullable : name // ignore: cast_nullable_to_non_nullable
as String, as String,
email: null == email email:
null == email
? _value.email ? _value.email
: email // ignore: cast_nullable_to_non_nullable : email // ignore: cast_nullable_to_non_nullable
as String, as String,
picture: null == picture picture:
null == picture
? _value.picture ? _value.picture
: picture // ignore: cast_nullable_to_non_nullable : picture // ignore: cast_nullable_to_non_nullable
as String, as String,
)); ),
);
} }
} }
/// @nodoc /// @nodoc
@JsonSerializable() @JsonSerializable()
class _$UserApiModelImpl implements _UserApiModel { class _$UserApiModelImpl implements _UserApiModel {
const _$UserApiModelImpl( const _$UserApiModelImpl({
{required this.id, required this.id,
required this.name, required this.name,
required this.email, required this.email,
required this.picture}); required this.picture,
});
factory _$UserApiModelImpl.fromJson(Map<String, dynamic> json) => factory _$UserApiModelImpl.fromJson(Map<String, dynamic> json) =>
_$$UserApiModelImplFromJson(json); _$$UserApiModelImplFromJson(json);
@ -200,18 +218,17 @@ class _$UserApiModelImpl implements _UserApiModel {
@override @override
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return _$$UserApiModelImplToJson( return _$$UserApiModelImplToJson(this);
this,
);
} }
} }
abstract class _UserApiModel implements UserApiModel { abstract class _UserApiModel implements UserApiModel {
const factory _UserApiModel( const factory _UserApiModel({
{required final String id, required final String id,
required final String name, required final String name,
required final String email, required final String email,
required final String picture}) = _$UserApiModelImpl; required final String picture,
}) = _$UserApiModelImpl;
factory _UserApiModel.fromJson(Map<String, dynamic> json) = factory _UserApiModel.fromJson(Map<String, dynamic> json) =
_$UserApiModelImpl.fromJson; _$UserApiModelImpl.fromJson;

@ -8,13 +8,7 @@ part 'activity.freezed.dart';
part 'activity.g.dart'; part 'activity.g.dart';
enum TimeOfDay { enum TimeOfDay { any, morning, afternoon, evening, night }
any,
morning,
afternoon,
evening,
night,
}
@freezed @freezed
class Activity with _$Activity { class Activity with _$Activity {

@ -12,7 +12,8 @@ part of 'activity.dart';
T _$identity<T>(T value) => value; T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError( final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
);
Activity _$ActivityFromJson(Map<String, dynamic> json) { Activity _$ActivityFromJson(Map<String, dynamic> json) {
return _Activity.fromJson(json); return _Activity.fromJson(json);
@ -66,8 +67,8 @@ abstract class $ActivityCopyWith<$Res> {
factory $ActivityCopyWith(Activity value, $Res Function(Activity) then) = factory $ActivityCopyWith(Activity value, $Res Function(Activity) then) =
_$ActivityCopyWithImpl<$Res, Activity>; _$ActivityCopyWithImpl<$Res, Activity>;
@useResult @useResult
$Res call( $Res call({
{String name, String name,
String description, String description,
String locationName, String locationName,
int duration, int duration,
@ -76,7 +77,8 @@ abstract class $ActivityCopyWith<$Res> {
int price, int price,
String destinationRef, String destinationRef,
String ref, String ref,
String imageUrl}); String imageUrl,
});
} }
/// @nodoc /// @nodoc
@ -105,48 +107,61 @@ class _$ActivityCopyWithImpl<$Res, $Val extends Activity>
Object? ref = null, Object? ref = null,
Object? imageUrl = null, Object? imageUrl = null,
}) { }) {
return _then(_value.copyWith( return _then(
name: null == name _value.copyWith(
name:
null == name
? _value.name ? _value.name
: name // ignore: cast_nullable_to_non_nullable : name // ignore: cast_nullable_to_non_nullable
as String, as String,
description: null == description description:
null == description
? _value.description ? _value.description
: description // ignore: cast_nullable_to_non_nullable : description // ignore: cast_nullable_to_non_nullable
as String, as String,
locationName: null == locationName locationName:
null == locationName
? _value.locationName ? _value.locationName
: locationName // ignore: cast_nullable_to_non_nullable : locationName // ignore: cast_nullable_to_non_nullable
as String, as String,
duration: null == duration duration:
null == duration
? _value.duration ? _value.duration
: duration // ignore: cast_nullable_to_non_nullable : duration // ignore: cast_nullable_to_non_nullable
as int, as int,
timeOfDay: null == timeOfDay timeOfDay:
null == timeOfDay
? _value.timeOfDay ? _value.timeOfDay
: timeOfDay // ignore: cast_nullable_to_non_nullable : timeOfDay // ignore: cast_nullable_to_non_nullable
as TimeOfDay, as TimeOfDay,
familyFriendly: null == familyFriendly familyFriendly:
null == familyFriendly
? _value.familyFriendly ? _value.familyFriendly
: familyFriendly // ignore: cast_nullable_to_non_nullable : familyFriendly // ignore: cast_nullable_to_non_nullable
as bool, as bool,
price: null == price price:
null == price
? _value.price ? _value.price
: price // ignore: cast_nullable_to_non_nullable : price // ignore: cast_nullable_to_non_nullable
as int, as int,
destinationRef: null == destinationRef destinationRef:
null == destinationRef
? _value.destinationRef ? _value.destinationRef
: destinationRef // ignore: cast_nullable_to_non_nullable : destinationRef // ignore: cast_nullable_to_non_nullable
as String, as String,
ref: null == ref ref:
null == ref
? _value.ref ? _value.ref
: ref // ignore: cast_nullable_to_non_nullable : ref // ignore: cast_nullable_to_non_nullable
as String, as String,
imageUrl: null == imageUrl imageUrl:
null == imageUrl
? _value.imageUrl ? _value.imageUrl
: imageUrl // ignore: cast_nullable_to_non_nullable : imageUrl // ignore: cast_nullable_to_non_nullable
as String, as String,
) as $Val); )
as $Val,
);
} }
} }
@ -154,12 +169,13 @@ class _$ActivityCopyWithImpl<$Res, $Val extends Activity>
abstract class _$$ActivityImplCopyWith<$Res> abstract class _$$ActivityImplCopyWith<$Res>
implements $ActivityCopyWith<$Res> { implements $ActivityCopyWith<$Res> {
factory _$$ActivityImplCopyWith( factory _$$ActivityImplCopyWith(
_$ActivityImpl value, $Res Function(_$ActivityImpl) then) = _$ActivityImpl value,
__$$ActivityImplCopyWithImpl<$Res>; $Res Function(_$ActivityImpl) then,
) = __$$ActivityImplCopyWithImpl<$Res>;
@override @override
@useResult @useResult
$Res call( $Res call({
{String name, String name,
String description, String description,
String locationName, String locationName,
int duration, int duration,
@ -168,7 +184,8 @@ abstract class _$$ActivityImplCopyWith<$Res>
int price, int price,
String destinationRef, String destinationRef,
String ref, String ref,
String imageUrl}); String imageUrl,
});
} }
/// @nodoc /// @nodoc
@ -176,8 +193,9 @@ class __$$ActivityImplCopyWithImpl<$Res>
extends _$ActivityCopyWithImpl<$Res, _$ActivityImpl> extends _$ActivityCopyWithImpl<$Res, _$ActivityImpl>
implements _$$ActivityImplCopyWith<$Res> { implements _$$ActivityImplCopyWith<$Res> {
__$$ActivityImplCopyWithImpl( __$$ActivityImplCopyWithImpl(
_$ActivityImpl _value, $Res Function(_$ActivityImpl) _then) _$ActivityImpl _value,
: super(_value, _then); $Res Function(_$ActivityImpl) _then,
) : super(_value, _then);
/// Create a copy of Activity /// Create a copy of Activity
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@ -195,56 +213,68 @@ class __$$ActivityImplCopyWithImpl<$Res>
Object? ref = null, Object? ref = null,
Object? imageUrl = null, Object? imageUrl = null,
}) { }) {
return _then(_$ActivityImpl( return _then(
name: null == name _$ActivityImpl(
name:
null == name
? _value.name ? _value.name
: name // ignore: cast_nullable_to_non_nullable : name // ignore: cast_nullable_to_non_nullable
as String, as String,
description: null == description description:
null == description
? _value.description ? _value.description
: description // ignore: cast_nullable_to_non_nullable : description // ignore: cast_nullable_to_non_nullable
as String, as String,
locationName: null == locationName locationName:
null == locationName
? _value.locationName ? _value.locationName
: locationName // ignore: cast_nullable_to_non_nullable : locationName // ignore: cast_nullable_to_non_nullable
as String, as String,
duration: null == duration duration:
null == duration
? _value.duration ? _value.duration
: duration // ignore: cast_nullable_to_non_nullable : duration // ignore: cast_nullable_to_non_nullable
as int, as int,
timeOfDay: null == timeOfDay timeOfDay:
null == timeOfDay
? _value.timeOfDay ? _value.timeOfDay
: timeOfDay // ignore: cast_nullable_to_non_nullable : timeOfDay // ignore: cast_nullable_to_non_nullable
as TimeOfDay, as TimeOfDay,
familyFriendly: null == familyFriendly familyFriendly:
null == familyFriendly
? _value.familyFriendly ? _value.familyFriendly
: familyFriendly // ignore: cast_nullable_to_non_nullable : familyFriendly // ignore: cast_nullable_to_non_nullable
as bool, as bool,
price: null == price price:
null == price
? _value.price ? _value.price
: price // ignore: cast_nullable_to_non_nullable : price // ignore: cast_nullable_to_non_nullable
as int, as int,
destinationRef: null == destinationRef destinationRef:
null == destinationRef
? _value.destinationRef ? _value.destinationRef
: destinationRef // ignore: cast_nullable_to_non_nullable : destinationRef // ignore: cast_nullable_to_non_nullable
as String, as String,
ref: null == ref ref:
null == ref
? _value.ref ? _value.ref
: ref // ignore: cast_nullable_to_non_nullable : ref // ignore: cast_nullable_to_non_nullable
as String, as String,
imageUrl: null == imageUrl imageUrl:
null == imageUrl
? _value.imageUrl ? _value.imageUrl
: imageUrl // ignore: cast_nullable_to_non_nullable : imageUrl // ignore: cast_nullable_to_non_nullable
as String, as String,
)); ),
);
} }
} }
/// @nodoc /// @nodoc
@JsonSerializable() @JsonSerializable()
class _$ActivityImpl implements _Activity { class _$ActivityImpl implements _Activity {
const _$ActivityImpl( const _$ActivityImpl({
{required this.name, required this.name,
required this.description, required this.description,
required this.locationName, required this.locationName,
required this.duration, required this.duration,
@ -253,7 +283,8 @@ class _$ActivityImpl implements _Activity {
required this.price, required this.price,
required this.destinationRef, required this.destinationRef,
required this.ref, required this.ref,
required this.imageUrl}); required this.imageUrl,
});
factory _$ActivityImpl.fromJson(Map<String, dynamic> json) => factory _$ActivityImpl.fromJson(Map<String, dynamic> json) =>
_$$ActivityImplFromJson(json); _$$ActivityImplFromJson(json);
@ -341,7 +372,8 @@ class _$ActivityImpl implements _Activity {
price, price,
destinationRef, destinationRef,
ref, ref,
imageUrl); imageUrl,
);
/// Create a copy of Activity /// Create a copy of Activity
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@ -353,15 +385,13 @@ class _$ActivityImpl implements _Activity {
@override @override
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return _$$ActivityImplToJson( return _$$ActivityImplToJson(this);
this,
);
} }
} }
abstract class _Activity implements Activity { abstract class _Activity implements Activity {
const factory _Activity( const factory _Activity({
{required final String name, required final String name,
required final String description, required final String description,
required final String locationName, required final String locationName,
required final int duration, required final int duration,
@ -370,7 +400,8 @@ abstract class _Activity implements Activity {
required final int price, required final int price,
required final String destinationRef, required final String destinationRef,
required final String ref, required final String ref,
required final String imageUrl}) = _$ActivityImpl; required final String imageUrl,
}) = _$ActivityImpl;
factory _Activity.fromJson(Map<String, dynamic> json) = factory _Activity.fromJson(Map<String, dynamic> json) =
_$ActivityImpl.fromJson; _$ActivityImpl.fromJson;

@ -12,7 +12,8 @@ part of 'booking.dart';
T _$identity<T>(T value) => value; T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError( final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
);
Booking _$BookingFromJson(Map<String, dynamic> json) { Booking _$BookingFromJson(Map<String, dynamic> json) {
return _Booking.fromJson(json); return _Booking.fromJson(json);
@ -50,12 +51,13 @@ abstract class $BookingCopyWith<$Res> {
factory $BookingCopyWith(Booking value, $Res Function(Booking) then) = factory $BookingCopyWith(Booking value, $Res Function(Booking) then) =
_$BookingCopyWithImpl<$Res, Booking>; _$BookingCopyWithImpl<$Res, Booking>;
@useResult @useResult
$Res call( $Res call({
{int? id, int? id,
DateTime startDate, DateTime startDate,
DateTime endDate, DateTime endDate,
Destination destination, Destination destination,
List<Activity> activity}); List<Activity> activity,
});
$DestinationCopyWith<$Res> get destination; $DestinationCopyWith<$Res> get destination;
} }
@ -81,28 +83,36 @@ class _$BookingCopyWithImpl<$Res, $Val extends Booking>
Object? destination = null, Object? destination = null,
Object? activity = null, Object? activity = null,
}) { }) {
return _then(_value.copyWith( return _then(
id: freezed == id _value.copyWith(
id:
freezed == id
? _value.id ? _value.id
: id // ignore: cast_nullable_to_non_nullable : id // ignore: cast_nullable_to_non_nullable
as int?, as int?,
startDate: null == startDate startDate:
null == startDate
? _value.startDate ? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable : startDate // ignore: cast_nullable_to_non_nullable
as DateTime, as DateTime,
endDate: null == endDate endDate:
null == endDate
? _value.endDate ? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable : endDate // ignore: cast_nullable_to_non_nullable
as DateTime, as DateTime,
destination: null == destination destination:
null == destination
? _value.destination ? _value.destination
: destination // ignore: cast_nullable_to_non_nullable : destination // ignore: cast_nullable_to_non_nullable
as Destination, as Destination,
activity: null == activity activity:
null == activity
? _value.activity ? _value.activity
: activity // ignore: cast_nullable_to_non_nullable : activity // ignore: cast_nullable_to_non_nullable
as List<Activity>, as List<Activity>,
) as $Val); )
as $Val,
);
} }
/// Create a copy of Booking /// Create a copy of Booking
@ -119,16 +129,18 @@ class _$BookingCopyWithImpl<$Res, $Val extends Booking>
/// @nodoc /// @nodoc
abstract class _$$BookingImplCopyWith<$Res> implements $BookingCopyWith<$Res> { abstract class _$$BookingImplCopyWith<$Res> implements $BookingCopyWith<$Res> {
factory _$$BookingImplCopyWith( factory _$$BookingImplCopyWith(
_$BookingImpl value, $Res Function(_$BookingImpl) then) = _$BookingImpl value,
__$$BookingImplCopyWithImpl<$Res>; $Res Function(_$BookingImpl) then,
) = __$$BookingImplCopyWithImpl<$Res>;
@override @override
@useResult @useResult
$Res call( $Res call({
{int? id, int? id,
DateTime startDate, DateTime startDate,
DateTime endDate, DateTime endDate,
Destination destination, Destination destination,
List<Activity> activity}); List<Activity> activity,
});
@override @override
$DestinationCopyWith<$Res> get destination; $DestinationCopyWith<$Res> get destination;
@ -139,8 +151,9 @@ class __$$BookingImplCopyWithImpl<$Res>
extends _$BookingCopyWithImpl<$Res, _$BookingImpl> extends _$BookingCopyWithImpl<$Res, _$BookingImpl>
implements _$$BookingImplCopyWith<$Res> { implements _$$BookingImplCopyWith<$Res> {
__$$BookingImplCopyWithImpl( __$$BookingImplCopyWithImpl(
_$BookingImpl _value, $Res Function(_$BookingImpl) _then) _$BookingImpl _value,
: super(_value, _then); $Res Function(_$BookingImpl) _then,
) : super(_value, _then);
/// Create a copy of Booking /// Create a copy of Booking
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@ -153,41 +166,48 @@ class __$$BookingImplCopyWithImpl<$Res>
Object? destination = null, Object? destination = null,
Object? activity = null, Object? activity = null,
}) { }) {
return _then(_$BookingImpl( return _then(
id: freezed == id _$BookingImpl(
id:
freezed == id
? _value.id ? _value.id
: id // ignore: cast_nullable_to_non_nullable : id // ignore: cast_nullable_to_non_nullable
as int?, as int?,
startDate: null == startDate startDate:
null == startDate
? _value.startDate ? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable : startDate // ignore: cast_nullable_to_non_nullable
as DateTime, as DateTime,
endDate: null == endDate endDate:
null == endDate
? _value.endDate ? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable : endDate // ignore: cast_nullable_to_non_nullable
as DateTime, as DateTime,
destination: null == destination destination:
null == destination
? _value.destination ? _value.destination
: destination // ignore: cast_nullable_to_non_nullable : destination // ignore: cast_nullable_to_non_nullable
as Destination, as Destination,
activity: null == activity activity:
null == activity
? _value._activity ? _value._activity
: activity // ignore: cast_nullable_to_non_nullable : activity // ignore: cast_nullable_to_non_nullable
as List<Activity>, as List<Activity>,
)); ),
);
} }
} }
/// @nodoc /// @nodoc
@JsonSerializable() @JsonSerializable()
class _$BookingImpl implements _Booking { class _$BookingImpl implements _Booking {
const _$BookingImpl( const _$BookingImpl({
{this.id, this.id,
required this.startDate, required this.startDate,
required this.endDate, required this.endDate,
required this.destination, required this.destination,
required final List<Activity> activity}) required final List<Activity> activity,
: _activity = activity; }) : _activity = activity;
factory _$BookingImpl.fromJson(Map<String, dynamic> json) => factory _$BookingImpl.fromJson(Map<String, dynamic> json) =>
_$$BookingImplFromJson(json); _$$BookingImplFromJson(json);
@ -241,8 +261,14 @@ class _$BookingImpl implements _Booking {
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@override @override
int get hashCode => Object.hash(runtimeType, id, startDate, endDate, int get hashCode => Object.hash(
destination, const DeepCollectionEquality().hash(_activity)); runtimeType,
id,
startDate,
endDate,
destination,
const DeepCollectionEquality().hash(_activity),
);
/// Create a copy of Booking /// Create a copy of Booking
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@ -254,19 +280,18 @@ class _$BookingImpl implements _Booking {
@override @override
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return _$$BookingImplToJson( return _$$BookingImplToJson(this);
this,
);
} }
} }
abstract class _Booking implements Booking { abstract class _Booking implements Booking {
const factory _Booking( const factory _Booking({
{final int? id, final int? id,
required final DateTime startDate, required final DateTime startDate,
required final DateTime endDate, required final DateTime endDate,
required final Destination destination, required final Destination destination,
required final List<Activity> activity}) = _$BookingImpl; required final List<Activity> activity,
}) = _$BookingImpl;
factory _Booking.fromJson(Map<String, dynamic> json) = _$BookingImpl.fromJson; factory _Booking.fromJson(Map<String, dynamic> json) = _$BookingImpl.fromJson;

@ -11,9 +11,11 @@ _$BookingImpl _$$BookingImplFromJson(Map<String, dynamic> json) =>
id: (json['id'] as num?)?.toInt(), id: (json['id'] as num?)?.toInt(),
startDate: DateTime.parse(json['startDate'] as String), startDate: DateTime.parse(json['startDate'] as String),
endDate: DateTime.parse(json['endDate'] as String), endDate: DateTime.parse(json['endDate'] as String),
destination: destination: Destination.fromJson(
Destination.fromJson(json['destination'] as Map<String, dynamic>), json['destination'] as Map<String, dynamic>,
activity: (json['activity'] as List<dynamic>) ),
activity:
(json['activity'] as List<dynamic>)
.map((e) => Activity.fromJson(e as Map<String, dynamic>)) .map((e) => Activity.fromJson(e as Map<String, dynamic>))
.toList(), .toList(),
); );

@ -12,7 +12,8 @@ part of 'booking_summary.dart';
T _$identity<T>(T value) => value; T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError( final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
);
BookingSummary _$BookingSummaryFromJson(Map<String, dynamic> json) { BookingSummary _$BookingSummaryFromJson(Map<String, dynamic> json) {
return _BookingSummary.fromJson(json); return _BookingSummary.fromJson(json);
@ -45,8 +46,9 @@ mixin _$BookingSummary {
/// @nodoc /// @nodoc
abstract class $BookingSummaryCopyWith<$Res> { abstract class $BookingSummaryCopyWith<$Res> {
factory $BookingSummaryCopyWith( factory $BookingSummaryCopyWith(
BookingSummary value, $Res Function(BookingSummary) then) = BookingSummary value,
_$BookingSummaryCopyWithImpl<$Res, BookingSummary>; $Res Function(BookingSummary) then,
) = _$BookingSummaryCopyWithImpl<$Res, BookingSummary>;
@useResult @useResult
$Res call({int id, String name, DateTime startDate, DateTime endDate}); $Res call({int id, String name, DateTime startDate, DateTime endDate});
} }
@ -71,33 +73,41 @@ class _$BookingSummaryCopyWithImpl<$Res, $Val extends BookingSummary>
Object? startDate = null, Object? startDate = null,
Object? endDate = null, Object? endDate = null,
}) { }) {
return _then(_value.copyWith( return _then(
id: null == id _value.copyWith(
id:
null == id
? _value.id ? _value.id
: id // ignore: cast_nullable_to_non_nullable : id // ignore: cast_nullable_to_non_nullable
as int, as int,
name: null == name name:
null == name
? _value.name ? _value.name
: name // ignore: cast_nullable_to_non_nullable : name // ignore: cast_nullable_to_non_nullable
as String, as String,
startDate: null == startDate startDate:
null == startDate
? _value.startDate ? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable : startDate // ignore: cast_nullable_to_non_nullable
as DateTime, as DateTime,
endDate: null == endDate endDate:
null == endDate
? _value.endDate ? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable : endDate // ignore: cast_nullable_to_non_nullable
as DateTime, as DateTime,
) as $Val); )
as $Val,
);
} }
} }
/// @nodoc /// @nodoc
abstract class _$$BookingSummaryImplCopyWith<$Res> abstract class _$$BookingSummaryImplCopyWith<$Res>
implements $BookingSummaryCopyWith<$Res> { implements $BookingSummaryCopyWith<$Res> {
factory _$$BookingSummaryImplCopyWith(_$BookingSummaryImpl value, factory _$$BookingSummaryImplCopyWith(
$Res Function(_$BookingSummaryImpl) then) = _$BookingSummaryImpl value,
__$$BookingSummaryImplCopyWithImpl<$Res>; $Res Function(_$BookingSummaryImpl) then,
) = __$$BookingSummaryImplCopyWithImpl<$Res>;
@override @override
@useResult @useResult
$Res call({int id, String name, DateTime startDate, DateTime endDate}); $Res call({int id, String name, DateTime startDate, DateTime endDate});
@ -108,8 +118,9 @@ class __$$BookingSummaryImplCopyWithImpl<$Res>
extends _$BookingSummaryCopyWithImpl<$Res, _$BookingSummaryImpl> extends _$BookingSummaryCopyWithImpl<$Res, _$BookingSummaryImpl>
implements _$$BookingSummaryImplCopyWith<$Res> { implements _$$BookingSummaryImplCopyWith<$Res> {
__$$BookingSummaryImplCopyWithImpl( __$$BookingSummaryImplCopyWithImpl(
_$BookingSummaryImpl _value, $Res Function(_$BookingSummaryImpl) _then) _$BookingSummaryImpl _value,
: super(_value, _then); $Res Function(_$BookingSummaryImpl) _then,
) : super(_value, _then);
/// Create a copy of BookingSummary /// Create a copy of BookingSummary
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@ -121,35 +132,42 @@ class __$$BookingSummaryImplCopyWithImpl<$Res>
Object? startDate = null, Object? startDate = null,
Object? endDate = null, Object? endDate = null,
}) { }) {
return _then(_$BookingSummaryImpl( return _then(
id: null == id _$BookingSummaryImpl(
id:
null == id
? _value.id ? _value.id
: id // ignore: cast_nullable_to_non_nullable : id // ignore: cast_nullable_to_non_nullable
as int, as int,
name: null == name name:
null == name
? _value.name ? _value.name
: name // ignore: cast_nullable_to_non_nullable : name // ignore: cast_nullable_to_non_nullable
as String, as String,
startDate: null == startDate startDate:
null == startDate
? _value.startDate ? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable : startDate // ignore: cast_nullable_to_non_nullable
as DateTime, as DateTime,
endDate: null == endDate endDate:
null == endDate
? _value.endDate ? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable : endDate // ignore: cast_nullable_to_non_nullable
as DateTime, as DateTime,
)); ),
);
} }
} }
/// @nodoc /// @nodoc
@JsonSerializable() @JsonSerializable()
class _$BookingSummaryImpl implements _BookingSummary { class _$BookingSummaryImpl implements _BookingSummary {
const _$BookingSummaryImpl( const _$BookingSummaryImpl({
{required this.id, required this.id,
required this.name, required this.name,
required this.startDate, required this.startDate,
required this.endDate}); required this.endDate,
});
factory _$BookingSummaryImpl.fromJson(Map<String, dynamic> json) => factory _$BookingSummaryImpl.fromJson(Map<String, dynamic> json) =>
_$$BookingSummaryImplFromJson(json); _$$BookingSummaryImplFromJson(json);
@ -198,22 +216,23 @@ class _$BookingSummaryImpl implements _BookingSummary {
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
_$$BookingSummaryImplCopyWith<_$BookingSummaryImpl> get copyWith => _$$BookingSummaryImplCopyWith<_$BookingSummaryImpl> get copyWith =>
__$$BookingSummaryImplCopyWithImpl<_$BookingSummaryImpl>( __$$BookingSummaryImplCopyWithImpl<_$BookingSummaryImpl>(
this, _$identity); this,
_$identity,
);
@override @override
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return _$$BookingSummaryImplToJson( return _$$BookingSummaryImplToJson(this);
this,
);
} }
} }
abstract class _BookingSummary implements BookingSummary { abstract class _BookingSummary implements BookingSummary {
const factory _BookingSummary( const factory _BookingSummary({
{required final int id, required final int id,
required final String name, required final String name,
required final DateTime startDate, required final DateTime startDate,
required final DateTime endDate}) = _$BookingSummaryImpl; required final DateTime endDate,
}) = _$BookingSummaryImpl;
factory _BookingSummary.fromJson(Map<String, dynamic> json) = factory _BookingSummary.fromJson(Map<String, dynamic> json) =
_$BookingSummaryImpl.fromJson; _$BookingSummaryImpl.fromJson;

@ -15,8 +15,8 @@ _$BookingSummaryImpl _$$BookingSummaryImplFromJson(Map<String, dynamic> json) =>
); );
Map<String, dynamic> _$$BookingSummaryImplToJson( Map<String, dynamic> _$$BookingSummaryImplToJson(
_$BookingSummaryImpl instance) => _$BookingSummaryImpl instance,
<String, dynamic>{ ) => <String, dynamic>{
'id': instance.id, 'id': instance.id,
'name': instance.name, 'name': instance.name,
'startDate': instance.startDate.toIso8601String(), 'startDate': instance.startDate.toIso8601String(),

@ -12,7 +12,8 @@ part of 'continent.dart';
T _$identity<T>(T value) => value; T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError( final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
);
Continent _$ContinentFromJson(Map<String, dynamic> json) { Continent _$ContinentFromJson(Map<String, dynamic> json) {
return _Continent.fromJson(json); return _Continent.fromJson(json);
@ -58,20 +59,22 @@ class _$ContinentCopyWithImpl<$Res, $Val extends Continent>
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({Object? name = null, Object? imageUrl = null}) {
Object? name = null, return _then(
Object? imageUrl = null, _value.copyWith(
}) { name:
return _then(_value.copyWith( null == name
name: null == name
? _value.name ? _value.name
: name // ignore: cast_nullable_to_non_nullable : name // ignore: cast_nullable_to_non_nullable
as String, as String,
imageUrl: null == imageUrl imageUrl:
null == imageUrl
? _value.imageUrl ? _value.imageUrl
: imageUrl // ignore: cast_nullable_to_non_nullable : imageUrl // ignore: cast_nullable_to_non_nullable
as String, as String,
) as $Val); )
as $Val,
);
} }
} }
@ -79,8 +82,9 @@ class _$ContinentCopyWithImpl<$Res, $Val extends Continent>
abstract class _$$ContinentImplCopyWith<$Res> abstract class _$$ContinentImplCopyWith<$Res>
implements $ContinentCopyWith<$Res> { implements $ContinentCopyWith<$Res> {
factory _$$ContinentImplCopyWith( factory _$$ContinentImplCopyWith(
_$ContinentImpl value, $Res Function(_$ContinentImpl) then) = _$ContinentImpl value,
__$$ContinentImplCopyWithImpl<$Res>; $Res Function(_$ContinentImpl) then,
) = __$$ContinentImplCopyWithImpl<$Res>;
@override @override
@useResult @useResult
$Res call({String name, String imageUrl}); $Res call({String name, String imageUrl});
@ -91,27 +95,29 @@ class __$$ContinentImplCopyWithImpl<$Res>
extends _$ContinentCopyWithImpl<$Res, _$ContinentImpl> extends _$ContinentCopyWithImpl<$Res, _$ContinentImpl>
implements _$$ContinentImplCopyWith<$Res> { implements _$$ContinentImplCopyWith<$Res> {
__$$ContinentImplCopyWithImpl( __$$ContinentImplCopyWithImpl(
_$ContinentImpl _value, $Res Function(_$ContinentImpl) _then) _$ContinentImpl _value,
: super(_value, _then); $Res Function(_$ContinentImpl) _then,
) : super(_value, _then);
/// Create a copy of Continent /// Create a copy of Continent
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({Object? name = null, Object? imageUrl = null}) {
Object? name = null, return _then(
Object? imageUrl = null, _$ContinentImpl(
}) { name:
return _then(_$ContinentImpl( null == name
name: null == name
? _value.name ? _value.name
: name // ignore: cast_nullable_to_non_nullable : name // ignore: cast_nullable_to_non_nullable
as String, as String,
imageUrl: null == imageUrl imageUrl:
null == imageUrl
? _value.imageUrl ? _value.imageUrl
: imageUrl // ignore: cast_nullable_to_non_nullable : imageUrl // ignore: cast_nullable_to_non_nullable
as String, as String,
)); ),
);
} }
} }
@ -160,16 +166,15 @@ class _$ContinentImpl implements _Continent {
@override @override
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return _$$ContinentImplToJson( return _$$ContinentImplToJson(this);
this,
);
} }
} }
abstract class _Continent implements Continent { abstract class _Continent implements Continent {
const factory _Continent( const factory _Continent({
{required final String name, required final String name,
required final String imageUrl}) = _$ContinentImpl; required final String imageUrl,
}) = _$ContinentImpl;
factory _Continent.fromJson(Map<String, dynamic> json) = factory _Continent.fromJson(Map<String, dynamic> json) =
_$ContinentImpl.fromJson; _$ContinentImpl.fromJson;

@ -13,7 +13,4 @@ _$ContinentImpl _$$ContinentImplFromJson(Map<String, dynamic> json) =>
); );
Map<String, dynamic> _$$ContinentImplToJson(_$ContinentImpl instance) => Map<String, dynamic> _$$ContinentImplToJson(_$ContinentImpl instance) =>
<String, dynamic>{ <String, dynamic>{'name': instance.name, 'imageUrl': instance.imageUrl};
'name': instance.name,
'imageUrl': instance.imageUrl,
};

@ -12,7 +12,8 @@ part of 'destination.dart';
T _$identity<T>(T value) => value; T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError( final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
);
Destination _$DestinationFromJson(Map<String, dynamic> json) { Destination _$DestinationFromJson(Map<String, dynamic> json) {
return _Destination.fromJson(json); return _Destination.fromJson(json);
@ -54,17 +55,19 @@ mixin _$Destination {
/// @nodoc /// @nodoc
abstract class $DestinationCopyWith<$Res> { abstract class $DestinationCopyWith<$Res> {
factory $DestinationCopyWith( factory $DestinationCopyWith(
Destination value, $Res Function(Destination) then) = Destination value,
_$DestinationCopyWithImpl<$Res, Destination>; $Res Function(Destination) then,
) = _$DestinationCopyWithImpl<$Res, Destination>;
@useResult @useResult
$Res call( $Res call({
{String ref, String ref,
String name, String name,
String country, String country,
String continent, String continent,
String knownFor, String knownFor,
List<String> tags, List<String> tags,
String imageUrl}); String imageUrl,
});
} }
/// @nodoc /// @nodoc
@ -90,36 +93,46 @@ class _$DestinationCopyWithImpl<$Res, $Val extends Destination>
Object? tags = null, Object? tags = null,
Object? imageUrl = null, Object? imageUrl = null,
}) { }) {
return _then(_value.copyWith( return _then(
ref: null == ref _value.copyWith(
ref:
null == ref
? _value.ref ? _value.ref
: ref // ignore: cast_nullable_to_non_nullable : ref // ignore: cast_nullable_to_non_nullable
as String, as String,
name: null == name name:
null == name
? _value.name ? _value.name
: name // ignore: cast_nullable_to_non_nullable : name // ignore: cast_nullable_to_non_nullable
as String, as String,
country: null == country country:
null == country
? _value.country ? _value.country
: country // ignore: cast_nullable_to_non_nullable : country // ignore: cast_nullable_to_non_nullable
as String, as String,
continent: null == continent continent:
null == continent
? _value.continent ? _value.continent
: continent // ignore: cast_nullable_to_non_nullable : continent // ignore: cast_nullable_to_non_nullable
as String, as String,
knownFor: null == knownFor knownFor:
null == knownFor
? _value.knownFor ? _value.knownFor
: knownFor // ignore: cast_nullable_to_non_nullable : knownFor // ignore: cast_nullable_to_non_nullable
as String, as String,
tags: null == tags tags:
null == tags
? _value.tags ? _value.tags
: tags // ignore: cast_nullable_to_non_nullable : tags // ignore: cast_nullable_to_non_nullable
as List<String>, as List<String>,
imageUrl: null == imageUrl imageUrl:
null == imageUrl
? _value.imageUrl ? _value.imageUrl
: imageUrl // ignore: cast_nullable_to_non_nullable : imageUrl // ignore: cast_nullable_to_non_nullable
as String, as String,
) as $Val); )
as $Val,
);
} }
} }
@ -127,18 +140,20 @@ class _$DestinationCopyWithImpl<$Res, $Val extends Destination>
abstract class _$$DestinationImplCopyWith<$Res> abstract class _$$DestinationImplCopyWith<$Res>
implements $DestinationCopyWith<$Res> { implements $DestinationCopyWith<$Res> {
factory _$$DestinationImplCopyWith( factory _$$DestinationImplCopyWith(
_$DestinationImpl value, $Res Function(_$DestinationImpl) then) = _$DestinationImpl value,
__$$DestinationImplCopyWithImpl<$Res>; $Res Function(_$DestinationImpl) then,
) = __$$DestinationImplCopyWithImpl<$Res>;
@override @override
@useResult @useResult
$Res call( $Res call({
{String ref, String ref,
String name, String name,
String country, String country,
String continent, String continent,
String knownFor, String knownFor,
List<String> tags, List<String> tags,
String imageUrl}); String imageUrl,
});
} }
/// @nodoc /// @nodoc
@ -146,8 +161,9 @@ class __$$DestinationImplCopyWithImpl<$Res>
extends _$DestinationCopyWithImpl<$Res, _$DestinationImpl> extends _$DestinationCopyWithImpl<$Res, _$DestinationImpl>
implements _$$DestinationImplCopyWith<$Res> { implements _$$DestinationImplCopyWith<$Res> {
__$$DestinationImplCopyWithImpl( __$$DestinationImplCopyWithImpl(
_$DestinationImpl _value, $Res Function(_$DestinationImpl) _then) _$DestinationImpl _value,
: super(_value, _then); $Res Function(_$DestinationImpl) _then,
) : super(_value, _then);
/// Create a copy of Destination /// Create a copy of Destination
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@ -162,51 +178,60 @@ class __$$DestinationImplCopyWithImpl<$Res>
Object? tags = null, Object? tags = null,
Object? imageUrl = null, Object? imageUrl = null,
}) { }) {
return _then(_$DestinationImpl( return _then(
ref: null == ref _$DestinationImpl(
ref:
null == ref
? _value.ref ? _value.ref
: ref // ignore: cast_nullable_to_non_nullable : ref // ignore: cast_nullable_to_non_nullable
as String, as String,
name: null == name name:
null == name
? _value.name ? _value.name
: name // ignore: cast_nullable_to_non_nullable : name // ignore: cast_nullable_to_non_nullable
as String, as String,
country: null == country country:
null == country
? _value.country ? _value.country
: country // ignore: cast_nullable_to_non_nullable : country // ignore: cast_nullable_to_non_nullable
as String, as String,
continent: null == continent continent:
null == continent
? _value.continent ? _value.continent
: continent // ignore: cast_nullable_to_non_nullable : continent // ignore: cast_nullable_to_non_nullable
as String, as String,
knownFor: null == knownFor knownFor:
null == knownFor
? _value.knownFor ? _value.knownFor
: knownFor // ignore: cast_nullable_to_non_nullable : knownFor // ignore: cast_nullable_to_non_nullable
as String, as String,
tags: null == tags tags:
null == tags
? _value._tags ? _value._tags
: tags // ignore: cast_nullable_to_non_nullable : tags // ignore: cast_nullable_to_non_nullable
as List<String>, as List<String>,
imageUrl: null == imageUrl imageUrl:
null == imageUrl
? _value.imageUrl ? _value.imageUrl
: imageUrl // ignore: cast_nullable_to_non_nullable : imageUrl // ignore: cast_nullable_to_non_nullable
as String, as String,
)); ),
);
} }
} }
/// @nodoc /// @nodoc
@JsonSerializable() @JsonSerializable()
class _$DestinationImpl implements _Destination { class _$DestinationImpl implements _Destination {
const _$DestinationImpl( const _$DestinationImpl({
{required this.ref, required this.ref,
required this.name, required this.name,
required this.country, required this.country,
required this.continent, required this.continent,
required this.knownFor, required this.knownFor,
required final List<String> tags, required final List<String> tags,
required this.imageUrl}) required this.imageUrl,
: _tags = tags; }) : _tags = tags;
factory _$DestinationImpl.fromJson(Map<String, dynamic> json) => factory _$DestinationImpl.fromJson(Map<String, dynamic> json) =>
_$$DestinationImplFromJson(json); _$$DestinationImplFromJson(json);
@ -270,8 +295,16 @@ class _$DestinationImpl implements _Destination {
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@override @override
int get hashCode => Object.hash(runtimeType, ref, name, country, continent, int get hashCode => Object.hash(
knownFor, const DeepCollectionEquality().hash(_tags), imageUrl); runtimeType,
ref,
name,
country,
continent,
knownFor,
const DeepCollectionEquality().hash(_tags),
imageUrl,
);
/// Create a copy of Destination /// Create a copy of Destination
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@ -283,21 +316,20 @@ class _$DestinationImpl implements _Destination {
@override @override
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return _$$DestinationImplToJson( return _$$DestinationImplToJson(this);
this,
);
} }
} }
abstract class _Destination implements Destination { abstract class _Destination implements Destination {
const factory _Destination( const factory _Destination({
{required final String ref, required final String ref,
required final String name, required final String name,
required final String country, required final String country,
required final String continent, required final String continent,
required final String knownFor, required final String knownFor,
required final List<String> tags, required final List<String> tags,
required final String imageUrl}) = _$DestinationImpl; required final String imageUrl,
}) = _$DestinationImpl;
factory _Destination.fromJson(Map<String, dynamic> json) = factory _Destination.fromJson(Map<String, dynamic> json) =
_$DestinationImpl.fromJson; _$DestinationImpl.fromJson;

@ -12,7 +12,8 @@ part of 'itinerary_config.dart';
T _$identity<T>(T value) => value; T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError( final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
);
ItineraryConfig _$ItineraryConfigFromJson(Map<String, dynamic> json) { ItineraryConfig _$ItineraryConfigFromJson(Map<String, dynamic> json) {
return _ItineraryConfig.fromJson(json); return _ItineraryConfig.fromJson(json);
@ -51,16 +52,18 @@ mixin _$ItineraryConfig {
/// @nodoc /// @nodoc
abstract class $ItineraryConfigCopyWith<$Res> { abstract class $ItineraryConfigCopyWith<$Res> {
factory $ItineraryConfigCopyWith( factory $ItineraryConfigCopyWith(
ItineraryConfig value, $Res Function(ItineraryConfig) then) = ItineraryConfig value,
_$ItineraryConfigCopyWithImpl<$Res, ItineraryConfig>; $Res Function(ItineraryConfig) then,
) = _$ItineraryConfigCopyWithImpl<$Res, ItineraryConfig>;
@useResult @useResult
$Res call( $Res call({
{String? continent, String? continent,
DateTime? startDate, DateTime? startDate,
DateTime? endDate, DateTime? endDate,
int? guests, int? guests,
String? destination, String? destination,
List<String> activities}); List<String> activities,
});
} }
/// @nodoc /// @nodoc
@ -85,50 +88,61 @@ class _$ItineraryConfigCopyWithImpl<$Res, $Val extends ItineraryConfig>
Object? destination = freezed, Object? destination = freezed,
Object? activities = null, Object? activities = null,
}) { }) {
return _then(_value.copyWith( return _then(
continent: freezed == continent _value.copyWith(
continent:
freezed == continent
? _value.continent ? _value.continent
: continent // ignore: cast_nullable_to_non_nullable : continent // ignore: cast_nullable_to_non_nullable
as String?, as String?,
startDate: freezed == startDate startDate:
freezed == startDate
? _value.startDate ? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable : startDate // ignore: cast_nullable_to_non_nullable
as DateTime?, as DateTime?,
endDate: freezed == endDate endDate:
freezed == endDate
? _value.endDate ? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable : endDate // ignore: cast_nullable_to_non_nullable
as DateTime?, as DateTime?,
guests: freezed == guests guests:
freezed == guests
? _value.guests ? _value.guests
: guests // ignore: cast_nullable_to_non_nullable : guests // ignore: cast_nullable_to_non_nullable
as int?, as int?,
destination: freezed == destination destination:
freezed == destination
? _value.destination ? _value.destination
: destination // ignore: cast_nullable_to_non_nullable : destination // ignore: cast_nullable_to_non_nullable
as String?, as String?,
activities: null == activities activities:
null == activities
? _value.activities ? _value.activities
: activities // ignore: cast_nullable_to_non_nullable : activities // ignore: cast_nullable_to_non_nullable
as List<String>, as List<String>,
) as $Val); )
as $Val,
);
} }
} }
/// @nodoc /// @nodoc
abstract class _$$ItineraryConfigImplCopyWith<$Res> abstract class _$$ItineraryConfigImplCopyWith<$Res>
implements $ItineraryConfigCopyWith<$Res> { implements $ItineraryConfigCopyWith<$Res> {
factory _$$ItineraryConfigImplCopyWith(_$ItineraryConfigImpl value, factory _$$ItineraryConfigImplCopyWith(
$Res Function(_$ItineraryConfigImpl) then) = _$ItineraryConfigImpl value,
__$$ItineraryConfigImplCopyWithImpl<$Res>; $Res Function(_$ItineraryConfigImpl) then,
) = __$$ItineraryConfigImplCopyWithImpl<$Res>;
@override @override
@useResult @useResult
$Res call( $Res call({
{String? continent, String? continent,
DateTime? startDate, DateTime? startDate,
DateTime? endDate, DateTime? endDate,
int? guests, int? guests,
String? destination, String? destination,
List<String> activities}); List<String> activities,
});
} }
/// @nodoc /// @nodoc
@ -136,8 +150,9 @@ class __$$ItineraryConfigImplCopyWithImpl<$Res>
extends _$ItineraryConfigCopyWithImpl<$Res, _$ItineraryConfigImpl> extends _$ItineraryConfigCopyWithImpl<$Res, _$ItineraryConfigImpl>
implements _$$ItineraryConfigImplCopyWith<$Res> { implements _$$ItineraryConfigImplCopyWith<$Res> {
__$$ItineraryConfigImplCopyWithImpl( __$$ItineraryConfigImplCopyWithImpl(
_$ItineraryConfigImpl _value, $Res Function(_$ItineraryConfigImpl) _then) _$ItineraryConfigImpl _value,
: super(_value, _then); $Res Function(_$ItineraryConfigImpl) _then,
) : super(_value, _then);
/// Create a copy of ItineraryConfig /// Create a copy of ItineraryConfig
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@ -151,46 +166,54 @@ class __$$ItineraryConfigImplCopyWithImpl<$Res>
Object? destination = freezed, Object? destination = freezed,
Object? activities = null, Object? activities = null,
}) { }) {
return _then(_$ItineraryConfigImpl( return _then(
continent: freezed == continent _$ItineraryConfigImpl(
continent:
freezed == continent
? _value.continent ? _value.continent
: continent // ignore: cast_nullable_to_non_nullable : continent // ignore: cast_nullable_to_non_nullable
as String?, as String?,
startDate: freezed == startDate startDate:
freezed == startDate
? _value.startDate ? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable : startDate // ignore: cast_nullable_to_non_nullable
as DateTime?, as DateTime?,
endDate: freezed == endDate endDate:
freezed == endDate
? _value.endDate ? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable : endDate // ignore: cast_nullable_to_non_nullable
as DateTime?, as DateTime?,
guests: freezed == guests guests:
freezed == guests
? _value.guests ? _value.guests
: guests // ignore: cast_nullable_to_non_nullable : guests // ignore: cast_nullable_to_non_nullable
as int?, as int?,
destination: freezed == destination destination:
freezed == destination
? _value.destination ? _value.destination
: destination // ignore: cast_nullable_to_non_nullable : destination // ignore: cast_nullable_to_non_nullable
as String?, as String?,
activities: null == activities activities:
null == activities
? _value._activities ? _value._activities
: activities // ignore: cast_nullable_to_non_nullable : activities // ignore: cast_nullable_to_non_nullable
as List<String>, as List<String>,
)); ),
);
} }
} }
/// @nodoc /// @nodoc
@JsonSerializable() @JsonSerializable()
class _$ItineraryConfigImpl implements _ItineraryConfig { class _$ItineraryConfigImpl implements _ItineraryConfig {
const _$ItineraryConfigImpl( const _$ItineraryConfigImpl({
{this.continent, this.continent,
this.startDate, this.startDate,
this.endDate, this.endDate,
this.guests, this.guests,
this.destination, this.destination,
final List<String> activities = const []}) final List<String> activities = const [],
: _activities = activities; }) : _activities = activities;
factory _$ItineraryConfigImpl.fromJson(Map<String, dynamic> json) => factory _$ItineraryConfigImpl.fromJson(Map<String, dynamic> json) =>
_$$ItineraryConfigImplFromJson(json); _$$ItineraryConfigImplFromJson(json);
@ -245,14 +268,23 @@ class _$ItineraryConfigImpl implements _ItineraryConfig {
(identical(other.guests, guests) || other.guests == guests) && (identical(other.guests, guests) || other.guests == guests) &&
(identical(other.destination, destination) || (identical(other.destination, destination) ||
other.destination == destination) && other.destination == destination) &&
const DeepCollectionEquality() const DeepCollectionEquality().equals(
.equals(other._activities, _activities)); other._activities,
_activities,
));
} }
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@override @override
int get hashCode => Object.hash(runtimeType, continent, startDate, endDate, int get hashCode => Object.hash(
guests, destination, const DeepCollectionEquality().hash(_activities)); runtimeType,
continent,
startDate,
endDate,
guests,
destination,
const DeepCollectionEquality().hash(_activities),
);
/// Create a copy of ItineraryConfig /// Create a copy of ItineraryConfig
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@ -261,24 +293,25 @@ class _$ItineraryConfigImpl implements _ItineraryConfig {
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
_$$ItineraryConfigImplCopyWith<_$ItineraryConfigImpl> get copyWith => _$$ItineraryConfigImplCopyWith<_$ItineraryConfigImpl> get copyWith =>
__$$ItineraryConfigImplCopyWithImpl<_$ItineraryConfigImpl>( __$$ItineraryConfigImplCopyWithImpl<_$ItineraryConfigImpl>(
this, _$identity); this,
_$identity,
);
@override @override
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return _$$ItineraryConfigImplToJson( return _$$ItineraryConfigImplToJson(this);
this,
);
} }
} }
abstract class _ItineraryConfig implements ItineraryConfig { abstract class _ItineraryConfig implements ItineraryConfig {
const factory _ItineraryConfig( const factory _ItineraryConfig({
{final String? continent, final String? continent,
final DateTime? startDate, final DateTime? startDate,
final DateTime? endDate, final DateTime? endDate,
final int? guests, final int? guests,
final String? destination, final String? destination,
final List<String> activities}) = _$ItineraryConfigImpl; final List<String> activities,
}) = _$ItineraryConfigImpl;
factory _ItineraryConfig.fromJson(Map<String, dynamic> json) = factory _ItineraryConfig.fromJson(Map<String, dynamic> json) =
_$ItineraryConfigImpl.fromJson; _$ItineraryConfigImpl.fromJson;

@ -7,26 +7,29 @@ part of 'itinerary_config.dart';
// ************************************************************************** // **************************************************************************
_$ItineraryConfigImpl _$$ItineraryConfigImplFromJson( _$ItineraryConfigImpl _$$ItineraryConfigImplFromJson(
Map<String, dynamic> json) => Map<String, dynamic> json,
_$ItineraryConfigImpl( ) => _$ItineraryConfigImpl(
continent: json['continent'] as String?, continent: json['continent'] as String?,
startDate: json['startDate'] == null startDate:
json['startDate'] == null
? null ? null
: DateTime.parse(json['startDate'] as String), : DateTime.parse(json['startDate'] as String),
endDate: json['endDate'] == null endDate:
json['endDate'] == null
? null ? null
: DateTime.parse(json['endDate'] as String), : DateTime.parse(json['endDate'] as String),
guests: (json['guests'] as num?)?.toInt(), guests: (json['guests'] as num?)?.toInt(),
destination: json['destination'] as String?, destination: json['destination'] as String?,
activities: (json['activities'] as List<dynamic>?) activities:
(json['activities'] as List<dynamic>?)
?.map((e) => e as String) ?.map((e) => e as String)
.toList() ?? .toList() ??
const [], const [],
); );
Map<String, dynamic> _$$ItineraryConfigImplToJson( Map<String, dynamic> _$$ItineraryConfigImplToJson(
_$ItineraryConfigImpl instance) => _$ItineraryConfigImpl instance,
<String, dynamic>{ ) => <String, dynamic>{
'continent': instance.continent, 'continent': instance.continent,
'startDate': instance.startDate?.toIso8601String(), 'startDate': instance.startDate?.toIso8601String(),
'endDate': instance.endDate?.toIso8601String(), 'endDate': instance.endDate?.toIso8601String(),

@ -12,7 +12,8 @@ part of 'user.dart';
T _$identity<T>(T value) => value; T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError( final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
);
User _$UserFromJson(Map<String, dynamic> json) { User _$UserFromJson(Map<String, dynamic> json) {
return _User.fromJson(json); return _User.fromJson(json);
@ -57,28 +58,31 @@ class _$UserCopyWithImpl<$Res, $Val extends User>
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({Object? name = null, Object? picture = null}) {
Object? name = null, return _then(
Object? picture = null, _value.copyWith(
}) { name:
return _then(_value.copyWith( null == name
name: null == name
? _value.name ? _value.name
: name // ignore: cast_nullable_to_non_nullable : name // ignore: cast_nullable_to_non_nullable
as String, as String,
picture: null == picture picture:
null == picture
? _value.picture ? _value.picture
: picture // ignore: cast_nullable_to_non_nullable : picture // ignore: cast_nullable_to_non_nullable
as String, as String,
) as $Val); )
as $Val,
);
} }
} }
/// @nodoc /// @nodoc
abstract class _$$UserImplCopyWith<$Res> implements $UserCopyWith<$Res> { abstract class _$$UserImplCopyWith<$Res> implements $UserCopyWith<$Res> {
factory _$$UserImplCopyWith( factory _$$UserImplCopyWith(
_$UserImpl value, $Res Function(_$UserImpl) then) = _$UserImpl value,
__$$UserImplCopyWithImpl<$Res>; $Res Function(_$UserImpl) then,
) = __$$UserImplCopyWithImpl<$Res>;
@override @override
@useResult @useResult
$Res call({String name, String picture}); $Res call({String name, String picture});
@ -95,20 +99,21 @@ class __$$UserImplCopyWithImpl<$Res>
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@override @override
$Res call({ $Res call({Object? name = null, Object? picture = null}) {
Object? name = null, return _then(
Object? picture = null, _$UserImpl(
}) { name:
return _then(_$UserImpl( null == name
name: null == name
? _value.name ? _value.name
: name // ignore: cast_nullable_to_non_nullable : name // ignore: cast_nullable_to_non_nullable
as String, as String,
picture: null == picture picture:
null == picture
? _value.picture ? _value.picture
: picture // ignore: cast_nullable_to_non_nullable : picture // ignore: cast_nullable_to_non_nullable
as String, as String,
)); ),
);
} }
} }
@ -156,15 +161,15 @@ class _$UserImpl implements _User {
@override @override
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return _$$UserImplToJson( return _$$UserImplToJson(this);
this,
);
} }
} }
abstract class _User implements User { abstract class _User implements User {
const factory _User( const factory _User({
{required final String name, required final String picture}) = _$UserImpl; required final String name,
required final String picture,
}) = _$UserImpl;
factory _User.fromJson(Map<String, dynamic> json) = _$UserImpl.fromJson; factory _User.fromJson(Map<String, dynamic> json) = _$UserImpl.fromJson;

@ -12,7 +12,4 @@ _$UserImpl _$$UserImplFromJson(Map<String, dynamic> json) => _$UserImpl(
); );
Map<String, dynamic> _$$UserImplToJson(_$UserImpl instance) => Map<String, dynamic> _$$UserImplToJson(_$UserImpl instance) =>
<String, dynamic>{ <String, dynamic>{'name': instance.name, 'picture': instance.picture};
'name': instance.name,
'picture': instance.picture,
};

@ -38,8 +38,9 @@ class BookingCreateUseCase {
_log.warning('Destination is not set'); _log.warning('Destination is not set');
return Result.error(Exception('Destination is not set')); return Result.error(Exception('Destination is not set'));
} }
final destinationResult = final destinationResult = await _fetchDestination(
await _fetchDestination(itineraryConfig.destination!); itineraryConfig.destination!,
);
switch (destinationResult) { switch (destinationResult) {
case Ok<Destination>(): case Ok<Destination>():
_log.fine('Destination loaded: ${destinationResult.value.ref}'); _log.fine('Destination loaded: ${destinationResult.value.ref}');
@ -62,7 +63,8 @@ class BookingCreateUseCase {
return Result.error(activitiesResult.error); return Result.error(activitiesResult.error);
case Ok<List<Activity>>(): case Ok<List<Activity>>():
} }
final activities = activitiesResult.value final activities =
activitiesResult.value
.where( .where(
(activity) => itineraryConfig.activities.contains(activity.ref), (activity) => itineraryConfig.activities.contains(activity.ref),
) )
@ -100,8 +102,9 @@ class BookingCreateUseCase {
final result = await _destinationRepository.getDestinations(); final result = await _destinationRepository.getDestinations();
switch (result) { switch (result) {
case Ok<List<Destination>>(): case Ok<List<Destination>>():
final destination = result.value final destination = result.value.firstWhere(
.firstWhere((destination) => destination.ref == destinationRef); (destination) => destination.ref == destinationRef,
);
return Result.ok(destination); return Result.ok(destination);
case Error<List<Destination>>(): case Error<List<Destination>>():
return Result.error(result.error); return Result.error(result.error);

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save