uri_content 2.1.1 copy "uri_content: ^2.1.1" to clipboard
uri_content: ^2.1.1 copied to clipboard

Get the Uint8List content of a given Uri. Supports file, data, content and http/https

example/lib/main.dart

import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:uri_content/uri_content.dart';
import 'package:uri_content_example/android_content_uri_example.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final uriStringFuture = Uri.parse(
    "https://raw.githubusercontent.com/talesbarreto/pull_request_coverage/main/README.md",
  ).getContent().then(utf8.decode);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text("pull_request_coverage readme"),
        ),
        body: FutureBuilder<String>(
          future: uriStringFuture,
          builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
            return Markdown(
              data: snapshot.data ?? snapshot.connectionState.name,
              imageBuilder: (_, __, ___) => const SizedBox(),
            );
          },
        ),
        floatingActionButton: Visibility(
          visible: Theme.of(context).platform == TargetPlatform.android,
          child: Builder(
            builder: (context) => ElevatedButton(
              child: const Text("Android's content example"),
              onPressed: () => AndroidContentUriExample.push(context),
            ),
          ),
        ),
      ),
    );
  }
}
10
likes
160
pub points
95%
popularity

Publisher

unverified uploader

Get the Uint8List content of a given Uri. Supports file, data, content and http/https

Repository (GitHub)
View/report issues

Topics

#uri #download #content #uint8list

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on uri_content