flutter_map_tile_caching 5.0.0-dev.1 copy "flutter_map_tile_caching: ^5.0.0-dev.1" to clipboard
flutter_map_tile_caching: ^5.0.0-dev.1 copied to clipboard

outdated

Plugin for 'flutter_map' providing advanced caching functionality, with ability to download map regions for offline use.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_map_tile_caching/flutter_map_tile_caching.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:provider/provider.dart';

import 'screens/main/main.dart';
import 'shared/state/general_provider.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  SystemChrome.setSystemUIOverlayStyle(
    const SystemUiOverlayStyle(statusBarColor: Colors.transparent),
  );

  FlutterMapTileCaching.initialise(await RootDirectory.normalCache);
  await FMTC.instance.rootDirectory.manage.resetAsync();

  await FMTC.instance('Store Alpha').manage.createAsync();
  await FMTC.instance('Store Beta').manage.createAsync();
  await FMTC.instance('Store Theta').manage.createAsync();
  await FMTC.instance('Store Gamma').manage.createAsync();

  runApp(const AppContainer());
}

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

  @override
  Widget build(BuildContext context) => MultiProvider(
        providers: [
          ChangeNotifierProvider<GeneralProvider>(
            create: (context) => GeneralProvider(),
          ),
        ],
        child: MaterialApp(
          title: 'FMTC Example',
          theme: ThemeData(
            primarySwatch: Colors.purple,
            useMaterial3: true,
            textTheme: GoogleFonts.openSansTextTheme(),
          ),
          debugShowCheckedModeBanner: false,
          home: const MainScreen(),
        ),
      );
}