Created
April 29, 2026 16:35
-
-
Save sheepla/ffa22d4dc4985779fb54e1e5fad87980 to your computer and use it in GitHub Desktop.
A simple AbemaTV client for Flutter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // lib/main.dart | |
| import 'package:flutter/foundation.dart'; | |
| import 'package:flutter/material.dart'; | |
| import 'package:flutter_inappwebview/flutter_inappwebview.dart'; | |
| import 'webview_config_stub.dart' | |
| if (dart.library.io) 'webview_config_native.dart' | |
| if (dart.library.html) 'webview_config_web.dart' | |
| if (dart.library.js_interop) 'webview_config_web.dart'; | |
| void main() async { | |
| WidgetsFlutterBinding.ensureInitialized(); | |
| runApp(const MyApp()); | |
| } | |
| class MyApp extends StatelessWidget { | |
| const MyApp({super.key}); | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| title: 'Simple Abema Client', | |
| debugShowCheckedModeBanner: false, | |
| theme: ThemeData( | |
| colorScheme: ColorScheme.fromSeed( | |
| seedColor: Colors.black, | |
| brightness: Brightness.dark, | |
| ), | |
| useMaterial3: true, | |
| ), | |
| home: const AbemaWebView(), | |
| ); | |
| } | |
| } | |
| class AbemaWebView extends StatefulWidget { | |
| const AbemaWebView({super.key}); | |
| @override | |
| State<AbemaWebView> createState() => _AbemaWebViewState(); | |
| } | |
| class _AbemaWebViewState extends State<AbemaWebView> { | |
| InAppWebViewController? webViewController; | |
| @override | |
| Widget build(BuildContext context) { | |
| return PopScope( | |
| canPop: false, | |
| onPopInvokedWithResult: (bool didPop, dynamic result) async { | |
| if (didPop) return; | |
| if (webViewController != null && await webViewController!.canGoBack()) { | |
| webViewController!.goBack(); | |
| } else { | |
| if (context.mounted && Navigator.of(context).canPop()) { | |
| Navigator.of(context).pop(); | |
| } | |
| } | |
| }, | |
| child: Scaffold( | |
| backgroundColor: Colors.black, | |
| appBar: kIsWeb | |
| ? AppBar( | |
| title: const Text('Abema Debug (Web)'), | |
| backgroundColor: Colors.black, | |
| ) | |
| : null, | |
| body: SafeArea( | |
| child: InAppWebView( | |
| initialUrlRequest: URLRequest(url: WebUri("https://abema.tv/")), | |
| initialSettings: getInAppWebViewSettings(), | |
| onWebViewCreated: (controller) { | |
| webViewController = controller; | |
| }, | |
| ), | |
| ), | |
| ), | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment