mastodon_flutter 0.3.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 51

mastodon_flutter #

A companion package to mastodon_dart that provides Flutter widgets to assist in developing a Mastodon Flutter client.

To see a complete Flutter Mastodon app, made with both mastodon_dart and this library, visit Jiminy for Mastodon.

Contributing #

Create an issue, back it with a PR, and tag an active contributor.

0.3.1 (4/7/2020) #

  • Update Media widget to properly handle sensitive content

0.3.0 (4/6/2020) #

  • BREAKING CHANGE: Completely revamp AuthBuilder. See example for details on how to use.
  • Add deleteToken function to AuthStorage
  • Updated example app

0.2.1 (3/19/2020 #

  • Correct StatusContent widget
  • New MediaInfo widget
  • 0.2.1+1: Fix MediaInfo not showing on MediaScreen
  • 0.2.1+2: Parameterize text color for StatusContent
  • 0.2.1+3: Update mastodon_dart dependency

0.2.0 (3/19/2020 #

  • Documentation updates
  • New widgets:
    • Media
    • MediaScreen
  • Renamed PostInfo to StatusContent
  • 0.2.0.+1: run flutter format lib

0.1.0 (March 15, 2020) #

  • Initial release my dudes

example/lib/main.dart

import 'package:example/timeline/timeline_screen.dart';
import 'package:flutter/material.dart';
import 'package:mastodon_dart/mastodon_dart.dart';
import 'package:mastodon_flutter/mastodon_flutter.dart';
import 'package:provider/provider.dart';
import 'package:web_socket_channel/io.dart';
import 'auth/auth_screen.dart';

Future<void> main() async {
  // Ensure widgets are bound and initialized before doing anything!
  WidgetsFlutterBinding.ensureInitialized();
  // Create an instance of Mastodon. You will likely want this to be dynamic.
  Mastodon masto = Mastodon(
    Uri.parse("https://mastodon.technology"),
    websocketFactory: (uri) => IOWebSocketChannel.connect(uri),
  );
  // Create an AuthBloc (from mastodon_dart)
  final AuthBloc authBloc = AuthBloc(
    masto,
    Uri.parse("https://github.com/lukepighetti/mastodon-flutter"),
    storage: AuthStorage(),
  );
  // Ensure the AuthBloc is initialized before running the app!
  await authBloc.initalized;
  // Run the app
  runApp(MyApp(
    bloc: authBloc,
    mastodon: masto,
  ));
}

// We provide MyApp with the AuthBloc and Mastodon from above. These will be passed
// down through the app via MultiProvider.
class MyApp extends StatelessWidget {
  const MyApp({
    Key key,
    @required this.bloc,
    this.mastodon,
  }) : super(key: key);

  final AuthBloc bloc;
  final Mastodon mastodon;

  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        Provider<AuthBloc>.value(value: bloc),
        Provider<Mastodon>.value(value: mastodon),
      ],
      child: MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
          cardTheme: CardTheme(elevation: 0.3),
          tabBarTheme: TabBarTheme(
            labelColor: Colors.blue,
          ),
        ),
        // Determine home widget based on authentication status. If there is a cached authentication token,
        // the AuthBloc will have already authenticated the user before the app is run, and we can get straight
        // to business. Otherwise go to the auth screen. NOTE: if you don't want to do it this way,
        // you don't have to, but you'll need to fiddle with your auth flow.
        home: bloc.account.value == null
            ? AuthScreen()
            : TimelineScreen(account: bloc.account.value),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  mastodon_flutter: ^0.3.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:mastodon_flutter/mastodon_flutter.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
7
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
51
Learn more about scoring.

We analyzed this package on Jul 10, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform android

Because of import path [package:mastodon_flutter/mastodon_flutter.dart, package:mastodon_flutter/src/auth_storage.dart, package:shared_preferences/shared_preferences.dart, package:shared_preferences_linux/shared_preferences_linux.dart] that declares support for platforms: linux

Package does not support Flutter platform ios

Because of import path [package:mastodon_flutter/mastodon_flutter.dart, package:mastodon_flutter/src/auth_storage.dart, package:shared_preferences/shared_preferences.dart, package:shared_preferences_linux/shared_preferences_linux.dart] that declares support for platforms: linux

Package does not support Flutter platform macos

Because of import path [package:mastodon_flutter/mastodon_flutter.dart, package:mastodon_flutter/src/auth_storage.dart, package:shared_preferences/shared_preferences.dart, package:shared_preferences_linux/shared_preferences_linux.dart] that declares support for platforms: linux

Package does not support Flutter platform web

Because of import path [package:mastodon_flutter/mastodon_flutter.dart, package:mastodon_flutter/src/auth_storage.dart, package:shared_preferences/shared_preferences.dart, package:shared_preferences_linux/shared_preferences_linux.dart] that declares support for platforms: linux

Package does not support Flutter platform windows

Because of import path [package:mastodon_flutter/mastodon_flutter.dart, package:mastodon_flutter/src/auth_storage.dart, package:shared_preferences/shared_preferences.dart] that declares support for platforms: android, ios, linux, macos, web

Package not compatible with SDK dart

because of import path [mastodon_flutter] that is in a package requiring null.

Health suggestions

Fix lib/src/emoji_text_span.dart. (-1 points)

Analysis of lib/src/emoji_text_span.dart reported 2 hints:

line 48 col 16: This function has a return type of 'String', but doesn't end with a return statement.

line 51 col 19: This function has a return type of 'String', but doesn't end with a return statement.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (mastodon_dart).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0 <3.0.0
feather_icons_flutter ^4.7.4 4.7.4
flutter 0.0.0
html ^0.14.0+3 0.14.0+3
mastodon_dart ^0.2.2 0.2.2 0.3.2
shared_preferences ^0.5.6+3 0.5.8
stack_trace ^1.9.3 1.9.5
timeago ^2.0.26 2.0.26
url_launcher ^5.4.2 5.5.0
Transitive dependencies
async 2.4.2
charcode 1.1.3
collection 1.14.12 1.14.13
convert 2.1.1
crypto 2.1.5
csslib 0.16.1
file 5.2.1
flutter_web_plugins 0.0.0
http 0.12.1
http_parser 3.1.4
intl 0.16.1
json_annotation 3.0.1
meta 1.1.8 1.2.2
path 1.7.0
path_provider_linux 0.0.1+2
path_provider_platform_interface 1.0.2
pedantic 1.9.0 1.9.2
platform 2.2.1
platform_detect 1.4.0
plugin_platform_interface 1.0.2
process 3.0.13
pub_semver 1.4.4
rxdart 0.23.1 0.24.1
shared_preferences_linux 0.0.2+1
shared_preferences_macos 0.0.1+10
shared_preferences_platform_interface 1.0.4
shared_preferences_web 0.1.2+7
sky_engine 0.0.99
source_span 1.7.0
stream_channel 2.0.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6 1.2.0
url_launcher_linux 0.0.1+1
url_launcher_macos 0.0.1+7
url_launcher_platform_interface 1.0.7
url_launcher_web 0.1.2
vector_math 2.0.8 2.1.0-nullsafety
web_socket_channel 1.1.0
xdg_directories 0.1.0
Dev dependencies
flutter_test