feat: modify example to work with lib

Signed-off-by: Sphericalkat <me@kat.bio>
This commit is contained in:
Amogh Lele 2024-07-18 01:38:04 +05:30
parent 1d52c7b78b
commit 2fec9a083d
Signed by: sphericalkat
GPG Key ID: 1C022B9CED2425B4
5 changed files with 69 additions and 14 deletions

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:readability/article.dart';
import 'dart:async';
import 'package:readability/readability.dart' as readability;
@ -15,14 +16,12 @@ class MyApp extends StatefulWidget {
}
class _MyAppState extends State<MyApp> {
late int sumResult;
late Future<int> sumAsyncResult;
late Future<readability.ArticleResponse> readabilityResult;
@override
void initState() {
super.initState();
sumResult = readability.sum(1, 2);
sumAsyncResult = readability.sumAsync(3, 4);
readabilityResult = readability.parseAsync('https://www.bbc.com/sport/football/articles/cl7y4z82z2do');
}
@override
@ -46,17 +45,11 @@ class _MyAppState extends State<MyApp> {
textAlign: TextAlign.center,
),
spacerSmall,
Text(
'sum(1, 2) = $sumResult',
style: textStyle,
textAlign: TextAlign.center,
),
spacerSmall,
FutureBuilder<int>(
future: sumAsyncResult,
builder: (BuildContext context, AsyncSnapshot<int> value) {
FutureBuilder<readability.ArticleResponse>(
future: readabilityResult,
builder: (BuildContext context, AsyncSnapshot<readability.ArticleResponse> value) {
final displayValue =
(value.hasData) ? value.data : 'loading';
(value.hasData) ? value.data?.article.content : 'loading';
return Text(
'await sumAsync(3, 4) = $displayValue',
style: textStyle,

View File

@ -0,0 +1,15 @@
//
// Generated file. Do not edit.
//
// clang-format off
#include "generated_plugin_registrant.h"
#include <readability/readability_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) readability_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "ReadabilityPlugin");
readability_plugin_register_with_registrar(readability_registrar);
}

View File

@ -0,0 +1,15 @@
//
// Generated file. Do not edit.
//
// clang-format off
#ifndef GENERATED_PLUGIN_REGISTRANT_
#define GENERATED_PLUGIN_REGISTRANT_
#include <flutter_linux/flutter_linux.h>
// Registers Flutter plugins.
void fl_register_plugins(FlPluginRegistry* registry);
#endif // GENERATED_PLUGIN_REGISTRANT_

View File

@ -0,0 +1,24 @@
#
# Generated file, do not edit.
#
list(APPEND FLUTTER_PLUGIN_LIST
readability
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST
)
set(PLUGIN_BUNDLED_LIBRARIES)
foreach(plugin ${FLUTTER_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin)
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)

View File

@ -57,6 +57,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.1"
ffi:
dependency: transitive
description:
name: ffi
sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
flutter:
dependency: "direct main"
description: flutter