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() {
_random ??= Random(cellNumber);
return Color.fromARGB(255, _random!.nextInt(50) + 205,
_random!.nextInt(50) + 205, _random!.nextInt(50) + 205);
return Color.fromARGB(
255,
_random!.nextInt(50) + 205,
_random!.nextInt(50) + 205,
_random!.nextInt(50) + 205,
);
}
@override
@ -108,7 +112,8 @@ class _CellState extends State<Cell> with WidgetsBindingObserver {
child: StreamBuilder<AccelerometerEvent>(
// Don't continuously rebuild for nothing when the
// cell isn't visible.
stream: appLifecycleState == AppLifecycleState.resumed
stream:
appLifecycleState == AppLifecycleState.resumed
? accelerometerEventStream()
: Stream.value(defaultPosition),
initialData: defaultPosition,
@ -117,11 +122,15 @@ class _CellState extends State<Cell> with WidgetsBindingObserver {
// Figure out the phone's orientation relative
// to gravity's direction. Ignore the z vector.
transform: Matrix4.rotationX(
snapshot.data!.y / gravity * pi / 2)
..multiply(Matrix4.rotationY(
snapshot.data!.x / gravity * pi / 2)),
snapshot.data!.y / gravity * pi / 2,
)..multiply(
Matrix4.rotationY(
snapshot.data!.x / gravity * pi / 2,
),
),
alignment: Alignment.center,
child: const FlutterLogo(size: 72));
child: const FlutterLogo(size: 72),
);
},
),
),

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

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

