Skip to content

Commit

Permalink
🎨 added support for watch path in web
Browse files Browse the repository at this point in the history
  • Loading branch information
sarbagyastha committed Aug 3, 2024
1 parent b33cc7e commit 6e7a86f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/web-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ jobs:
- uses: subosito/flutter-action@v2
- uses: sarbagyastha/flutter-gh-pages@main
with:
workingDir: packages/youtube_player_iframe/example
baseHref: /youtube_player_flutter/
workingDir: packages/youtube_player_iframe/example
3 changes: 2 additions & 1 deletion packages/youtube_player_iframe/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ class YoutubeApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = ColorScheme.fromSeed(
seedColor: Colors.red,
seedColor: Colors.green,
dynamicSchemeVariant: DynamicSchemeVariant.expressive,
brightness: Brightness.dark,
);

return MaterialApp.router(
Expand Down
18 changes: 12 additions & 6 deletions packages/youtube_player_iframe/example/lib/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ const List<String> _videoIds = [

///
class HomePage extends StatefulWidget {
const HomePage({super.key});
const HomePage({super.key, this.videoId});

final String? videoId;

@override
State<HomePage> createState() => _HomePageState();
Expand All @@ -56,11 +58,15 @@ class _HomePageState extends State<HomePage> {
},
);

_controller.loadPlaylist(
list: _videoIds,
listType: ListType.playlist,
startSeconds: 136,
);
if (widget.videoId != null) {
_controller.loadVideoById(videoId: widget.videoId!);
} else {
_controller.loadPlaylist(
list: _videoIds,
listType: ListType.playlist,
startSeconds: 136,
);
}
}

@override
Expand Down
9 changes: 9 additions & 0 deletions packages/youtube_player_iframe/example/lib/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ final router = GoRouter(
path: 'playlist',
pageBuilder: (_, __) => NoTransitionPage(child: VideoListPage()),
),
GoRoute(
path: 'watch',
pageBuilder: (_, GoRouterState state) {
print(state.pathParameters);
return NoTransitionPage(
child: HomePage(videoId: state.uri.queryParameters['v']),
);
},
),
],
),
],
Expand Down

0 comments on commit 6e7a86f

Please sign in to comment.