getter 0.0.3 icon indicating copy to clipboard operation
getter: ^0.0.3 copied to clipboard

PlatformAndroid

By using this plugin you can get images, videos, or audios from the local storage.

example/lib/main.dart

import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:getter/getter.dart';

void main() => runApp(MyApp());

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: HomeScreen(),
    );
  }
}

class HomeScreen extends StatefulWidget {
  const HomeScreen({Key? key}) : super(key: key);

  @override
  _HomeScreenState createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  Future<List<Media>> getImages() async {
    return await Getter.get(type: GetterType.photos);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: FutureBuilder<List<Media>>(
        future: getImages(),
        builder: (_, snapshot) {
          if (!snapshot.hasData) {
            return Center(
              child: const CircularProgressIndicator(),
            );
          }
          if (snapshot.data!.isEmpty) {
            return Text('Nothing to show');
          }
          return GridView.count(
            crossAxisCount: 2,
            children: List.generate(
              snapshot.data!.length,
              (i) => Image.file(
                File.fromUri(snapshot.data![i].path),
                fit: BoxFit.cover,
              ),
            ),
          );
        },
      ),
    );
  }
}
27
likes
130
pub points
51%
popularity

Publisher

unverified uploader

By using this plugin you can get images, videos, or audios from the local storage.

Repository (GitHub)

Documentation

API reference

License

Icon for licenses.GPL-3.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on getter