2024-07-17 18:59:09 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2024-07-18 00:16:45 +00:00
|
|
|
import 'package:readability/article.dart';
|
2024-07-17 18:59:09 +00:00
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
import 'package:readability/readability.dart' as readability;
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
runApp(const MyApp());
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyApp extends StatefulWidget {
|
|
|
|
const MyApp({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<MyApp> createState() => _MyAppState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MyAppState extends State<MyApp> {
|
2024-07-18 00:16:45 +00:00
|
|
|
late Future<Article> readabilityResult;
|
2024-07-17 18:59:09 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
2024-07-17 20:08:04 +00:00
|
|
|
readabilityResult = readability.parseAsync('https://www.bbc.com/sport/football/articles/cl7y4z82z2do');
|
2024-07-17 18:59:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
const textStyle = TextStyle(fontSize: 25);
|
|
|
|
const spacerSmall = SizedBox(height: 10);
|
|
|
|
return MaterialApp(
|
|
|
|
home: Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
title: const Text('Native Packages'),
|
|
|
|
),
|
|
|
|
body: SingleChildScrollView(
|
|
|
|
child: Container(
|
|
|
|
padding: const EdgeInsets.all(10),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
2024-07-18 00:16:45 +00:00
|
|
|
FutureBuilder<Article>(
|
2024-07-17 20:08:04 +00:00
|
|
|
future: readabilityResult,
|
2024-07-18 00:16:45 +00:00
|
|
|
builder: (BuildContext context, AsyncSnapshot<Article> value) {
|
2024-07-17 23:47:56 +00:00
|
|
|
final textContent =
|
2024-07-18 00:16:45 +00:00
|
|
|
(value.hasData) ? value.data?.textContent : 'loading';
|
2024-07-17 23:47:56 +00:00
|
|
|
final title =
|
2024-07-18 00:16:45 +00:00
|
|
|
(value.hasData) ? value.data?.title : 'loading';
|
2024-07-17 23:47:56 +00:00
|
|
|
|
|
|
|
return Column(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
title ?? '',
|
|
|
|
style: const TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
|
|
|
|
),
|
|
|
|
spacerSmall,
|
|
|
|
Text(
|
|
|
|
textContent ?? '',
|
|
|
|
style: textStyle,
|
|
|
|
),
|
|
|
|
],
|
2024-07-17 18:59:09 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|