Skip to content

Commit 658f181

Browse files
committed
chore: dart format
1 parent 6221028 commit 658f181

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1527
-1583
lines changed

packages/go_router/example/lib/async_redirection.dart

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@ class App extends StatelessWidget {
3030
// add the login info into the tree as app state that can change over time
3131
@override
3232
Widget build(BuildContext context) => MaterialApp.router(
33-
routerConfig: _router,
34-
title: title,
35-
debugShowCheckedModeBanner: false,
36-
);
33+
routerConfig: _router,
34+
title: title,
35+
debugShowCheckedModeBanner: false,
36+
);
3737

3838
late final GoRouter _router = GoRouter(
3939
routes: <GoRoute>[
4040
GoRoute(
4141
path: '/',
42-
builder:
43-
(BuildContext context, GoRouterState state) => const HomeScreen(),
42+
builder: (BuildContext context, GoRouterState state) =>
43+
const HomeScreen(),
4444
),
4545
GoRoute(
4646
path: '/login',
47-
builder:
48-
(BuildContext context, GoRouterState state) => const LoginScreen(),
47+
builder: (BuildContext context, GoRouterState state) =>
48+
const LoginScreen(),
4949
),
5050
],
5151

@@ -93,8 +93,8 @@ class _LoginScreenState extends State<LoginScreen>
9393
vsync: this,
9494
duration: const Duration(seconds: 1),
9595
)..addListener(() {
96-
setState(() {});
97-
});
96+
setState(() {});
97+
});
9898
controller.repeat();
9999
}
100100

@@ -106,26 +106,26 @@ class _LoginScreenState extends State<LoginScreen>
106106

107107
@override
108108
Widget build(BuildContext context) => Scaffold(
109-
appBar: AppBar(title: const Text(App.title)),
110-
body: Center(
111-
child: Column(
112-
mainAxisAlignment: MainAxisAlignment.center,
113-
children: <Widget>[
114-
if (loggingIn) CircularProgressIndicator(value: controller.value),
115-
if (!loggingIn)
116-
ElevatedButton(
117-
onPressed: () {
118-
StreamAuthScope.of(context).signIn('test-user');
119-
setState(() {
120-
loggingIn = true;
121-
});
122-
},
123-
child: const Text('Login'),
124-
),
125-
],
126-
),
127-
),
128-
);
109+
appBar: AppBar(title: const Text(App.title)),
110+
body: Center(
111+
child: Column(
112+
mainAxisAlignment: MainAxisAlignment.center,
113+
children: <Widget>[
114+
if (loggingIn) CircularProgressIndicator(value: controller.value),
115+
if (!loggingIn)
116+
ElevatedButton(
117+
onPressed: () {
118+
StreamAuthScope.of(context).signIn('test-user');
119+
setState(() {
120+
loggingIn = true;
121+
});
122+
},
123+
child: const Text('Login'),
124+
),
125+
],
126+
),
127+
),
128+
);
129129
}
130130

