king_cache 0.0.54 copy "king_cache: ^0.0.54" to clipboard
king_cache: ^0.0.54 copied to clipboard

PlatformAndroid

A Flutter package for caching api data and markdown content to disk and improving app performance. It uses the http package to make api calls and use cache directory to cache data with specialized sup [...]

example/lib/main.dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import 'components/Analytics.dart';
import 'components/Cache.dart';
import 'components/logger.dart';
import 'components/network_calls.dart';

const pageWidgets = <Widget>[
  LogsPage(),
  NetworkCalls(),
  CachePage(),
  AnalyticsPage(),
];
const pages = [
  'Logger',
  'Network Calls',
  'Cache Management',
  'Analytics',
];

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

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

  @override
  Widget build(BuildContext context) => const MaterialApp(
        title: 'King Cache Example',
        home: MyHomePage(title: 'King Cache Example'),
      );
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);
    return Scaffold(
      body: GridView.builder(
          shrinkWrap: true,
          padding: const EdgeInsets.all(25),
          gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
            maxCrossAxisExtent: 200,
            childAspectRatio: 2,
            crossAxisSpacing: 20,
            mainAxisSpacing: 20,
          ),
          itemCount: pages.length,
          itemBuilder: (context, index) => Container(
                clipBehavior: Clip.antiAlias,
                decoration: ShapeDecoration(
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(20),
                  ),
                  shadows: [
                    BoxShadow(
                      color: theme.brightness == Brightness.dark
                          ? const Color(0x3FFFFFFF)
                          : const Color(0x3F000000),
                      blurRadius: 2,
                      offset: const Offset(0, 1),
                    )
                  ],
                ),
                child: Material(
                  color: theme.scaffoldBackgroundColor,
                  clipBehavior: Clip.antiAlias,
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(20),
                  ),
                  child: InkWell(
                    onTap: () => Navigator.push(
                        context,
                        MaterialPageRoute<Widget>(
                            builder: (context) => pageWidgets[index])),
                    borderRadius: const BorderRadius.all(Radius.circular(16)),
                    child: Container(
                      alignment: Alignment.center,
                      child: Text(
                        pages[index],
                        style: theme.textTheme.titleMedium,
                        textAlign: TextAlign.center,
                        maxLines: 1,
                        overflow: TextOverflow.ellipsis,
                      ),
                    ),
                  ),
                ),
              )),
    );
  }

  @override
  void debugFillProperties(DiagnosticPropertiesBuilder properties) {
    super.debugFillProperties(properties);
    properties.add(StringProperty('title', title));
  }
}
13
likes
140
points
443
downloads

Publisher

verified publisherkingtechnologies.dev

Weekly Downloads

A Flutter package for caching api data and markdown content to disk and improving app performance. It uses the http package to make api calls and use cache directory to cache data with specialized support for tech books and documentation.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

device_info_plus, firebase_analytics, firebase_crashlytics, flutter, http, in_app_update, intl, local_auth, logger, package_info_plus, path_provider, permission_handler, url_launcher, web

More

Packages that depend on king_cache