diff --git a/example/lib/main.dart b/example/lib/main.dart index 54be1f9..80aa841 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -20,15 +20,13 @@ class HomePage extends StatefulWidget { _HomePageState createState() => _HomePageState(); } -class _HomePageState extends State - with SingleTickerProviderStateMixin { - FlutterInsta flutterInsta = - FlutterInsta(); // create instance of FlutterInsta class +class _HomePageState extends State with SingleTickerProviderStateMixin { + FlutterInsta flutterInsta = FlutterInsta(); // create instance of FlutterInsta class TextEditingController usernameController = TextEditingController(); TextEditingController reelController = TextEditingController(); - TabController tabController; + TabController? tabController; - String username, followers = " ", following, bio, website, profileimage; + String? username, followers = " ", following, bio, website, profileimage; bool pressed = false; bool downloading = false; @@ -36,20 +34,18 @@ class _HomePageState extends State void initState() { super.initState(); tabController = TabController(vsync: this, initialIndex: 1, length: 2); - InitializeDownloader(); + initializeDownloader(); downloadReels(); } - void InitializeDownloader() async { + void initializeDownloader() async { WidgetsFlutterBinding.ensureInitialized(); - await FlutterDownloader.initialize( - debug: true // optional: set false to disable printing logs to console + await FlutterDownloader.initialize(debug: true // optional: set false to disable printing logs to console ); } void downloadReels() async { - var s = await flutterInsta - .downloadReels("https://www.instagram.com/p/CDlGkdZgB2y"); + var s = await flutterInsta.downloadReels("https://www.instagram.com/p/CDlGkdZgB2y"); print(s); } @@ -74,7 +70,7 @@ class _HomePageState extends State controller: tabController, children: [ homePage(), // // home screen for Getting profile details - ReelPage() // reel download Screen + reelPage() // reel download Screen ], ), ); @@ -149,8 +145,7 @@ class _HomePageState extends State padding: EdgeInsets.only(top: 10), ), Row( - mainAxisAlignment: - MainAxisAlignment.spaceAround, + mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Text( "$followers\nFollowers", @@ -196,7 +191,7 @@ class _HomePageState extends State } //Reel Downloader page - Widget ReelPage() { + Widget reelPage() { return Column( mainAxisAlignment: MainAxisAlignment.start, children: [ @@ -214,8 +209,7 @@ class _HomePageState extends State ), downloading ? Center( - child: - CircularProgressIndicator(), //if downloading is true show Progress Indicator + child: CircularProgressIndicator(), //if downloading is true show Progress Indicator ) : Container() ], @@ -225,13 +219,13 @@ class _HomePageState extends State //Download reel video on button clickl void download() async { var myvideourl = await flutterInsta.downloadReels(reelController.text); - final taskId = await FlutterDownloader.enqueue( + + await FlutterDownloader.enqueue( url: '$myvideourl', savedDir: '/sdcard/Download', showNotification: true, // show download progress in status bar (for Android) - openFileFromNotification: - true, // click on notification to open downloaded file (for Android) + openFileFromNotification: true, // click on notification to open downloaded file (for Android) ).whenComplete(() { setState(() { downloading = false; // set to false to stop Progress indicator diff --git a/example/pubspec.lock b/example/pubspec.lock index 4127b53..0dc0430 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,56 +7,56 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.1" + version: "2.6.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.3" + version: "1.15.0" cupertino_icons: dependency: "direct main" description: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "1.0.3" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -68,14 +68,14 @@ packages: name: flutter_downloader url: "https://pub.dartlang.org" source: hosted - version: "1.5.2" + version: "1.6.1" flutter_insta: dependency: "direct main" description: path: ".." relative: true source: path - version: "0.1.4" + version: "1.6.1" flutter_test: dependency: "direct dev" description: flutter @@ -87,42 +87,42 @@ packages: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.12.2" + version: "0.13.3" http_parser: dependency: transitive description: name: http_parser url: "https://pub.dartlang.org" source: hosted - version: "3.1.4" + version: "4.0.0" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.1" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.1" + version: "1.8.0" pedantic: dependency: transitive description: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.9.0" + version: "1.11.0" sky_engine: dependency: transitive description: flutter @@ -134,56 +134,56 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.2" + version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.2" + version: "0.3.0" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" sdks: - dart: ">=2.10.0-110 <2.11.0" - flutter: ">=1.12.13 <2.0.0" + dart: ">=2.12.0 <3.0.0" + flutter: ">=1.20.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index f70bd24..80a9ff6 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -3,27 +3,18 @@ description: Demonstrates how to use the flutter_insta plugin. # The following line prevents the package from being accidentally published to # pub.dev using `pub publish`. This is preferred for private packages. -publish_to: 'none' # Remove this line if you wish to publish to pub.dev +publish_to: "none" # Remove this line if you wish to publish to pub.dev environment: - sdk: ">=2.7.0 <3.0.0" + sdk: ">=2.12.0 <3.0.0" dependencies: flutter: sdk: flutter - flutter_downloader: ^1.5.2 - flutter_insta: - # When depending on this package from a real application you should use: - # flutter_insta: ^x.y.z - # See https://dart.dev/tools/pub/dependencies#version-constraints - # The example app is bundled with the plugin so we use a path dependency on - # the parent directory to use the current plugin's version. path: ../ - - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^0.1.3 + cupertino_icons: ^1.0.2 + flutter_downloader: ^1.6.1 dev_dependencies: flutter_test: @@ -31,26 +22,20 @@ dev_dependencies: # 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: - # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. uses-material-design: true - # To add assets to your application, add an assets section, like this: # assets: # - images/a_dot_burr.jpeg # - images/a_dot_ham.jpeg - # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware. - # For details regarding adding assets from package dependencies, see # https://flutter.dev/assets-and-images/#from-packages - # To add custom fonts to your application, 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 diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index 094db58..9942474 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -18,8 +18,7 @@ void main() { // Verify that platform version is retrieved. expect( find.byWidgetPredicate( - (Widget widget) => widget is Text && - widget.data.startsWith('Running on:'), + (Widget widget) => widget is Text && widget.data!.startsWith('Running on:'), ), findsOneWidget, ); diff --git a/lib/flutter_insta.dart b/lib/flutter_insta.dart index 155dd90..e1afc4b 100644 --- a/lib/flutter_insta.dart +++ b/lib/flutter_insta.dart @@ -4,16 +4,14 @@ import 'package:http/http.dart' as http; class FlutterInsta { String url = "https://www.instagram.com/"; - String _followers, _following, _website, _bio, _imgurl,_username; + String? _followers, _following, _website, _bio, _imgurl, _username; // List of images from user feed - List _feedImagesUrl; + List? _feedImagesUrl; //Download reels video Future downloadReels(String link) async { var linkEdit = link.replaceAll(" ", "").split("/"); - var downloadURL = await http.get( - '${linkEdit[0]}//${linkEdit[2]}/${linkEdit[3]}/${linkEdit[4]}' + - "/?__a=1"); + var downloadURL = await http.get(Uri.parse('${linkEdit[0]}//${linkEdit[2]}/${linkEdit[3]}/${linkEdit[4]}' + "/?__a=1")); var data = json.decode(downloadURL.body); var graphql = data['graphql']; var shortcodeMedia = graphql['shortcode_media']; @@ -23,7 +21,7 @@ class FlutterInsta { //get profile details Future getProfileData(String username) async { - var res = await http.get(Uri.encodeFull(url + username + "/?__a=1")); + var res = await http.get(Uri.parse(Uri.encodeFull(url + username + "/?__a=1"))); var data = json.decode(res.body); var graphql = data['graphql']; var user = graphql['user']; @@ -35,15 +33,16 @@ class FlutterInsta { _following = myfollowing['count'].toString(); _website = user['external_url']; _imgurl = user['profile_pic_url_hd']; - _feedImagesUrl = user['edge_owner_to_timeline_media']['edges'].map((image) => image['node']['display_url'] as String).toList(); - this._username=username; + _feedImagesUrl = + user['edge_owner_to_timeline_media']['edges'].map((image) => image['node']['display_url'] as String).toList(); + this._username = username; } - String get followers => _followers; + String? get followers => _followers; get following => _following; - get username =>_username; + get username => _username; get website => _website; @@ -51,5 +50,5 @@ class FlutterInsta { get imgurl => _imgurl; - List get feedImagesUrl => _feedImagesUrl; + List? get feedImagesUrl => _feedImagesUrl; } diff --git a/pubspec.lock b/pubspec.lock index 23bd389..d321925 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,49 +7,49 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.1" + version: "2.6.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.3" + version: "1.15.0" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -66,42 +66,42 @@ packages: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.12.2" + version: "0.13.3" http_parser: dependency: transitive description: name: http_parser url: "https://pub.dartlang.org" source: hosted - version: "3.1.4" + version: "4.0.0" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.1" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.1" + version: "1.8.0" pedantic: dependency: transitive description: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.9.0" + version: "1.11.0" sky_engine: dependency: transitive description: flutter @@ -113,56 +113,56 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.2" + version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.2" + version: "0.3.0" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" sdks: - dart: ">=2.10.0-110 <2.11.0" - flutter: ">=1.10.0" + dart: ">=2.12.0 <3.0.0" + flutter: ">=1.20.0" diff --git a/pubspec.yaml b/pubspec.yaml index aabed45..60761f0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,30 +1,30 @@ name: flutter_insta -description: Flutter package to get instagram user's details such as profile picture url,number of followers,following,Bio,website and download reels video. -version: 0.1.4 +description: Flutter package to get instagram user's details such as profile + picture url,number of followers,following,Bio,website and download reels + video. +version: 1.6.1 homepage: https://github.com/viralvaghela/flutter_insta environment: - sdk: ">=2.7.0 <3.0.0" - flutter: ">=1.10.0" + sdk: ">=2.12.0 <3.0.0" + flutter: ">=1.20.0" dependencies: flutter: sdk: flutter - http: ^0.12.2 + http: ^0.13.3 dev_dependencies: 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: - # This section identifies this Flutter project as a plugin project. - # The 'pluginClass' and Android 'package' identifiers should not ordinarily - # be modified. They are used by the tooling to maintain consistency when - # adding or updating assets for this project. +# flutter: null +# This section identifies this Flutter project as a plugin project. +# The 'pluginClass' and Android 'package' identifiers should not ordinarily +# be modified. They are used by the tooling to maintain consistency when +# adding or updating assets for this project. # plugin: # platforms: # android: @@ -32,34 +32,32 @@ flutter: # pluginClass: FlutterInstaPlugin # ios: # pluginClass: FlutterInstaPlugin - - # To add assets to your plugin 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 plugin 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 +# To add assets to your plugin 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 plugin 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