131131
/// The home screen.
@@ -157,7 +157,7 @@ class HomeScreen extends StatelessWidget {
157157
class StreamAuthScope extends InheritedNotifier<StreamAuthNotifier> {
158158
/// Creates a [StreamAuthScope] sign in scope.
159159
StreamAuthScope({super.key, required super.child})
160-
: super(notifier: StreamAuthNotifier());
160+
: super(notifier: StreamAuthNotifier());
161161

162162
/// Gets the [StreamAuth].
163163
static StreamAuth of(BuildContext context) {
@@ -189,7 +189,7 @@ class StreamAuth {
189189
/// Creates an [StreamAuth] that clear the current user session in
190190
/// [refeshInterval] second.
191191
StreamAuth({this.refreshInterval = 20})
192-
: _userStreamController = StreamController<String?>.broadcast() {
192+
: _userStreamController = StreamController<String?>.broadcast() {
193193
_userStreamController.stream.listen((String? currentUser) {
194194
_currentUser = currentUser;
195195
});

packages/go_router/example/lib/books/main.dart

Lines changed: 54 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ class Bookstore extends StatelessWidget {
2929

3030
@override
3131
Widget build(BuildContext context) => BookstoreAuthScope(
32-
notifier: _auth,
33-
child: MaterialApp.router(routerConfig: _router),
34-
);
32+
notifier: _auth,
33+
child: MaterialApp.router(routerConfig: _router),
34+
);
3535

3636
final BookstoreAuth _auth = BookstoreAuth();
3737

@@ -40,35 +40,34 @@ class Bookstore extends StatelessWidget {
4040
GoRoute(path: '/', redirect: (_, __) => '/books'),
4141
GoRoute(
4242
path: '/signin',
43-
pageBuilder:
44-
(BuildContext context, GoRouterState state) => FadeTransitionPage(
45-
key: state.pageKey,
46-
child: SignInScreen(
47-
onSignIn: (Credentials credentials) {
48-
BookstoreAuthScope.of(
49-
context,
50-
).signIn(credentials.username, credentials.password);
51-
},
52-
),
53-
),
43+
pageBuilder: (BuildContext context, GoRouterState state) =>
44+
FadeTransitionPage(
45+
key: state.pageKey,
46+
child: SignInScreen(
47+
onSignIn: (Credentials credentials) {
48+
BookstoreAuthScope.of(
49+
context,
50+
).signIn(credentials.username, credentials.password);
51+
},
52+
),
53+
),
5454
),
5555
GoRoute(path: '/books', redirect: (_, __) => '/books/popular'),
5656
GoRoute(
5757
path: '/book/:bookId',
58-
redirect:
59-
(BuildContext context, GoRouterState state) =>
60-
'/books/all/${state.pathParameters['bookId']}',
58+
redirect: (BuildContext context, GoRouterState state) =>
59+
'/books/all/${state.pathParameters['bookId']}',
6160
),
6261
GoRoute(
6362
path: '/books/:kind(new|all|popular)',
64-
pageBuilder:
65-
(BuildContext context, GoRouterState state) => FadeTransitionPage(
66-
key: _scaffoldKey,
67-
child: BookstoreScaffold(
68-
selectedTab: ScaffoldTab.books,
69-
child: BooksScreen(state.pathParameters['kind']!),
70-
),
71-
),
63+
pageBuilder: (BuildContext context, GoRouterState state) =>
64+
FadeTransitionPage(
65+
key: _scaffoldKey,
66+
child: BookstoreScaffold(
67+
selectedTab: ScaffoldTab.books,
68+
child: BooksScreen(state.pathParameters['kind']!),
69+
),
70+
),
7271
routes: <GoRoute>[
7372
GoRoute(
7473
path: ':bookId',
@@ -84,20 +83,19 @@ class Bookstore extends StatelessWidget {
8483
),
8584
GoRoute(
8685
path: '/author/:authorId',
87-
redirect:
88-
(BuildContext context, GoRouterState state) =>
89-
'/authors/${state.pathParameters['authorId']}',
86+
redirect: (BuildContext context, GoRouterState state) =>
87+
'/authors/${state.pathParameters['authorId']}',
9088
),
9189
GoRoute(
9290
path: '/authors',
93-
pageBuilder:
94-
(BuildContext context, GoRouterState state) => FadeTransitionPage(
95-
key: _scaffoldKey,
96-
child: const BookstoreScaffold(
97-
selectedTab: ScaffoldTab.authors,
98-
child: AuthorsScreen(),
99-
),
100-
),
91+
pageBuilder: (BuildContext context, GoRouterState state) =>
92+
FadeTransitionPage(
93+
key: _scaffoldKey,
94+
child: const BookstoreScaffold(
95+
selectedTab: ScaffoldTab.authors,
96+
child: AuthorsScreen(),
97+
),
98+
),
10199
routes: <GoRoute>[
102100
GoRoute(
103101
path: ':authorId',
@@ -113,14 +111,14 @@ class Bookstore extends StatelessWidget {
113111
),
114112
GoRoute(
115113
path: '/settings',
116-
pageBuilder:
117-
(BuildContext context, GoRouterState state) => FadeTransitionPage(
118-
key: _scaffoldKey,
119-
child: const BookstoreScaffold(
120-
selectedTab: ScaffoldTab.settings,
121-
child: SettingsScreen(),
122-
),
123-
),
114+
pageBuilder: (BuildContext context, GoRouterState state) =>
115+
FadeTransitionPage(
116+
key: _scaffoldKey,
117+
child: const BookstoreScaffold(
118+
selectedTab: ScaffoldTab.settings,
119+
child: SettingsScreen(),
120+
),
121+
),
124122
),
125123
],
126124
redirect: _guard,
@@ -150,18 +148,18 @@ class Bookstore extends StatelessWidget {
150148
class FadeTransitionPage extends CustomTransitionPage<void> {
151149
/// Creates a [FadeTransitionPage].
152150
FadeTransitionPage({required LocalKey super.key, required super.child})
153-
: super(
154-
transitionsBuilder:
155-
(
156-
BuildContext context,
157-
Animation<double> animation,
158-
Animation<double> secondaryAnimation,
159-
Widget child,
160-
) => FadeTransition(
161-
opacity: animation.drive(_curveTween),
162-
child: child,
163-
),
164-
);
151+
: super(
152+
transitionsBuilder: (
153+
BuildContext context,
154+
Animation<double> animation,
155+
Animation<double> secondaryAnimation,
156+
Widget child,
157+
) =>
158+
FadeTransition(
159+
opacity: animation.drive(_curveTween),
160+
child: child,
161+
),
162+
);
165163

166164
static final CurveTween _curveTween = CurveTween(curve: Curves.easeIn);
167165
}

packages/go_router/example/lib/books/src/auth.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ class BookstoreAuthScope extends InheritedNotifier<BookstoreAuth> {
4040
});
4141

4242
/// Gets the [BookstoreAuth] above the context.
43-
static BookstoreAuth of(BuildContext context) =>
44-
context
45-
.dependOnInheritedWidgetOfExactType<BookstoreAuthScope>()!
46-
.notifier!;
43+
static BookstoreAuth of(BuildContext context) => context
44+
.dependOnInheritedWidgetOfExactType<BookstoreAuthScope>()!
45+
.notifier!;
4746
}

packages/go_router/example/lib/books/src/data/library.dart

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,31 @@ import 'author.dart';
66
import 'book.dart';
77

88
/// Library data mock.
9-
final Library libraryInstance =
10-
Library()
11-
..addBook(
12-
title: 'Left Hand of Darkness',
13-
authorName: 'Ursula K. Le Guin',
14-
isPopular: true,
15-
isNew: true,
16-
)
17-
..addBook(
18-
title: 'Too Like the Lightning',
19-
authorName: 'Ada Palmer',
20-
isPopular: false,
21-
isNew: true,
22-
)
23-
..addBook(
24-
title: 'Kindred',
25-
authorName: 'Octavia E. Butler',
26-
isPopular: true,
27-
isNew: false,
28-
)
29-
..addBook(
30-
title: 'The Lathe of Heaven',
31-
authorName: 'Ursula K. Le Guin',
32-
isPopular: false,
33-
isNew: false,
34-
);
9+
final Library libraryInstance = Library()
10+
..addBook(
11+
title: 'Left Hand of Darkness',
12+
authorName: 'Ursula K. Le Guin',
13+
isPopular: true,
14+
isNew: true,
15+
)
16+
..addBook(
17+
title: 'Too Like the Lightning',
18+
authorName: 'Ada Palmer',
19+
isPopular: false,
20+
isNew: true,
21+
)
22+
..addBook(
23+
title: 'Kindred',
24+
authorName: 'Octavia E. Butler',
25+
isPopular: true,
26+
isNew: false,
27+
)
28+
..addBook(
29+
title: 'The Lathe of Heaven',
30+
authorName: 'Ursula K. Le Guin',
31+
isPopular: false,
32+
isNew: false,
33+
);
3534

3635
/// A library that contains books and authors.
3736
class Library {
@@ -71,11 +70,11 @@ class Library {
7170

7271
/// The list of popular books in the library.
7372
List<Book> get popularBooks => <Book>[
74-
...allBooks.where((Book book) => book.isPopular),
75-
];
73+
...allBooks.where((Book book) => book.isPopular),
74+
];
7675

7776
/// The list of new books in the library.
7877
List<Book> get newBooks => <Book>[
79-
...allBooks.where((Book book) => book.isNew),
80-
];
78+
...allBooks.where((Book book) => book.isNew),
79+
];
8180
}

packages/go_router/example/lib/books/src/screens/authors.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ class AuthorsScreen extends StatelessWidget {
1818

1919
@override
2020
Widget build(BuildContext context) => Scaffold(
21-
appBar: AppBar(title: const Text(title)),
22-
body: AuthorList(
23-
authors: libraryInstance.allAuthors,
24-
onTap: (Author author) {
25-
context.go('/author/${author.id}');
26-
},
27-
),
28-
);
21+
appBar: AppBar(title: const Text(title)),
22+
body: AuthorList(
23+
authors: libraryInstance.allAuthors,
24+
onTap: (Author author) {
25+
context.go('/author/${author.id}');
26+
},
27+
),
28+
);
2929
}

packages/go_router/example/lib/books/src/screens/book_details.dart

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,20 @@ class BookDetailsScreen extends StatelessWidget {
3939
onPressed: () {
4040
Navigator.of(context).push<void>(
4141
MaterialPageRoute<void>(
42-
builder:
43-
(BuildContext context) =>
44-
AuthorDetailsScreen(author: book!.author),
42+
builder: (BuildContext context) =>
43+
AuthorDetailsScreen(author: book!.author),
4544
),
4645
);
4746
},
4847
child: const Text('View author (navigator.push)'),
4948
),
5049
Link(
5150
uri: Uri.parse('/author/${book!.author.id}'),
52-
builder:
53-
(BuildContext context, FollowLink? followLink) => TextButton(
54-
onPressed: followLink,
55-
child: const Text('View author (Link)'),
56-
),
51+
builder: (BuildContext context, FollowLink? followLink) =>
52+
TextButton(
53+
onPressed: followLink,
54+
child: const Text('View author (Link)'),
55+
),
5756
),
5857
TextButton(
5958
onPressed: () {

0 commit comments

Comments
 (0)