feat: modify example to work with lib
Signed-off-by: Sphericalkat <me@kat.bio>
This commit is contained in:
		
							parent
							
								
									1d52c7b78b
								
							
						
					
					
						commit
						2fec9a083d
					
				@ -1,4 +1,5 @@
 | 
				
			|||||||
import 'package:flutter/material.dart';
 | 
					import 'package:flutter/material.dart';
 | 
				
			||||||
 | 
					import 'package:readability/article.dart';
 | 
				
			||||||
import 'dart:async';
 | 
					import 'dart:async';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import 'package:readability/readability.dart' as readability;
 | 
					import 'package:readability/readability.dart' as readability;
 | 
				
			||||||
@ -15,14 +16,12 @@ class MyApp extends StatefulWidget {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class _MyAppState extends State<MyApp> {
 | 
					class _MyAppState extends State<MyApp> {
 | 
				
			||||||
  late int sumResult;
 | 
					  late Future<readability.ArticleResponse> readabilityResult;
 | 
				
			||||||
  late Future<int> sumAsyncResult;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
  void initState() {
 | 
					  void initState() {
 | 
				
			||||||
    super.initState();
 | 
					    super.initState();
 | 
				
			||||||
    sumResult = readability.sum(1, 2);
 | 
					    readabilityResult = readability.parseAsync('https://www.bbc.com/sport/football/articles/cl7y4z82z2do');
 | 
				
			||||||
    sumAsyncResult = readability.sumAsync(3, 4);
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
@ -46,17 +45,11 @@ class _MyAppState extends State<MyApp> {
 | 
				
			|||||||
                  textAlign: TextAlign.center,
 | 
					                  textAlign: TextAlign.center,
 | 
				
			||||||
                ),
 | 
					                ),
 | 
				
			||||||
                spacerSmall,
 | 
					                spacerSmall,
 | 
				
			||||||
                Text(
 | 
					                FutureBuilder<readability.ArticleResponse>(
 | 
				
			||||||
                  'sum(1, 2) = $sumResult',
 | 
					                  future: readabilityResult,
 | 
				
			||||||
                  style: textStyle,
 | 
					                  builder: (BuildContext context, AsyncSnapshot<readability.ArticleResponse> value) {
 | 
				
			||||||
                  textAlign: TextAlign.center,
 | 
					 | 
				
			||||||
                ),
 | 
					 | 
				
			||||||
                spacerSmall,
 | 
					 | 
				
			||||||
                FutureBuilder<int>(
 | 
					 | 
				
			||||||
                  future: sumAsyncResult,
 | 
					 | 
				
			||||||
                  builder: (BuildContext context, AsyncSnapshot<int> value) {
 | 
					 | 
				
			||||||
                    final displayValue =
 | 
					                    final displayValue =
 | 
				
			||||||
                        (value.hasData) ? value.data : 'loading';
 | 
					                        (value.hasData) ? value.data?.article.content : 'loading';
 | 
				
			||||||
                    return Text(
 | 
					                    return Text(
 | 
				
			||||||
                      'await sumAsync(3, 4) = $displayValue',
 | 
					                      'await sumAsync(3, 4) = $displayValue',
 | 
				
			||||||
                      style: textStyle,
 | 
					                      style: textStyle,
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										15
									
								
								example/linux/flutter/generated_plugin_registrant.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								example/linux/flutter/generated_plugin_registrant.cc
									
									
									
									
									
										Normal 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);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										15
									
								
								example/linux/flutter/generated_plugin_registrant.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								example/linux/flutter/generated_plugin_registrant.h
									
									
									
									
									
										Normal 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_
 | 
				
			||||||
							
								
								
									
										24
									
								
								example/linux/flutter/generated_plugins.cmake
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								example/linux/flutter/generated_plugins.cmake
									
									
									
									
									
										Normal 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)
 | 
				
			||||||
@ -57,6 +57,14 @@ packages:
 | 
				
			|||||||
      url: "https://pub.dev"
 | 
					      url: "https://pub.dev"
 | 
				
			||||||
    source: hosted
 | 
					    source: hosted
 | 
				
			||||||
    version: "1.3.1"
 | 
					    version: "1.3.1"
 | 
				
			||||||
 | 
					  ffi:
 | 
				
			||||||
 | 
					    dependency: transitive
 | 
				
			||||||
 | 
					    description:
 | 
				
			||||||
 | 
					      name: ffi
 | 
				
			||||||
 | 
					      sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21"
 | 
				
			||||||
 | 
					      url: "https://pub.dev"
 | 
				
			||||||
 | 
					    source: hosted
 | 
				
			||||||
 | 
					    version: "2.1.2"
 | 
				
			||||||
  flutter:
 | 
					  flutter:
 | 
				
			||||||
    dependency: "direct main"
 | 
					    dependency: "direct main"
 | 
				
			||||||
    description: flutter
 | 
					    description: flutter
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user