flutter_start/packages/example/lib/main.dart

102 lines
2.2 KiB
Dart
Raw Normal View History

2024-01-24 14:37:59 +01:00
import 'package:flutter/material.dart';
import 'package:flutter_start/flutter_start.dart';
import 'package:go_router/go_router.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
2024-01-31 11:56:38 +01:00
Widget build(BuildContext context) => const MaterialApp(
home: Home(),
);
2024-01-24 14:37:59 +01:00
}
class Home extends StatelessWidget {
const Home({super.key});
@override
Widget build(BuildContext context) => NavigatorStartUserStory(
2024-10-23 09:35:02 +02:00
// configuration: config,
onComplete: (context) async {
await Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (context) => const HomeEntry()),
);
},
);
2024-01-24 14:37:59 +01:00
}
StartUserStoryConfiguration config = StartUserStoryConfiguration(
// showIntroduction: false,
2024-10-23 09:35:02 +02:00
introductionService: MyIntroductionService(),
2024-01-24 14:37:59 +01:00
splashScreenBuilder: (context, onFinish) => SplashScreen(
onFinish: onFinish,
),
);
2024-10-23 09:35:02 +02:00
class MyIntroductionService implements IntroductionService {
@override
Future<void> onComplete() {
// TODO: implement onComplete
throw UnimplementedError();
}
@override
Future<void> onSkip() {
// TODO: implement onSkip
throw UnimplementedError();
}
@override
Future<bool> shouldShow() {
// TODO: implement shouldShow
throw UnimplementedError();
}
}
2024-01-24 14:37:59 +01:00
class SplashScreen extends StatefulWidget {
const SplashScreen({
required this.onFinish,
super.key,
});
final Function() onFinish;
@override
State<SplashScreen> createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
@override
void initState() {
Future.delayed(const Duration(seconds: 3), () {
widget.onFinish();
});
super.initState();
}
@override
2024-01-31 11:56:38 +01:00
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: const Text('SplashScreen'),
),
body: const Center(child: Text('SplashScreen')),
);
2024-01-24 14:37:59 +01:00
}
class HomeEntry extends StatelessWidget {
const HomeEntry({super.key});
@override
2024-01-31 11:56:38 +01:00
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: const Text('HomeEntry'),
),
body: const Center(child: Text('HomeEntry')),
);
2024-01-24 14:37:59 +01:00
}