Skip to content

Commit

Permalink
Fixes after PR
Browse files Browse the repository at this point in the history
  • Loading branch information
demchenkoalex committed Mar 6, 2021
1 parent 7cd94c3 commit 4b995de
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 80 deletions.
53 changes: 47 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Miscellaneous
*.class
*.lock
*.log
*.pyc
*.swp
Expand All @@ -15,20 +16,48 @@
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
# Visual Studio Code related
.classpath
.project
.settings/
.vscode/

# Flutter repo-specific
/bin/cache/
/bin/internal/bootstrap.bat
/bin/internal/bootstrap.sh
/bin/mingit/
/dev/benchmarks/mega_gallery/
/dev/bots/.recipe_deps
/dev/bots/android_tools/
/dev/devicelab/ABresults*.json
/dev/docs/doc/
/dev/docs/flutter.docs.zip
/dev/docs/lib/
/dev/docs/pubspec.yaml
/dev/integration_tests/**/xcuserdata
/dev/integration_tests/**/Pods
/packages/flutter/coverage/
version
analysis_benchmark.json

# packages file containing multi-root paths
.packages.generated

# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
**/generated_plugin_registrant.dart
.packages
.pub-cache/
.pub/
build/
flutter_*.png
linked_*.ds
unlinked.ds
unlinked_spec.ds

# Android related
**/android/**/gradle-wrapper.jar
Expand All @@ -38,6 +67,8 @@ build/
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java
**/android/key.properties
*.jks

# iOS/XCode related
**/ios/**/*.mode1v3
Expand All @@ -56,22 +87,32 @@ build/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/.last_build_id
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Flutter.podspec
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/ephemeral
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/Flutter/flutter_export_environment.sh
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*

# macOS
**/macos/Flutter/GeneratedPluginRegistrant.swift

# Coverage
coverage/

# Symbols
app.*.symbols

# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

pubspec.lock
!/dev/ci/**/Gemfile.lock
2 changes: 1 addition & 1 deletion .metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.

version:
revision: bbfbf1770cca2da7c82e887e4e4af910034800b6
revision: c5a4b4029c0798f37c4a39b479d7cb75daa7b05c
channel: stable

project_type: package
2 changes: 1 addition & 1 deletion example/.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.

version:
revision: 60bd88df915880d23877bfc1602e8ddcf4c4dd2a
revision: c5a4b4029c0798f37c4a39b479d7cb75daa7b05c
channel: stable

project_type: app
21 changes: 5 additions & 16 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
import 'package:flutter/material.dart';
import 'package:flutter_chat_types/flutter_chat_types.dart' show PreviewData;
import 'package:flutter_link_previewer/flutter_link_previewer.dart';

void main() {
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({
Key key,
}) : super(key: key);
const MyApp({Key key}) : super(key: key);

// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: const HomePage(),
home: const MyHomePage(),
);
}
}

