garage_auth, garage_entitlements, garage_iap and garage_ui, moved out of Garage-Services and Metro-Map-Maker into one public repo. MIT, one readme, docs under docs/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013F4NWNvYcdeSgqbWMT1VQ7
61 lines
1.8 KiB
Dart
61 lines
1.8 KiB
Dart
// Minimal, runnable-shaped example of wiring GarageAuth into a Flutter app.
|
|
// Not a full app — just the moving parts. See the README for the callback
|
|
// route + deep-link handling.
|
|
|
|
import "package:flutter/material.dart";
|
|
import "package:garage_auth/garage_auth.dart";
|
|
|
|
final auth = GarageAuth(
|
|
issuer: "https://hub.imbenji.net/auth-api",
|
|
clientId: "my-app",
|
|
redirectUri: "myapp://auth/callback",
|
|
);
|
|
|
|
Future<void> main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
await auth.restore();
|
|
runApp(const MyApp());
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
home: ListenableBuilder(
|
|
listenable: auth,
|
|
builder: (context, _) {
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text("garage_auth example")),
|
|
body: Center(
|
|
child: auth.isSignedIn
|
|
? Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const Text("Signed in 🎉"),
|
|
TextButton(
|
|
onPressed: () async {
|
|
final me = await auth.profile();
|
|
debugPrint("profile: $me");
|
|
},
|
|
child: const Text("Print profile"),
|
|
),
|
|
TextButton(
|
|
onPressed: auth.signOut,
|
|
child: const Text("Sign out"),
|
|
),
|
|
],
|
|
)
|
|
: TextButton(
|
|
onPressed: auth.signIn,
|
|
child: const Text("Sign in with Garage"),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|