Skip to content

Commit 029ef16

Browse files
shinyfordslightfoot
authored andcommitted
fix: improve multi-login on user button [CLERK_SDK #20]
1 parent 05a9169 commit 029ef16

File tree

6 files changed

+260
-153
lines changed

6 files changed

+260
-153
lines changed

packages/clerk_auth/lib/models/client.dart

+4-2
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ class Client {
3636

3737
Map<String, dynamic> toJson() => _$ClientToJson(this);
3838

39+
Set<String> get sessionIds => sessions.map((s) => s.id).toSet();
40+
3941
Session? get activeSession {
4042
for (final session in sessions) {
41-
if (session.isActive) return session;
43+
if (session.id == lastActiveSessionId) return session;
4244
}
4345

4446
for (final session in sessions) {
45-
if (session.id == lastActiveSessionId) return session;
47+
if (session.isActive) return session;
4648
}
4749

4850
return null;

packages/clerk_flutter/example/lib/main.dart

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ class MainApp extends StatelessWidget {
2323
publishableKey: dotenv.env['publishable_key'] ?? '',
2424
child: Scaffold(
2525
backgroundColor: ClerkColors.whiteSmoke,
26-
body: Center(
27-
child: ClerkAuthBuilder(
28-
signedInBuilder: (context, auth) => const Padding(
29-
padding: allPadding32,
30-
child: ClerkUserButton(),
26+
body: Padding(
27+
padding: horizontalPadding32,
28+
child: Center(
29+
child: ClerkAuthBuilder(
30+
signedInBuilder: (context, auth) => const ClerkUserButton(),
31+
signedOutBuilder: (context, auth) => const ClerkAuthenticationWidget(),
3132
),
32-
signedOutBuilder: (context, auth) => const ClerkAuthenticationWidget(),
3333
),
3434
),
3535
),

packages/clerk_flutter/lib/src/widgets/control/clerk_auth.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ClerkAuth extends StatefulWidget {
3838
this.translator = const DefaultClerkTranslator(),
3939
this.persistor,
4040
this.loading,
41-
}) : assert((publicKey is String && publishableKey is String) != auth is Clerk.Auth);
41+
}) : assert((publicKey is String && publishableKey is String) != auth is ClerkAuthProvider);
4242

4343
@override
4444
State<ClerkAuth> createState() => _ClerkAuthState();

packages/clerk_flutter/lib/src/widgets/ui/clerk_text_form_field.dart

+5-8
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,11 @@ class ClerkTextFormField extends StatelessWidget {
4949
children: [
5050
if (label case String label) //
5151
Expanded(
52-
child: FittedBox(
53-
fit: BoxFit.fitWidth,
54-
child: Text(
55-
translator.translate(label),
56-
textAlign: TextAlign.start,
57-
maxLines: 2,
58-
style: ClerkTextStyle.inputLabel,
59-
),
52+
child: Text(
53+
translator.translate(label),
54+
textAlign: TextAlign.start,
55+
maxLines: 2,
56+
style: ClerkTextStyle.inputLabel,
6057
),
6158
),
6259
if (optional) ...[

packages/clerk_flutter/lib/src/widgets/ui/style/colors.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class ClerkColors {
5252
/// Mountain Mist (user button subtitle and status indicator color).
5353
static const mountainMist = Color(0xFF9394a1);
5454

55-
/// Deset Storm (status indicator color).
55+
/// Desert Storm (status indicator color).
5656
static const desertStorm = Color(0xFFf7f7f8);
5757

5858
/// Carmine pink (cta and error color).

0 commit comments

Comments
 (0)