class HomePage extends StatelessWidget {
const HomePage({
Key key,
}) : super(key: key);
class MyHomePage extends StatelessWidget {
const MyHomePage({Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
Expand All @@ -52,7 +47,6 @@ class HomePage extends StatelessWidget {
Radius.circular(10),
),
child: LinkPreview(
onPreviewDataFetched: _onPreviewDataFetched,
text:
'https://dev.to/demchenkoalex/making-a-right-keyboard-accessory-view-in-react-native-4n3p',
width: MediaQuery.of(context).size.width,
Expand All @@ -68,7 +62,6 @@ class HomePage extends StatelessWidget {
),
),
child: LinkPreview(
onPreviewDataFetched: _onPreviewDataFetched,
text: 'instagram.com',
width: MediaQuery.of(context).size.width,
),
Expand All @@ -78,8 +71,4 @@ class HomePage extends StatelessWidget {
),
);
}

void _onPreviewDataFetched(PreviewData previewData) {
print(previewData.link);
}
}
2 changes: 1 addition & 1 deletion lib/src/url_linkifier.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:meta/meta.dart';
import 'package:linkify/linkify.dart';
import 'package:meta/meta.dart';

final _urlRegex = RegExp(
r'^(.*?)((?:https?:\/\/|www\.)[^\s/$.?#].[^\s]*)',
Expand Down
11 changes: 5 additions & 6 deletions lib/src/utils.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'dart:async';
import 'package:flutter/material.dart' hide Element;
import 'package:http/http.dart' as http show get;
import 'package:html/parser.dart' as parser show parse;
import 'package:html/dom.dart' show Document;
import 'package:flutter_link_previewer/src/types.dart';
import 'package:flutter_chat_types/flutter_chat_types.dart'
show PreviewData, PreviewDataImage;
import 'package:html/dom.dart' show Document;
import 'package:html/parser.dart' as parser show parse;
import 'package:http/http.dart' as http show get;
import 'types.dart';

extension FileNameExtention on String {
String get fileExtension {
Expand Down Expand Up @@ -121,7 +121,7 @@ Future<String> _getBiggestImageUrl(List<String> imageUrls) async {
}

Future<PreviewData> getPreviewData(String text) async {
final previewData = PreviewData();
const previewData = PreviewData();

String previewDataUrl;
String previewDataTitle;
Expand Down Expand Up @@ -180,7 +180,6 @@ Future<PreviewData> getPreviewData(String text) async {
title: previewDataTitle,
);
} catch (e) {
print(e);
return PreviewData(
description: previewDataDescription,
image: previewDataImage,
Expand Down
10 changes: 5 additions & 5 deletions lib/src/widgets/link_preview.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_chat_types/flutter_chat_types.dart' show PreviewData;
import 'package:flutter_link_previewer/src/utils.dart';
import 'package:flutter_link_previewer/src/url_linkifier.dart';
import 'package:flutter_linkify/flutter_linkify.dart' hide UrlLinkifier;
import 'package:url_launcher/url_launcher.dart';
import '../url_linkifier.dart' show UrlLinkifier;
import '../utils.dart' show getPreviewData;

@immutable
class LinkPreview extends StatelessWidget {
Expand Down Expand Up @@ -73,7 +73,7 @@ class LinkPreview extends StatelessWidget {
linkStyle: linkStyle,
maxLines: 100,
onOpen: _onOpen,
options: LinkifyOptions(
options: const LinkifyOptions(
defaultToHttps: true,
humanize: false,
looseUrl: true,
Expand Down Expand Up @@ -110,7 +110,7 @@ class LinkPreview extends StatelessWidget {
linkStyle: linkStyle,
maxLines: 100,
onOpen: _onOpen,
options: LinkifyOptions(
options: const LinkifyOptions(
defaultToHttps: true,
humanize: false,
looseUrl: true,
Expand Down Expand Up @@ -210,7 +210,7 @@ class LinkPreview extends StatelessWidget {
linkStyle: linkStyle,
maxLines: 100,
onOpen: _onOpen,
options: LinkifyOptions(
options: const LinkifyOptions(
defaultToHttps: true,
humanize: false,
looseUrl: true,
Expand Down
50 changes: 6 additions & 44 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,16 @@ environment:
dependencies:
flutter:
sdk: flutter

cupertino_icons: ^1.0.0
cupertino_icons: ^1.0.2
flutter_chat_types: ^2.0.0
flutter_linkify: ^5.0.0
html: ^0.15.0
http: ^0.13.0
flutter_chat_types: ^1.1.1
flutter_linkify: ^4.0.2
linkify: ^3.0.0
meta: ^1.2.4
linkify: ^4.0.0
meta: ^1.3.0
url_launcher: ^6.0.2

dev_dependencies:
pedantic: ^1.11.0
flutter_test:
sdk: flutter

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

# To add assets to your package, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
#
# For details regarding assets in packages, see
# https://flutter.dev/assets-and-images/#from-packages
#
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.

# To add custom fonts to your package, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts in packages, see
# https://flutter.dev/custom-fonts/#from-packages
pedantic: ^1.11.0

0 comments on commit 4b995de

Please sign in to comment.