@ -13,9 +13,7 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
primaryColor: const Color(0xff6200ee),
),
theme: ThemeData(primaryColor: const Color(0xff6200ee)),
home: const BookDetail(),
);
}
@ -70,7 +68,8 @@ class _BookDetailState extends State<BookDetail> {
// calls from the platform.
// TODO(gaaclarke): make the setup method an instance method so it's
// 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
// method to the handler class.
(book) {
@ -93,7 +92,9 @@ class _BookDetailState extends State<BookDetail> {
this.book!.author = authorTextController.text;
});
});
}));
},
),
);
}
// Not overriding didUpdateWidget because the Android program can't change
@ -124,7 +125,8 @@ class _BookDetailState extends State<BookDetail> {
IconButton(
icon: const Icon(Icons.check),
// Pressing save sends the updated book to the platform.
onPressed: book != null
onPressed:
book != null
? () {
hostApi.finishEditingBook(book!);
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
// for.
? const Center(child: CircularProgressIndicator())
@ -207,15 +210,14 @@ class BookForm extends StatelessWidget {
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'${book.pageCount} pages ~ published ${book.publishDate}'),
'${book.pageCount} pages ~ published ${book.publishDate}',
),
),
),
const Divider(),
const SizedBox(height: 32),
if (book.thumbnail?.url != null) ...[
Center(
child: Image.network(book.thumbnail!.url!),
),
Center(child: Image.network(book.thumbnail!.url!)),
const SizedBox(height: 32),
],
if (book.summary != null) ...[
@ -234,7 +236,7 @@ class BookForm extends StatelessWidget {
book.summary ?? '',
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
environment:
sdk: ^3.5.0
sdk: ^3.7.0-0
dependencies:
flutter:

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

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

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

@ -72,24 +72,17 @@ class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
appBar: AppBar(title: Text(widget.title)),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
'You have pushed the button this many times:',
),
const Text('You have pushed the button this many times:'),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
TextButton(
onPressed: _incrementCounter,
child: const Text('Add'),
),
TextButton(onPressed: _incrementCounter, child: const Text('Add')),
TextButton(
onPressed: () {
_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
environment:
sdk: ^3.5.0
sdk: ^3.7.0-0
dependencies:
flutter:

@ -62,8 +62,12 @@ class _CellState extends State<Cell> with WidgetsBindingObserver {
Color randomLightColor() {
_random ??= Random(cellNumber);
return Color.fromARGB(255, _random!.nextInt(50) + 205,
_random!.nextInt(50) + 205, _random!.nextInt(50) + 205);
return Color.fromARGB(
255,
_random!.nextInt(50) + 205,
_random!.nextInt(50) + 205,
_random!.nextInt(50) + 205,
);
}
@override
@ -108,7 +112,8 @@ class _CellState extends State<Cell> with WidgetsBindingObserver {
child: StreamBuilder<AccelerometerEvent>(
// Don't continuously rebuild for nothing when the
// cell isn't visible.
stream: appLifecycleState == AppLifecycleState.resumed
stream:
appLifecycleState == AppLifecycleState.resumed
? accelerometerEventStream()
: Stream.value(defaultPosition),
initialData: defaultPosition,
@ -123,7 +128,8 @@ class _CellState extends State<Cell> with WidgetsBindingObserver {
transform: Matrix4.rotationX(
data.y / gravity * pi / 2,
)..multiply(
Matrix4.rotationY(data.x / gravity * pi / 2)),
Matrix4.rotationY(data.x / gravity * pi / 2),
),
alignment: Alignment.center,
child: const FlutterLogo(size: 72),
);

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

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

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

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

@ -3,7 +3,7 @@ description: Analysis defaults for flutter/samples
publish_to: none
environment:
sdk: ^3.5.0
sdk: ^3.7.0-0
# NOTE: Code is not allowed in this package. Do not add more dependencies.
# The `flutter_lints` dependency is required for `lib/flutter.yaml`.

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

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

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

@ -24,8 +24,10 @@ class _AnimatedBuilderDemoState extends State<AnimatedBuilderDemo>
void initState() {
super.initState();
controller = AnimationController(vsync: this, duration: duration);
animation =
ColorTween(begin: beginColor, end: endColor).animate(controller);
animation = ColorTween(
begin: beginColor,
end: endColor,
).animate(controller);
}
@override
@ -37,9 +39,7 @@ class _AnimatedBuilderDemoState extends State<AnimatedBuilderDemo>
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('AnimatedBuilder'),
),
appBar: AppBar(title: const Text('AnimatedBuilder')),
body: Center(
// 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
@ -49,9 +49,7 @@ class _AnimatedBuilderDemoState extends State<AnimatedBuilderDemo>
animation: animation,
builder: (context, child) {
return ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: animation.value,
),
style: ElevatedButton.styleFrom(backgroundColor: animation.value),
child: child,
onPressed: () {
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
// and shrinking cards.
return Scaffold(
appBar: AppBar(
title: const Text('AnimatedContainer'),
),
appBar: AppBar(title: const Text('AnimatedContainer')),
body: Center(
child: Column(
children: [
@ -71,9 +69,7 @@ class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
),
),
ElevatedButton(
child: const Text(
'change',
),
child: const Text('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
// has completed.
return Scaffold(
appBar: AppBar(
title: const Text('Animation Controller'),
),
appBar: AppBar(title: const Text('Animation Controller')),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
@ -79,7 +77,7 @@ class _AnimationControllerDemoState extends State<AnimationControllerDemo>
controller.forward();
}
},
)
),
],
),
),

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

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

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

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

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

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

@ -20,7 +20,7 @@ Widget generateContainer(int keyCount) => Container(
width: Random().nextDouble() * 5,
),
),
);
);
class AnimatedSwitcherDemo extends StatefulWidget {
const AnimatedSwitcherDemo({super.key});
@ -48,9 +48,8 @@ class _AnimatedSwitcherDemoState extends State<AnimatedSwitcherDemo> {
title: const Text('AnimatedSwitcher'),
actions: [
TextButton(
onPressed: () => setState(
() => container = generateContainer(++keyCount),
),
onPressed:
() => setState(() => container = generateContainer(++keyCount)),
child: const Text('Change Widget'),
),
],
@ -62,10 +61,9 @@ class _AnimatedSwitcherDemoState extends State<AnimatedSwitcherDemo> {
child: AnimatedSwitcher(
duration: const Duration(seconds: 1),
child: container,
transitionBuilder: (child, animation) => ScaleTransition(
scale: animation,
child: child,
),
transitionBuilder:
(child, animation) =>
ScaleTransition(scale: animation, child: child),
),
),
);

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

@ -21,9 +21,7 @@ class CarouselDemo extends StatelessWidget {
@override
Widget build(context) {
return Scaffold(
appBar: AppBar(
title: const Text('Carousel Demo'),
),
appBar: AppBar(title: const Text('Carousel Demo')),
body: Center(
child: Padding(
padding: const EdgeInsets.all(16),
@ -79,15 +77,14 @@ class _CarouselState extends State<Carousel> {
},
controller: _controller,
scrollBehavior: ScrollConfiguration.of(context).copyWith(
dragDevices: {
ui.PointerDeviceKind.touch,
ui.PointerDeviceKind.mouse,
},
dragDevices: {ui.PointerDeviceKind.touch, ui.PointerDeviceKind.mouse},
),
itemBuilder: (context, index) => AnimatedBuilder(
itemBuilder:
(context, index) => AnimatedBuilder(
animation: _controller,
builder: (context, child) {
var result = _pageHasChanged ? _controller.page! : _currentPage * 1.0;
var result =
_pageHasChanged ? _controller.page! : _currentPage * 1.0;
// The horizontal position of the page between a 1 and 0
var value = result - index;

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

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

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

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

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

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

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

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

@ -6,9 +6,8 @@ import 'package:animations/src/basics/basics.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
Widget createAnimatedBuilderDemoScreen() => const MaterialApp(
home: AnimatedBuilderDemo(),
);
Widget createAnimatedBuilderDemoScreen() =>
const MaterialApp(home: AnimatedBuilderDemo());
void main() {
group('AnimatedBuilder Tests', () {

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

@ -6,9 +6,8 @@ import 'package:animations/src/misc/animated_positioned.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
Widget createAnimatedPositionedDemoScreen() => const MaterialApp(
home: AnimatedPositionedDemo(),
);
Widget createAnimatedPositionedDemoScreen() =>
const MaterialApp(home: AnimatedPositionedDemo());
void main() {
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_test/flutter_test.dart';
Widget createCardSwipeScreen() => const MaterialApp(
home: CardSwipeDemo(),
);
Widget createCardSwipeScreen() => const MaterialApp(home: CardSwipeDemo());
void main() {
group('Card Swipe Tests', () {

@ -6,9 +6,7 @@ import 'package:animations/src/misc/carousel.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
Widget createCarouselDemoScreen() => MaterialApp(
home: CarouselDemo(),
);
Widget createCarouselDemoScreen() => MaterialApp(home: CarouselDemo());
void main() {
group('CarouselDemo tests', () {

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

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

@ -11,7 +11,8 @@ int main(List<String> arguments) {
// the `--input` option and one for the `--output` option.
// `--input` is the original asset file that this program should transform.
// `--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(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)
// and fail the build. Anything written to stderr by the asset transformer
// will be surfaced by flutter.
stderr.writeln('Unexpected exception when producing grayscale image.\n'
'Details: $e');
stderr.writeln(
'Unexpected exception when producing grayscale image.\n'
'Details: $e',
);
return 1;
}
}

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

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

@ -29,9 +29,7 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
title: 'Background Isolate Channels',
theme: ThemeData(
primarySwatch: Colors.blue,
),
theme: ThemeData(primarySwatch: Colors.blue),
home: const MyHomePage(title: 'Background Isolate Channels'),
);
}
@ -69,7 +67,8 @@ class _MyHomePageState extends State<MyHomePage> {
// just for demonstration purposes.
final Future<void> sharedPreferencesSet = SharedPreferences.getInstance()
.then(
(sharedPreferences) => sharedPreferences.setBool('isDebug', true));
(sharedPreferences) => sharedPreferences.setBool('isDebug', true),
);
final Future<Directory> tempDirFuture =
path_provider.getTemporaryDirectory();
@ -113,8 +112,9 @@ class _MyHomePageState extends State<MyHomePage> {
/// Adds a UUID and a timestamp to the [SimpleDatabase].
void _addDate() {
final DateTime now = DateTime.now();
final DateFormat formatter =
DateFormat('EEEE MMMM d, HH:mm:ss\n${const uuid.Uuid().v4()}');
final DateFormat formatter = DateFormat(
'EEEE MMMM d, HH:mm:ss\n${const uuid.Uuid().v4()}',
);
final String formatted = formatter.format(now);
_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
/// [_SimpleDatabaseServer].
enum _Codes {
init,
add,
query,
ack,
result,
done,
}
enum _Codes { init, add, query, ack, result, done }
/// A command sent between [SimpleDatabase] and [_SimpleDatabaseServer].
class _Command {
@ -85,8 +78,10 @@ class SimpleDatabase {
/// Open the database at [path] and launch the server on a background isolate..
static Future<SimpleDatabase> open(String path) async {
final ReceivePort receivePort = ReceivePort();
final Isolate isolate =
await Isolate.spawn(_SimpleDatabaseServer._run, receivePort.sendPort);
final Isolate isolate = await Isolate.spawn(
_SimpleDatabaseServer._run,
receivePort.sendPort,
);
final SimpleDatabase result = SimpleDatabase._(isolate, path);
Completer<void> completer = Completer<void>();
result._completers.addFirst(completer);
@ -130,8 +125,9 @@ class SimpleDatabase {
// invoke [BackgroundIsolateBinaryMessenger.ensureInitialized].
// ----------------------------------------------------------------------
RootIsolateToken rootIsolateToken = RootIsolateToken.instance!;
_sendPort
.send(_Command(_Codes.init, arg0: _path, arg1: rootIsolateToken));
_sendPort.send(
_Command(_Codes.init, arg0: _path, arg1: rootIsolateToken),
);
case _Codes.ack:
_completers.removeLast().complete();
case _Codes.result:
@ -200,7 +196,8 @@ class _SimpleDatabaseServer {
_doFind(command.arg0 as String);
default:
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
environment:
sdk: ^3.5.0
sdk: ^3.7.0-0
dependencies:
cupertino_icons: ^1.0.2

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

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

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

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

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

@ -12,7 +12,8 @@ part of 'models.dart';
T _$identity<T>(T value) => value;
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) {
return _Increment.fromJson(json);
@ -48,15 +49,17 @@ class _$IncrementCopyWithImpl<$Res, $Val extends Increment>
@pragma('vm:prefer-inline')
@override
$Res call({
Object? by = null,
}) {
return _then(_value.copyWith(
by: null == by
$Res call({Object? by = null}) {
return _then(
_value.copyWith(
by:
null == by
? _value.by
: by // ignore: cast_nullable_to_non_nullable
as int,
) as $Val);
)
as $Val,
);
}
}
@ -64,8 +67,9 @@ class _$IncrementCopyWithImpl<$Res, $Val extends Increment>
abstract class _$$IncrementImplCopyWith<$Res>
implements $IncrementCopyWith<$Res> {
factory _$$IncrementImplCopyWith(
_$IncrementImpl value, $Res Function(_$IncrementImpl) then) =
__$$IncrementImplCopyWithImpl<$Res>;
_$IncrementImpl value,
$Res Function(_$IncrementImpl) then,
) = __$$IncrementImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({int by});
@ -76,20 +80,22 @@ class __$$IncrementImplCopyWithImpl<$Res>
extends _$IncrementCopyWithImpl<$Res, _$IncrementImpl>
implements _$$IncrementImplCopyWith<$Res> {
__$$IncrementImplCopyWithImpl(
_$IncrementImpl _value, $Res Function(_$IncrementImpl) _then)
: super(_value, _then);
_$IncrementImpl _value,
$Res Function(_$IncrementImpl) _then,
) : super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? by = null,
}) {
return _then(_$IncrementImpl(
by: null == by
$Res call({Object? by = null}) {
return _then(
_$IncrementImpl(
by:
null == by
? _value.by
: by // ignore: cast_nullable_to_non_nullable
as int,
));
),
);
}
}
@ -129,9 +135,7 @@ class _$IncrementImpl implements _Increment {
@override
Map<String, dynamic> toJson() {
return _$$IncrementImplToJson(
this,
);
return _$$IncrementImplToJson(this);
}
}
@ -182,23 +186,26 @@ class _$CountCopyWithImpl<$Res, $Val extends Count>
@pragma('vm:prefer-inline')
@override
$Res call({
Object? value = null,
}) {
return _then(_value.copyWith(
value: null == value
$Res call({Object? value = null}) {
return _then(
_value.copyWith(
value:
null == value
? _value.value
: value // ignore: cast_nullable_to_non_nullable
as int,
) as $Val);
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$CountImplCopyWith<$Res> implements $CountCopyWith<$Res> {
factory _$$CountImplCopyWith(
_$CountImpl value, $Res Function(_$CountImpl) then) =
__$$CountImplCopyWithImpl<$Res>;
_$CountImpl value,
$Res Function(_$CountImpl) then,
) = __$$CountImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({int value});
@ -209,20 +216,21 @@ class __$$CountImplCopyWithImpl<$Res>
extends _$CountCopyWithImpl<$Res, _$CountImpl>
implements _$$CountImplCopyWith<$Res> {
__$$CountImplCopyWithImpl(
_$CountImpl _value, $Res Function(_$CountImpl) _then)
: super(_value, _then);
_$CountImpl _value,
$Res Function(_$CountImpl) _then,
) : super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? value = null,
}) {
return _then(_$CountImpl(
$Res call({Object? value = null}) {
return _then(
_$CountImpl(
null == value
? _value.value
: value // ignore: cast_nullable_to_non_nullable
as int,
));
),
);
}
}
@ -262,9 +270,7 @@ class _$CountImpl implements _Count {
@override
Map<String, dynamic> toJson() {
return _$$CountImplToJson(
this,
);
return _$$CountImplToJson(this);
}
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -12,7 +12,8 @@ part of 'booking_api_model.dart';
T _$identity<T>(T value) => value;
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) {
return _BookingApiModel.fromJson(json);
@ -52,16 +53,18 @@ mixin _$BookingApiModel {
/// @nodoc
abstract class $BookingApiModelCopyWith<$Res> {
factory $BookingApiModelCopyWith(
BookingApiModel value, $Res Function(BookingApiModel) then) =
_$BookingApiModelCopyWithImpl<$Res, BookingApiModel>;
BookingApiModel value,
$Res Function(BookingApiModel) then,
) = _$BookingApiModelCopyWithImpl<$Res, BookingApiModel>;
@useResult
$Res call(
{int? id,
$Res call({
int? id,
DateTime startDate,
DateTime endDate,
String name,
String destinationRef,
List<String> activitiesRef});
List<String> activitiesRef,
});
}
/// @nodoc
@ -86,50 +89,61 @@ class _$BookingApiModelCopyWithImpl<$Res, $Val extends BookingApiModel>
Object? destinationRef = null,
Object? activitiesRef = null,
}) {
return _then(_value.copyWith(
id: freezed == id
return _then(
_value.copyWith(
id:
freezed == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int?,
startDate: null == startDate
startDate:
null == startDate
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime,
endDate: null == endDate
endDate:
null == endDate
? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable
as DateTime,
name: null == name
name:
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
destinationRef: null == destinationRef
destinationRef:
null == destinationRef
? _value.destinationRef
: destinationRef // ignore: cast_nullable_to_non_nullable
as String,
activitiesRef: null == activitiesRef
activitiesRef:
null == activitiesRef
? _value.activitiesRef
: activitiesRef // ignore: cast_nullable_to_non_nullable
as List<String>,
) as $Val);
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$BookingApiModelImplCopyWith<$Res>
implements $BookingApiModelCopyWith<$Res> {
factory _$$BookingApiModelImplCopyWith(_$BookingApiModelImpl value,
$Res Function(_$BookingApiModelImpl) then) =
__$$BookingApiModelImplCopyWithImpl<$Res>;
factory _$$BookingApiModelImplCopyWith(
_$BookingApiModelImpl value,
$Res Function(_$BookingApiModelImpl) then,
) = __$$BookingApiModelImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{int? id,
$Res call({
int? id,
DateTime startDate,
DateTime endDate,
String name,
String destinationRef,
List<String> activitiesRef});
List<String> activitiesRef,
});
}
/// @nodoc
@ -137,8 +151,9 @@ class __$$BookingApiModelImplCopyWithImpl<$Res>
extends _$BookingApiModelCopyWithImpl<$Res, _$BookingApiModelImpl>
implements _$$BookingApiModelImplCopyWith<$Res> {
__$$BookingApiModelImplCopyWithImpl(
_$BookingApiModelImpl _value, $Res Function(_$BookingApiModelImpl) _then)
: super(_value, _then);
_$BookingApiModelImpl _value,
$Res Function(_$BookingApiModelImpl) _then,
) : super(_value, _then);
/// Create a copy of BookingApiModel
/// with the given fields replaced by the non-null parameter values.
@ -152,46 +167,54 @@ class __$$BookingApiModelImplCopyWithImpl<$Res>
Object? destinationRef = null,
Object? activitiesRef = null,
}) {
return _then(_$BookingApiModelImpl(
id: freezed == id
return _then(
_$BookingApiModelImpl(
id:
freezed == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int?,
startDate: null == startDate
startDate:
null == startDate
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime,
endDate: null == endDate
endDate:
null == endDate
? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable
as DateTime,
name: null == name
name:
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
destinationRef: null == destinationRef
destinationRef:
null == destinationRef
? _value.destinationRef
: destinationRef // ignore: cast_nullable_to_non_nullable
as String,
activitiesRef: null == activitiesRef
activitiesRef:
null == activitiesRef
? _value._activitiesRef
: activitiesRef // ignore: cast_nullable_to_non_nullable
as List<String>,
));
),
);
}
}
/// @nodoc
@JsonSerializable()
class _$BookingApiModelImpl implements _BookingApiModel {
const _$BookingApiModelImpl(
{this.id,
const _$BookingApiModelImpl({
this.id,
required this.startDate,
required this.endDate,
required this.name,
required this.destinationRef,
required final List<String> activitiesRef})
: _activitiesRef = activitiesRef;
required final List<String> activitiesRef,
}) : _activitiesRef = activitiesRef;
factory _$BookingApiModelImpl.fromJson(Map<String, dynamic> json) =>
_$$BookingApiModelImplFromJson(json);
@ -245,14 +268,23 @@ class _$BookingApiModelImpl implements _BookingApiModel {
(identical(other.name, name) || other.name == name) &&
(identical(other.destinationRef, destinationRef) ||
other.destinationRef == destinationRef) &&
const DeepCollectionEquality()
.equals(other._activitiesRef, _activitiesRef));
const DeepCollectionEquality().equals(
other._activitiesRef,
_activitiesRef,
));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, id, startDate, endDate, name,
destinationRef, const DeepCollectionEquality().hash(_activitiesRef));
int get hashCode => Object.hash(
runtimeType,
id,
startDate,
endDate,
name,
destinationRef,
const DeepCollectionEquality().hash(_activitiesRef),
);
/// Create a copy of BookingApiModel
/// with the given fields replaced by the non-null parameter values.
@ -261,24 +293,25 @@ class _$BookingApiModelImpl implements _BookingApiModel {
@pragma('vm:prefer-inline')
_$$BookingApiModelImplCopyWith<_$BookingApiModelImpl> get copyWith =>
__$$BookingApiModelImplCopyWithImpl<_$BookingApiModelImpl>(
this, _$identity);
this,
_$identity,
);
@override
Map<String, dynamic> toJson() {
return _$$BookingApiModelImplToJson(
this,
);
return _$$BookingApiModelImplToJson(this);
}
}
abstract class _BookingApiModel implements BookingApiModel {
const factory _BookingApiModel(
{final int? id,
const factory _BookingApiModel({
final int? id,
required final DateTime startDate,
required final DateTime endDate,
required final String name,
required final String destinationRef,
required final List<String> activitiesRef}) = _$BookingApiModelImpl;
required final List<String> activitiesRef,
}) = _$BookingApiModelImpl;
factory _BookingApiModel.fromJson(Map<String, dynamic> json) =
_$BookingApiModelImpl.fromJson;

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

@ -12,7 +12,8 @@ part of 'login_request.dart';
T _$identity<T>(T value) => value;
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) {
return _LoginRequest.fromJson(json);
@ -39,8 +40,9 @@ mixin _$LoginRequest {
/// @nodoc
abstract class $LoginRequestCopyWith<$Res> {
factory $LoginRequestCopyWith(
LoginRequest value, $Res Function(LoginRequest) then) =
_$LoginRequestCopyWithImpl<$Res, LoginRequest>;
LoginRequest value,
$Res Function(LoginRequest) then,
) = _$LoginRequestCopyWithImpl<$Res, LoginRequest>;
@useResult
$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.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? email = null,
Object? password = null,
}) {
return _then(_value.copyWith(
email: null == email
$Res call({Object? email = null, Object? password = null}) {
return _then(
_value.copyWith(
email:
null == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String,
password: null == password
password:
null == password
? _value.password
: password // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
)
as $Val,
);
}
}
@ -80,8 +84,9 @@ class _$LoginRequestCopyWithImpl<$Res, $Val extends LoginRequest>
abstract class _$$LoginRequestImplCopyWith<$Res>
implements $LoginRequestCopyWith<$Res> {
factory _$$LoginRequestImplCopyWith(
_$LoginRequestImpl value, $Res Function(_$LoginRequestImpl) then) =
__$$LoginRequestImplCopyWithImpl<$Res>;
_$LoginRequestImpl value,
$Res Function(_$LoginRequestImpl) then,
) = __$$LoginRequestImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String email, String password});
@ -92,27 +97,29 @@ class __$$LoginRequestImplCopyWithImpl<$Res>
extends _$LoginRequestCopyWithImpl<$Res, _$LoginRequestImpl>
implements _$$LoginRequestImplCopyWith<$Res> {
__$$LoginRequestImplCopyWithImpl(
_$LoginRequestImpl _value, $Res Function(_$LoginRequestImpl) _then)
: super(_value, _then);
_$LoginRequestImpl _value,
$Res Function(_$LoginRequestImpl) _then,
) : super(_value, _then);
/// Create a copy of LoginRequest
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? email = null,
Object? password = null,
}) {
return _then(_$LoginRequestImpl(
email: null == email
$Res call({Object? email = null, Object? password = null}) {
return _then(
_$LoginRequestImpl(
email:
null == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String,
password: null == password
password:
null == password
? _value.password
: password // ignore: cast_nullable_to_non_nullable
as String,
));
),
);
}
}
@ -161,16 +168,15 @@ class _$LoginRequestImpl implements _LoginRequest {
@override
Map<String, dynamic> toJson() {
return _$$LoginRequestImplToJson(
this,
);
return _$$LoginRequestImplToJson(this);
}
}
abstract class _LoginRequest implements LoginRequest {
const factory _LoginRequest(
{required final String email,
required final String password}) = _$LoginRequestImpl;
const factory _LoginRequest({
required final String email,
required final String password,
}) = _$LoginRequestImpl;
factory _LoginRequest.fromJson(Map<String, dynamic> json) =
_$LoginRequestImpl.fromJson;

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

@ -12,7 +12,8 @@ part of 'login_response.dart';
T _$identity<T>(T value) => value;
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) {
return _LoginResponse.fromJson(json);
@ -39,8 +40,9 @@ mixin _$LoginResponse {
/// @nodoc
abstract class $LoginResponseCopyWith<$Res> {
factory $LoginResponseCopyWith(
LoginResponse value, $Res Function(LoginResponse) then) =
_$LoginResponseCopyWithImpl<$Res, LoginResponse>;
LoginResponse value,
$Res Function(LoginResponse) then,
) = _$LoginResponseCopyWithImpl<$Res, LoginResponse>;
@useResult
$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.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? token = null,
Object? userId = null,
}) {
return _then(_value.copyWith(
token: null == token
$Res call({Object? token = null, Object? userId = null}) {
return _then(
_value.copyWith(
token:
null == token
? _value.token
: token // ignore: cast_nullable_to_non_nullable
as String,
userId: null == userId
userId:
null == userId
? _value.userId
: userId // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
)
as $Val,
);
}
}
@ -80,8 +84,9 @@ class _$LoginResponseCopyWithImpl<$Res, $Val extends LoginResponse>
abstract class _$$LoginResponseImplCopyWith<$Res>
implements $LoginResponseCopyWith<$Res> {
factory _$$LoginResponseImplCopyWith(
_$LoginResponseImpl value, $Res Function(_$LoginResponseImpl) then) =
__$$LoginResponseImplCopyWithImpl<$Res>;
_$LoginResponseImpl value,
$Res Function(_$LoginResponseImpl) then,
) = __$$LoginResponseImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String token, String userId});
@ -92,27 +97,29 @@ class __$$LoginResponseImplCopyWithImpl<$Res>
extends _$LoginResponseCopyWithImpl<$Res, _$LoginResponseImpl>
implements _$$LoginResponseImplCopyWith<$Res> {
__$$LoginResponseImplCopyWithImpl(
_$LoginResponseImpl _value, $Res Function(_$LoginResponseImpl) _then)
: super(_value, _then);
_$LoginResponseImpl _value,
$Res Function(_$LoginResponseImpl) _then,
) : super(_value, _then);
/// Create a copy of LoginResponse
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? token = null,
Object? userId = null,
}) {
return _then(_$LoginResponseImpl(
token: null == token
$Res call({Object? token = null, Object? userId = null}) {
return _then(
_$LoginResponseImpl(
token:
null == token
? _value.token
: token // ignore: cast_nullable_to_non_nullable
as String,
userId: null == userId
userId:
null == userId
? _value.userId
: userId // ignore: cast_nullable_to_non_nullable
as String,
));
),
);
}
}
@ -160,16 +167,15 @@ class _$LoginResponseImpl implements _LoginResponse {
@override
Map<String, dynamic> toJson() {
return _$$LoginResponseImplToJson(
this,
);
return _$$LoginResponseImplToJson(this);
}
}
abstract class _LoginResponse implements LoginResponse {
const factory _LoginResponse(
{required final String token,
required final String userId}) = _$LoginResponseImpl;
const factory _LoginResponse({
required final String token,
required final String userId,
}) = _$LoginResponseImpl;
factory _LoginResponse.fromJson(Map<String, dynamic> json) =
_$LoginResponseImpl.fromJson;

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

@ -12,7 +12,8 @@ part of 'user_api_model.dart';
T _$identity<T>(T value) => value;
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) {
return _UserApiModel.fromJson(json);
@ -45,8 +46,9 @@ mixin _$UserApiModel {
/// @nodoc
abstract class $UserApiModelCopyWith<$Res> {
factory $UserApiModelCopyWith(
UserApiModel value, $Res Function(UserApiModel) then) =
_$UserApiModelCopyWithImpl<$Res, UserApiModel>;
UserApiModel value,
$Res Function(UserApiModel) then,
) = _$UserApiModelCopyWithImpl<$Res, UserApiModel>;
@useResult
$Res call({String id, String name, String email, String picture});
}
@ -71,24 +73,31 @@ class _$UserApiModelCopyWithImpl<$Res, $Val extends UserApiModel>
Object? email = null,
Object? picture = null,
}) {
return _then(_value.copyWith(
id: null == id
return _then(
_value.copyWith(
id:
null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
name:
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
email: null == email
email:
null == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String,
picture: null == picture
picture:
null == picture
? _value.picture
: picture // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
)
as $Val,
);
}
}
@ -96,8 +105,9 @@ class _$UserApiModelCopyWithImpl<$Res, $Val extends UserApiModel>
abstract class _$$UserApiModelImplCopyWith<$Res>
implements $UserApiModelCopyWith<$Res> {
factory _$$UserApiModelImplCopyWith(
_$UserApiModelImpl value, $Res Function(_$UserApiModelImpl) then) =
__$$UserApiModelImplCopyWithImpl<$Res>;
_$UserApiModelImpl value,
$Res Function(_$UserApiModelImpl) then,
) = __$$UserApiModelImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String id, String name, String email, String picture});
@ -108,8 +118,9 @@ class __$$UserApiModelImplCopyWithImpl<$Res>
extends _$UserApiModelCopyWithImpl<$Res, _$UserApiModelImpl>
implements _$$UserApiModelImplCopyWith<$Res> {
__$$UserApiModelImplCopyWithImpl(
_$UserApiModelImpl _value, $Res Function(_$UserApiModelImpl) _then)
: super(_value, _then);
_$UserApiModelImpl _value,
$Res Function(_$UserApiModelImpl) _then,
) : super(_value, _then);
/// Create a copy of UserApiModel
/// with the given fields replaced by the non-null parameter values.
@ -121,35 +132,42 @@ class __$$UserApiModelImplCopyWithImpl<$Res>
Object? email = null,
Object? picture = null,
}) {
return _then(_$UserApiModelImpl(
id: null == id
return _then(
_$UserApiModelImpl(
id:
null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
name:
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
email: null == email
email:
null == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String,
picture: null == picture
picture:
null == picture
? _value.picture
: picture // ignore: cast_nullable_to_non_nullable
as String,
));
),
);
}
}
/// @nodoc
@JsonSerializable()
class _$UserApiModelImpl implements _UserApiModel {
const _$UserApiModelImpl(
{required this.id,
const _$UserApiModelImpl({
required this.id,
required this.name,
required this.email,
required this.picture});
required this.picture,
});
factory _$UserApiModelImpl.fromJson(Map<String, dynamic> json) =>
_$$UserApiModelImplFromJson(json);
@ -200,18 +218,17 @@ class _$UserApiModelImpl implements _UserApiModel {
@override
Map<String, dynamic> toJson() {
return _$$UserApiModelImplToJson(
this,
);
return _$$UserApiModelImplToJson(this);
}
}
abstract class _UserApiModel implements UserApiModel {
const factory _UserApiModel(
{required final String id,
const factory _UserApiModel({
required final String id,
required final String name,
required final String email,
required final String picture}) = _$UserApiModelImpl;
required final String picture,
}) = _$UserApiModelImpl;
factory _UserApiModel.fromJson(Map<String, dynamic> json) =
_$UserApiModelImpl.fromJson;

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

@ -12,7 +12,8 @@ part of 'activity.dart';
T _$identity<T>(T value) => value;
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) {
return _Activity.fromJson(json);
@ -66,8 +67,8 @@ abstract class $ActivityCopyWith<$Res> {
factory $ActivityCopyWith(Activity value, $Res Function(Activity) then) =
_$ActivityCopyWithImpl<$Res, Activity>;
@useResult
$Res call(
{String name,
$Res call({
String name,
String description,
String locationName,
int duration,
@ -76,7 +77,8 @@ abstract class $ActivityCopyWith<$Res> {
int price,
String destinationRef,
String ref,
String imageUrl});
String imageUrl,
});
}
/// @nodoc
@ -105,48 +107,61 @@ class _$ActivityCopyWithImpl<$Res, $Val extends Activity>
Object? ref = null,
Object? imageUrl = null,
}) {
return _then(_value.copyWith(
name: null == name
return _then(
_value.copyWith(
name:
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
description: null == description
description:
null == description
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String,
locationName: null == locationName
locationName:
null == locationName
? _value.locationName
: locationName // ignore: cast_nullable_to_non_nullable
as String,
duration: null == duration
duration:
null == duration
? _value.duration
: duration // ignore: cast_nullable_to_non_nullable
as int,
timeOfDay: null == timeOfDay
timeOfDay:
null == timeOfDay
? _value.timeOfDay
: timeOfDay // ignore: cast_nullable_to_non_nullable
as TimeOfDay,
familyFriendly: null == familyFriendly
familyFriendly:
null == familyFriendly
? _value.familyFriendly
: familyFriendly // ignore: cast_nullable_to_non_nullable
as bool,
price: null == price
price:
null == price
? _value.price
: price // ignore: cast_nullable_to_non_nullable
as int,
destinationRef: null == destinationRef
destinationRef:
null == destinationRef
? _value.destinationRef
: destinationRef // ignore: cast_nullable_to_non_nullable
as String,
ref: null == ref
ref:
null == ref
? _value.ref
: ref // ignore: cast_nullable_to_non_nullable
as String,
imageUrl: null == imageUrl
imageUrl:
null == imageUrl
? _value.imageUrl
: imageUrl // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
)
as $Val,
);
}
}
@ -154,12 +169,13 @@ class _$ActivityCopyWithImpl<$Res, $Val extends Activity>
abstract class _$$ActivityImplCopyWith<$Res>
implements $ActivityCopyWith<$Res> {
factory _$$ActivityImplCopyWith(
_$ActivityImpl value, $Res Function(_$ActivityImpl) then) =
__$$ActivityImplCopyWithImpl<$Res>;
_$ActivityImpl value,
$Res Function(_$ActivityImpl) then,
) = __$$ActivityImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{String name,
$Res call({
String name,
String description,
String locationName,
int duration,
@ -168,7 +184,8 @@ abstract class _$$ActivityImplCopyWith<$Res>
int price,
String destinationRef,
String ref,
String imageUrl});
String imageUrl,
});
}
/// @nodoc
@ -176,8 +193,9 @@ class __$$ActivityImplCopyWithImpl<$Res>
extends _$ActivityCopyWithImpl<$Res, _$ActivityImpl>
implements _$$ActivityImplCopyWith<$Res> {
__$$ActivityImplCopyWithImpl(
_$ActivityImpl _value, $Res Function(_$ActivityImpl) _then)
: super(_value, _then);
_$ActivityImpl _value,
$Res Function(_$ActivityImpl) _then,
) : super(_value, _then);
/// Create a copy of Activity
/// with the given fields replaced by the non-null parameter values.
@ -195,56 +213,68 @@ class __$$ActivityImplCopyWithImpl<$Res>
Object? ref = null,
Object? imageUrl = null,
}) {
return _then(_$ActivityImpl(
name: null == name
return _then(
_$ActivityImpl(
name:
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
description: null == description
description:
null == description
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String,
locationName: null == locationName
locationName:
null == locationName
? _value.locationName
: locationName // ignore: cast_nullable_to_non_nullable
as String,
duration: null == duration
duration:
null == duration
? _value.duration
: duration // ignore: cast_nullable_to_non_nullable
as int,
timeOfDay: null == timeOfDay
timeOfDay:
null == timeOfDay
? _value.timeOfDay
: timeOfDay // ignore: cast_nullable_to_non_nullable
as TimeOfDay,
familyFriendly: null == familyFriendly
familyFriendly:
null == familyFriendly
? _value.familyFriendly
: familyFriendly // ignore: cast_nullable_to_non_nullable
as bool,
price: null == price
price:
null == price
? _value.price
: price // ignore: cast_nullable_to_non_nullable
as int,
destinationRef: null == destinationRef
destinationRef:
null == destinationRef
? _value.destinationRef
: destinationRef // ignore: cast_nullable_to_non_nullable
as String,
ref: null == ref
ref:
null == ref
? _value.ref
: ref // ignore: cast_nullable_to_non_nullable
as String,
imageUrl: null == imageUrl
imageUrl:
null == imageUrl
? _value.imageUrl
: imageUrl // ignore: cast_nullable_to_non_nullable
as String,
));
),
);
}
}
/// @nodoc
@JsonSerializable()
class _$ActivityImpl implements _Activity {
const _$ActivityImpl(
{required this.name,
const _$ActivityImpl({
required this.name,
required this.description,
required this.locationName,
required this.duration,
@ -253,7 +283,8 @@ class _$ActivityImpl implements _Activity {
required this.price,
required this.destinationRef,
required this.ref,
required this.imageUrl});
required this.imageUrl,
});
factory _$ActivityImpl.fromJson(Map<String, dynamic> json) =>
_$$ActivityImplFromJson(json);
@ -341,7 +372,8 @@ class _$ActivityImpl implements _Activity {
price,
destinationRef,
ref,
imageUrl);
imageUrl,
);
/// Create a copy of Activity
/// with the given fields replaced by the non-null parameter values.
@ -353,15 +385,13 @@ class _$ActivityImpl implements _Activity {
@override
Map<String, dynamic> toJson() {
return _$$ActivityImplToJson(
this,
);
return _$$ActivityImplToJson(this);
}
}
abstract class _Activity implements Activity {
const factory _Activity(
{required final String name,
const factory _Activity({
required final String name,
required final String description,
required final String locationName,
required final int duration,
@ -370,7 +400,8 @@ abstract class _Activity implements Activity {
required final int price,
required final String destinationRef,
required final String ref,
required final String imageUrl}) = _$ActivityImpl;
required final String imageUrl,
}) = _$ActivityImpl;
factory _Activity.fromJson(Map<String, dynamic> json) =
_$ActivityImpl.fromJson;

@ -12,7 +12,8 @@ part of 'booking.dart';
T _$identity<T>(T value) => value;
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) {
return _Booking.fromJson(json);
@ -50,12 +51,13 @@ abstract class $BookingCopyWith<$Res> {
factory $BookingCopyWith(Booking value, $Res Function(Booking) then) =
_$BookingCopyWithImpl<$Res, Booking>;
@useResult
$Res call(
{int? id,
$Res call({
int? id,
DateTime startDate,
DateTime endDate,
Destination destination,
List<Activity> activity});
List<Activity> activity,
});
$DestinationCopyWith<$Res> get destination;
}
@ -81,28 +83,36 @@ class _$BookingCopyWithImpl<$Res, $Val extends Booking>
Object? destination = null,
Object? activity = null,
}) {
return _then(_value.copyWith(
id: freezed == id
return _then(
_value.copyWith(
id:
freezed == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int?,
startDate: null == startDate
startDate:
null == startDate
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime,
endDate: null == endDate
endDate:
null == endDate
? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable
as DateTime,
destination: null == destination
destination:
null == destination
? _value.destination
: destination // ignore: cast_nullable_to_non_nullable
as Destination,
activity: null == activity
activity:
null == activity
? _value.activity
: activity // ignore: cast_nullable_to_non_nullable
as List<Activity>,
) as $Val);
)
as $Val,
);
}
/// Create a copy of Booking
@ -119,16 +129,18 @@ class _$BookingCopyWithImpl<$Res, $Val extends Booking>
/// @nodoc
abstract class _$$BookingImplCopyWith<$Res> implements $BookingCopyWith<$Res> {
factory _$$BookingImplCopyWith(
_$BookingImpl value, $Res Function(_$BookingImpl) then) =
__$$BookingImplCopyWithImpl<$Res>;
_$BookingImpl value,
$Res Function(_$BookingImpl) then,
) = __$$BookingImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{int? id,
$Res call({
int? id,
DateTime startDate,
DateTime endDate,
Destination destination,
List<Activity> activity});
List<Activity> activity,
});
@override
$DestinationCopyWith<$Res> get destination;
@ -139,8 +151,9 @@ class __$$BookingImplCopyWithImpl<$Res>
extends _$BookingCopyWithImpl<$Res, _$BookingImpl>
implements _$$BookingImplCopyWith<$Res> {
__$$BookingImplCopyWithImpl(
_$BookingImpl _value, $Res Function(_$BookingImpl) _then)
: super(_value, _then);
_$BookingImpl _value,
$Res Function(_$BookingImpl) _then,
) : super(_value, _then);
/// Create a copy of Booking
/// with the given fields replaced by the non-null parameter values.
@ -153,41 +166,48 @@ class __$$BookingImplCopyWithImpl<$Res>
Object? destination = null,
Object? activity = null,
}) {
return _then(_$BookingImpl(
id: freezed == id
return _then(
_$BookingImpl(
id:
freezed == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int?,
startDate: null == startDate
startDate:
null == startDate
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime,
endDate: null == endDate
endDate:
null == endDate
? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable
as DateTime,
destination: null == destination
destination:
null == destination
? _value.destination
: destination // ignore: cast_nullable_to_non_nullable
as Destination,
activity: null == activity
activity:
null == activity
? _value._activity
: activity // ignore: cast_nullable_to_non_nullable
as List<Activity>,
));
),
);
}
}
/// @nodoc
@JsonSerializable()
class _$BookingImpl implements _Booking {
const _$BookingImpl(
{this.id,
const _$BookingImpl({
this.id,
required this.startDate,
required this.endDate,
required this.destination,
required final List<Activity> activity})
: _activity = activity;
required final List<Activity> activity,
}) : _activity = activity;
factory _$BookingImpl.fromJson(Map<String, dynamic> json) =>
_$$BookingImplFromJson(json);
@ -241,8 +261,14 @@ class _$BookingImpl implements _Booking {
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, id, startDate, endDate,
destination, const DeepCollectionEquality().hash(_activity));
int get hashCode => Object.hash(
runtimeType,
id,
startDate,
endDate,
destination,
const DeepCollectionEquality().hash(_activity),
);
/// Create a copy of Booking
/// with the given fields replaced by the non-null parameter values.
@ -254,19 +280,18 @@ class _$BookingImpl implements _Booking {
@override
Map<String, dynamic> toJson() {
return _$$BookingImplToJson(
this,
);
return _$$BookingImplToJson(this);
}
}
abstract class _Booking implements Booking {
const factory _Booking(
{final int? id,
const factory _Booking({
final int? id,
required final DateTime startDate,
required final DateTime endDate,
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;

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

@ -12,7 +12,8 @@ part of 'booking_summary.dart';
T _$identity<T>(T value) => value;
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) {
return _BookingSummary.fromJson(json);
@ -45,8 +46,9 @@ mixin _$BookingSummary {
/// @nodoc
abstract class $BookingSummaryCopyWith<$Res> {
factory $BookingSummaryCopyWith(
BookingSummary value, $Res Function(BookingSummary) then) =
_$BookingSummaryCopyWithImpl<$Res, BookingSummary>;
BookingSummary value,
$Res Function(BookingSummary) then,
) = _$BookingSummaryCopyWithImpl<$Res, BookingSummary>;
@useResult
$Res call({int id, String name, DateTime startDate, DateTime endDate});
}
@ -71,33 +73,41 @@ class _$BookingSummaryCopyWithImpl<$Res, $Val extends BookingSummary>
Object? startDate = null,
Object? endDate = null,
}) {
return _then(_value.copyWith(
id: null == id
return _then(
_value.copyWith(
id:
null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
name: null == name
name:
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
startDate: null == startDate
startDate:
null == startDate
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime,
endDate: null == endDate
endDate:
null == endDate
? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable
as DateTime,
) as $Val);
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$BookingSummaryImplCopyWith<$Res>
implements $BookingSummaryCopyWith<$Res> {
factory _$$BookingSummaryImplCopyWith(_$BookingSummaryImpl value,
$Res Function(_$BookingSummaryImpl) then) =
__$$BookingSummaryImplCopyWithImpl<$Res>;
factory _$$BookingSummaryImplCopyWith(
_$BookingSummaryImpl value,
$Res Function(_$BookingSummaryImpl) then,
) = __$$BookingSummaryImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({int id, String name, DateTime startDate, DateTime endDate});
@ -108,8 +118,9 @@ class __$$BookingSummaryImplCopyWithImpl<$Res>
extends _$BookingSummaryCopyWithImpl<$Res, _$BookingSummaryImpl>
implements _$$BookingSummaryImplCopyWith<$Res> {
__$$BookingSummaryImplCopyWithImpl(
_$BookingSummaryImpl _value, $Res Function(_$BookingSummaryImpl) _then)
: super(_value, _then);
_$BookingSummaryImpl _value,
$Res Function(_$BookingSummaryImpl) _then,
) : super(_value, _then);
/// Create a copy of BookingSummary
/// with the given fields replaced by the non-null parameter values.
@ -121,35 +132,42 @@ class __$$BookingSummaryImplCopyWithImpl<$Res>
Object? startDate = null,
Object? endDate = null,
}) {
return _then(_$BookingSummaryImpl(
id: null == id
return _then(
_$BookingSummaryImpl(
id:
null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
name: null == name
name:
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
startDate: null == startDate
startDate:
null == startDate
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime,
endDate: null == endDate
endDate:
null == endDate
? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable
as DateTime,
));
),
);
}
}
/// @nodoc
@JsonSerializable()
class _$BookingSummaryImpl implements _BookingSummary {
const _$BookingSummaryImpl(
{required this.id,
const _$BookingSummaryImpl({
required this.id,
required this.name,
required this.startDate,
required this.endDate});
required this.endDate,
});
factory _$BookingSummaryImpl.fromJson(Map<String, dynamic> json) =>
_$$BookingSummaryImplFromJson(json);
@ -198,22 +216,23 @@ class _$BookingSummaryImpl implements _BookingSummary {
@pragma('vm:prefer-inline')
_$$BookingSummaryImplCopyWith<_$BookingSummaryImpl> get copyWith =>
__$$BookingSummaryImplCopyWithImpl<_$BookingSummaryImpl>(
this, _$identity);
this,
_$identity,
);
@override
Map<String, dynamic> toJson() {
return _$$BookingSummaryImplToJson(
this,
);
return _$$BookingSummaryImplToJson(this);
}
}
abstract class _BookingSummary implements BookingSummary {
const factory _BookingSummary(
{required final int id,
const factory _BookingSummary({
required final int id,
required final String name,
required final DateTime startDate,
required final DateTime endDate}) = _$BookingSummaryImpl;
required final DateTime endDate,
}) = _$BookingSummaryImpl;
factory _BookingSummary.fromJson(Map<String, dynamic> json) =
_$BookingSummaryImpl.fromJson;

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

@ -12,7 +12,8 @@ part of 'continent.dart';
T _$identity<T>(T value) => value;
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) {
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.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
Object? imageUrl = null,
}) {
return _then(_value.copyWith(
name: null == name
$Res call({Object? name = null, Object? imageUrl = null}) {
return _then(
_value.copyWith(
name:
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
imageUrl: null == imageUrl
imageUrl:
null == imageUrl
? _value.imageUrl
: imageUrl // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
)
as $Val,
);
}
}
@ -79,8 +82,9 @@ class _$ContinentCopyWithImpl<$Res, $Val extends Continent>
abstract class _$$ContinentImplCopyWith<$Res>
implements $ContinentCopyWith<$Res> {
factory _$$ContinentImplCopyWith(
_$ContinentImpl value, $Res Function(_$ContinentImpl) then) =
__$$ContinentImplCopyWithImpl<$Res>;
_$ContinentImpl value,
$Res Function(_$ContinentImpl) then,
) = __$$ContinentImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String name, String imageUrl});
@ -91,27 +95,29 @@ class __$$ContinentImplCopyWithImpl<$Res>
extends _$ContinentCopyWithImpl<$Res, _$ContinentImpl>
implements _$$ContinentImplCopyWith<$Res> {
__$$ContinentImplCopyWithImpl(
_$ContinentImpl _value, $Res Function(_$ContinentImpl) _then)
: super(_value, _then);
_$ContinentImpl _value,
$Res Function(_$ContinentImpl) _then,
) : super(_value, _then);
/// Create a copy of Continent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
Object? imageUrl = null,
}) {
return _then(_$ContinentImpl(
name: null == name
$Res call({Object? name = null, Object? imageUrl = null}) {
return _then(
_$ContinentImpl(
name:
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
imageUrl: null == imageUrl
imageUrl:
null == imageUrl
? _value.imageUrl
: imageUrl // ignore: cast_nullable_to_non_nullable
as String,
));
),
);
}
}
@ -160,16 +166,15 @@ class _$ContinentImpl implements _Continent {
@override
Map<String, dynamic> toJson() {
return _$$ContinentImplToJson(
this,
);
return _$$ContinentImplToJson(this);
}
}
abstract class _Continent implements Continent {
const factory _Continent(
{required final String name,
required final String imageUrl}) = _$ContinentImpl;
const factory _Continent({
required final String name,
required final String imageUrl,
}) = _$ContinentImpl;
factory _Continent.fromJson(Map<String, dynamic> json) =
_$ContinentImpl.fromJson;

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

@ -12,7 +12,8 @@ part of 'destination.dart';
T _$identity<T>(T value) => value;
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) {
return _Destination.fromJson(json);
@ -54,17 +55,19 @@ mixin _$Destination {
/// @nodoc
abstract class $DestinationCopyWith<$Res> {
factory $DestinationCopyWith(
Destination value, $Res Function(Destination) then) =
_$DestinationCopyWithImpl<$Res, Destination>;
Destination value,
$Res Function(Destination) then,
) = _$DestinationCopyWithImpl<$Res, Destination>;
@useResult
$Res call(
{String ref,
$Res call({
String ref,
String name,
String country,
String continent,
String knownFor,
List<String> tags,
String imageUrl});
String imageUrl,
});
}
/// @nodoc
@ -90,36 +93,46 @@ class _$DestinationCopyWithImpl<$Res, $Val extends Destination>
Object? tags = null,
Object? imageUrl = null,
}) {
return _then(_value.copyWith(
ref: null == ref
return _then(
_value.copyWith(
ref:
null == ref
? _value.ref
: ref // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
name:
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
country: null == country
country:
null == country
? _value.country
: country // ignore: cast_nullable_to_non_nullable
as String,
continent: null == continent
continent:
null == continent
? _value.continent
: continent // ignore: cast_nullable_to_non_nullable
as String,
knownFor: null == knownFor
knownFor:
null == knownFor
? _value.knownFor
: knownFor // ignore: cast_nullable_to_non_nullable
as String,
tags: null == tags
tags:
null == tags
? _value.tags
: tags // ignore: cast_nullable_to_non_nullable
as List<String>,
imageUrl: null == imageUrl
imageUrl:
null == imageUrl
? _value.imageUrl
: imageUrl // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
)
as $Val,
);
}
}
@ -127,18 +140,20 @@ class _$DestinationCopyWithImpl<$Res, $Val extends Destination>
abstract class _$$DestinationImplCopyWith<$Res>
implements $DestinationCopyWith<$Res> {
factory _$$DestinationImplCopyWith(
_$DestinationImpl value, $Res Function(_$DestinationImpl) then) =
__$$DestinationImplCopyWithImpl<$Res>;
_$DestinationImpl value,
$Res Function(_$DestinationImpl) then,
) = __$$DestinationImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{String ref,
$Res call({
String ref,
String name,
String country,
String continent,
String knownFor,
List<String> tags,
String imageUrl});
String imageUrl,
});
}
/// @nodoc
@ -146,8 +161,9 @@ class __$$DestinationImplCopyWithImpl<$Res>
extends _$DestinationCopyWithImpl<$Res, _$DestinationImpl>
implements _$$DestinationImplCopyWith<$Res> {
__$$DestinationImplCopyWithImpl(
_$DestinationImpl _value, $Res Function(_$DestinationImpl) _then)
: super(_value, _then);
_$DestinationImpl _value,
$Res Function(_$DestinationImpl) _then,
) : super(_value, _then);
/// Create a copy of Destination
/// with the given fields replaced by the non-null parameter values.
@ -162,51 +178,60 @@ class __$$DestinationImplCopyWithImpl<$Res>
Object? tags = null,
Object? imageUrl = null,
}) {
return _then(_$DestinationImpl(
ref: null == ref
return _then(
_$DestinationImpl(
ref:
null == ref
? _value.ref
: ref // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
name:
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
country: null == country
country:
null == country
? _value.country
: country // ignore: cast_nullable_to_non_nullable
as String,
continent: null == continent
continent:
null == continent
? _value.continent
: continent // ignore: cast_nullable_to_non_nullable
as String,
knownFor: null == knownFor
knownFor:
null == knownFor
? _value.knownFor
: knownFor // ignore: cast_nullable_to_non_nullable
as String,
tags: null == tags
tags:
null == tags
? _value._tags
: tags // ignore: cast_nullable_to_non_nullable
as List<String>,
imageUrl: null == imageUrl
imageUrl:
null == imageUrl
? _value.imageUrl
: imageUrl // ignore: cast_nullable_to_non_nullable
as String,
));
),
);
}
}
/// @nodoc
@JsonSerializable()
class _$DestinationImpl implements _Destination {
const _$DestinationImpl(
{required this.ref,
const _$DestinationImpl({
required this.ref,
required this.name,
required this.country,
required this.continent,
required this.knownFor,
required final List<String> tags,
required this.imageUrl})
: _tags = tags;
required this.imageUrl,
}) : _tags = tags;
factory _$DestinationImpl.fromJson(Map<String, dynamic> json) =>
_$$DestinationImplFromJson(json);
@ -270,8 +295,16 @@ class _$DestinationImpl implements _Destination {
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, ref, name, country, continent,
knownFor, const DeepCollectionEquality().hash(_tags), imageUrl);
int get hashCode => Object.hash(
runtimeType,
ref,
name,
country,
continent,
knownFor,
const DeepCollectionEquality().hash(_tags),
imageUrl,
);
/// Create a copy of Destination
/// with the given fields replaced by the non-null parameter values.
@ -283,21 +316,20 @@ class _$DestinationImpl implements _Destination {
@override
Map<String, dynamic> toJson() {
return _$$DestinationImplToJson(
this,
);
return _$$DestinationImplToJson(this);
}
}
abstract class _Destination implements Destination {
const factory _Destination(
{required final String ref,
const factory _Destination({
required final String ref,
required final String name,
required final String country,
required final String continent,
required final String knownFor,
required final List<String> tags,
required final String imageUrl}) = _$DestinationImpl;
required final String imageUrl,
}) = _$DestinationImpl;
factory _Destination.fromJson(Map<String, dynamic> json) =
_$DestinationImpl.fromJson;

@ -12,7 +12,8 @@ part of 'itinerary_config.dart';
T _$identity<T>(T value) => value;
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) {
return _ItineraryConfig.fromJson(json);
@ -51,16 +52,18 @@ mixin _$ItineraryConfig {
/// @nodoc
abstract class $ItineraryConfigCopyWith<$Res> {
factory $ItineraryConfigCopyWith(
ItineraryConfig value, $Res Function(ItineraryConfig) then) =
_$ItineraryConfigCopyWithImpl<$Res, ItineraryConfig>;
ItineraryConfig value,
$Res Function(ItineraryConfig) then,
) = _$ItineraryConfigCopyWithImpl<$Res, ItineraryConfig>;
@useResult
$Res call(
{String? continent,
$Res call({
String? continent,
DateTime? startDate,
DateTime? endDate,
int? guests,
String? destination,
List<String> activities});
List<String> activities,
});
}
/// @nodoc
@ -85,50 +88,61 @@ class _$ItineraryConfigCopyWithImpl<$Res, $Val extends ItineraryConfig>
Object? destination = freezed,
Object? activities = null,
}) {
return _then(_value.copyWith(
continent: freezed == continent
return _then(
_value.copyWith(
continent:
freezed == continent
? _value.continent
: continent // ignore: cast_nullable_to_non_nullable
as String?,
startDate: freezed == startDate
startDate:
freezed == startDate
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime?,
endDate: freezed == endDate
endDate:
freezed == endDate
? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable
as DateTime?,
guests: freezed == guests
guests:
freezed == guests
? _value.guests
: guests // ignore: cast_nullable_to_non_nullable
as int?,
destination: freezed == destination
destination:
freezed == destination
? _value.destination
: destination // ignore: cast_nullable_to_non_nullable
as String?,
activities: null == activities
activities:
null == activities
? _value.activities
: activities // ignore: cast_nullable_to_non_nullable
as List<String>,
) as $Val);
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$ItineraryConfigImplCopyWith<$Res>
implements $ItineraryConfigCopyWith<$Res> {
factory _$$ItineraryConfigImplCopyWith(_$ItineraryConfigImpl value,
$Res Function(_$ItineraryConfigImpl) then) =
__$$ItineraryConfigImplCopyWithImpl<$Res>;
factory _$$ItineraryConfigImplCopyWith(
_$ItineraryConfigImpl value,
$Res Function(_$ItineraryConfigImpl) then,
) = __$$ItineraryConfigImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{String? continent,
$Res call({
String? continent,
DateTime? startDate,
DateTime? endDate,
int? guests,
String? destination,
List<String> activities});
List<String> activities,
});
}
/// @nodoc
@ -136,8 +150,9 @@ class __$$ItineraryConfigImplCopyWithImpl<$Res>
extends _$ItineraryConfigCopyWithImpl<$Res, _$ItineraryConfigImpl>
implements _$$ItineraryConfigImplCopyWith<$Res> {
__$$ItineraryConfigImplCopyWithImpl(
_$ItineraryConfigImpl _value, $Res Function(_$ItineraryConfigImpl) _then)
: super(_value, _then);
_$ItineraryConfigImpl _value,
$Res Function(_$ItineraryConfigImpl) _then,
) : super(_value, _then);
/// Create a copy of ItineraryConfig
/// with the given fields replaced by the non-null parameter values.
@ -151,46 +166,54 @@ class __$$ItineraryConfigImplCopyWithImpl<$Res>
Object? destination = freezed,
Object? activities = null,
}) {
return _then(_$ItineraryConfigImpl(
continent: freezed == continent
return _then(
_$ItineraryConfigImpl(
continent:
freezed == continent
? _value.continent
: continent // ignore: cast_nullable_to_non_nullable
as String?,
startDate: freezed == startDate
startDate:
freezed == startDate
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime?,
endDate: freezed == endDate
endDate:
freezed == endDate
? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable
as DateTime?,
guests: freezed == guests
guests:
freezed == guests
? _value.guests
: guests // ignore: cast_nullable_to_non_nullable
as int?,
destination: freezed == destination
destination:
freezed == destination
? _value.destination
: destination // ignore: cast_nullable_to_non_nullable
as String?,
activities: null == activities
activities:
null == activities
? _value._activities
: activities // ignore: cast_nullable_to_non_nullable
as List<String>,
));
),
);
}
}
/// @nodoc
@JsonSerializable()
class _$ItineraryConfigImpl implements _ItineraryConfig {
const _$ItineraryConfigImpl(
{this.continent,
const _$ItineraryConfigImpl({
this.continent,
this.startDate,
this.endDate,
this.guests,
this.destination,
final List<String> activities = const []})
: _activities = activities;
final List<String> activities = const [],
}) : _activities = activities;
factory _$ItineraryConfigImpl.fromJson(Map<String, dynamic> json) =>
_$$ItineraryConfigImplFromJson(json);
@ -245,14 +268,23 @@ class _$ItineraryConfigImpl implements _ItineraryConfig {
(identical(other.guests, guests) || other.guests == guests) &&
(identical(other.destination, destination) ||
other.destination == destination) &&
const DeepCollectionEquality()
.equals(other._activities, _activities));
const DeepCollectionEquality().equals(
other._activities,
_activities,
));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, continent, startDate, endDate,
guests, destination, const DeepCollectionEquality().hash(_activities));
int get hashCode => Object.hash(
runtimeType,
continent,
startDate,
endDate,
guests,
destination,
const DeepCollectionEquality().hash(_activities),
);
/// Create a copy of ItineraryConfig
/// with the given fields replaced by the non-null parameter values.
@ -261,24 +293,25 @@ class _$ItineraryConfigImpl implements _ItineraryConfig {
@pragma('vm:prefer-inline')
_$$ItineraryConfigImplCopyWith<_$ItineraryConfigImpl> get copyWith =>
__$$ItineraryConfigImplCopyWithImpl<_$ItineraryConfigImpl>(
this, _$identity);
this,
_$identity,
);
@override
Map<String, dynamic> toJson() {
return _$$ItineraryConfigImplToJson(
this,
);
return _$$ItineraryConfigImplToJson(this);
}
}
abstract class _ItineraryConfig implements ItineraryConfig {
const factory _ItineraryConfig(
{final String? continent,
const factory _ItineraryConfig({
final String? continent,
final DateTime? startDate,
final DateTime? endDate,
final int? guests,
final String? destination,
final List<String> activities}) = _$ItineraryConfigImpl;
final List<String> activities,
}) = _$ItineraryConfigImpl;
factory _ItineraryConfig.fromJson(Map<String, dynamic> json) =
_$ItineraryConfigImpl.fromJson;

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

@ -12,7 +12,8 @@ part of 'user.dart';
T _$identity<T>(T value) => value;
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) {
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.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
Object? picture = null,
}) {
return _then(_value.copyWith(
name: null == name
$Res call({Object? name = null, Object? picture = null}) {
return _then(
_value.copyWith(
name:
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
picture: null == picture
picture:
null == picture
? _value.picture
: picture // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$UserImplCopyWith<$Res> implements $UserCopyWith<$Res> {
factory _$$UserImplCopyWith(
_$UserImpl value, $Res Function(_$UserImpl) then) =
__$$UserImplCopyWithImpl<$Res>;
_$UserImpl value,
$Res Function(_$UserImpl) then,
) = __$$UserImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String name, String picture});
@ -95,20 +99,21 @@ class __$$UserImplCopyWithImpl<$Res>
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
Object? picture = null,
}) {
return _then(_$UserImpl(
name: null == name
$Res call({Object? name = null, Object? picture = null}) {
return _then(
_$UserImpl(
name:
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
picture: null == picture
picture:
null == picture
? _value.picture
: picture // ignore: cast_nullable_to_non_nullable
as String,
));
),
);
}
}
@ -156,15 +161,15 @@ class _$UserImpl implements _User {
@override
Map<String, dynamic> toJson() {
return _$$UserImplToJson(
this,
);
return _$$UserImplToJson(this);
}
}
abstract class _User implements User {
const factory _User(
{required final String name, required final String picture}) = _$UserImpl;
const factory _User({
required final String name,
required final String picture,
}) = _$UserImpl;
factory _User.fromJson(Map<String, dynamic> json) = _$UserImpl.fromJson;

@ -9,10 +9,7 @@ part of 'user.dart';
_$UserImpl _$$UserImplFromJson(Map<String, dynamic> json) => _$UserImpl(
name: json['name'] as String,
picture: json['picture'] as String,
);
);
Map<String, dynamic> _$$UserImplToJson(_$UserImpl instance) =>
<String, dynamic>{
'name': instance.name,
'picture': instance.picture,
};
<String, dynamic>{'name': instance.name, 'picture': instance.picture};

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

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

Loading…
Cancel
Save