circle_flags 5.0.0 copy "circle_flags: ^5.0.0" to clipboard
circle_flags: ^5.0.0 copied to clipboard

A collection of roundd flags

example/lib/main.dart

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

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

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

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

class _MyAppState extends State<MyApp> {
  bool preloaded = false;
  bool showFlags = false;

  @override
  void initState() {
    super.initState();
  }

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
    // preloading flags so they how instantly (mostly useful for web)
    if (!preloaded) {
      CircleFlag.preload(Flag.values);
      preloaded = true;
    }
  }

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        brightness: Brightness.light,
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Flags'),
        ),
        body: showFlags
            ? ListView.builder(
                itemCount: Flag.values.length,
                itemBuilder: (context, index) => Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: ListTile(
                    leading: CircleFlag(
                      Flag.values[index],
                      size: 32,
                    ),
                    title: Text(Flag.values[index]),
                    onTap: () {},
                  ),
                ),
              )
            : Center(
                child: ElevatedButton(
                    onPressed: () {
                      setState(() {
                        showFlags = true;
                      });
                    },
                    child: const Text('show')),
              ),
      ),
    );
  }
}
38
likes
140
points
32.9k
downloads

Publisher

unverified uploader

Weekly Downloads

A collection of roundd flags

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_svg

More

Packages that depend on circle_flags