Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,5 @@ build/
example/.firebase/**.**
example/firebase.json
example/.firebase/hosting.YnVpbGQvd2Vi.cache

pubspec.lock
77 changes: 45 additions & 32 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
import 'package:example/pages/random_map.dart';
import 'package:example/pages/supported_countries_map.dart';
import 'package:flutter/material.dart';

import 'pages/random_map.dart';
import 'pages/supported_countries_map.dart';

void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(SMapExampleApp());
runApp(const SMapExampleApp());
}

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

// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Worldmap Example',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity),
home: MyHomePage());
title: 'Worldmap Example',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: const MyHomePage(),
);
}
}

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

@override
_MyHomePageState createState() => _MyHomePageState();
State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage>
Expand All @@ -40,27 +45,35 @@ class _MyHomePageState extends State<MyHomePage>
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Countries World Map',
style: TextStyle(color: Colors.blue)),
backgroundColor: Colors.transparent,
elevation: 0,
bottom: TabBar(controller: controller, tabs: [
ListTile(title: Center(child: Text('Supported countries'))),
ListTile(title: Center(child: Text('Random colors'))),
// ListTile(title: Center(child: Text('Africa'))),
])),
body: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: TabBarView(
physics: NeverScrollableScrollPhysics(),
controller: controller,
children: [
SupportedCountriesMap(),
RandomWorldMapGenerator(),
// AfricaContinent()
]),
));
appBar: AppBar(
title: const Text(
'Countries World Map',
style: TextStyle(color: Colors.blue),
),
backgroundColor: Colors.transparent,
elevation: 0,
bottom: TabBar(
controller: controller,
tabs: <Widget>[
const ListTile(title: Center(child: Text('Supported countries'))),
const ListTile(title: Center(child: Text('Random colors'))),
// ListTile(title: Center(child: Text('Africa'))),
],
),
),
body: SizedBox(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: TabBarView(
physics: const NeverScrollableScrollPhysics(),
controller: controller,
children: <Widget>[
const SupportedCountriesMap(),
const RandomWorldMapGenerator(),
// AfricaContinent()
],
),
),
);
}
}
47 changes: 27 additions & 20 deletions example/lib/pages/random_map.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import 'dart:math';

import 'package:countries_world_map/countries_world_map.dart';
import 'package:countries_world_map/data/maps/world_map.dart';
import 'package:flutter/material.dart';

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

@override
_RandomWorldMapGeneratorState createState() =>
State<RandomWorldMapGenerator> createState() =>
_RandomWorldMapGeneratorState();
}

class _RandomWorldMapGeneratorState extends State<RandomWorldMapGenerator> {
List<Color> colors = [
List<Color> colors = <Color>[
Colors.indigo.shade900,
Colors.blue,
Colors.pink,
Expand All @@ -23,7 +24,7 @@ class _RandomWorldMapGeneratorState extends State<RandomWorldMapGenerator> {
Colors.black,
];

final _random = Random();
final Random _random = Random();

@override
void initState() {
Expand All @@ -36,19 +37,20 @@ class _RandomWorldMapGeneratorState extends State<RandomWorldMapGenerator> {
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: Stack(
children: [
children: <Widget>[
InteractiveViewer(
maxScale: 75.0,
maxScale: 75,
child: Center(
child: Row(
children: [
children: <Widget>[
SizedBox(
width: MediaQuery.of(context).size.width * 0.92,
// Actual widget from the Countries_world_map package.
child: SimpleMap(
countryBorder: CountryBorder(color: Colors.white),
countryBorder: const CountryBorder(color: Colors.white),
instructions: SMapWorld.instructionsMercator,
callback: (id, name, tabDetails) {
callback:
(String id, String name, TouchDetails tabDetails) {
print(id + name);
},
colors: SMapWorldColors(
Expand Down Expand Up @@ -312,21 +314,26 @@ class _RandomWorldMapGeneratorState extends State<RandomWorldMapGenerator> {
),
),
),
Positioned(
bottom: 36,
left: 0,
right: 0,
child: Text('Tap / click the dice to change the colors',
style: TextStyle(fontSize: 18), textAlign: TextAlign.center)),
const Positioned(
bottom: 36,
left: 0,
right: 0,
child: Text(
'Tap / click the dice to change the colors',
style: TextStyle(fontSize: 18),
textAlign: TextAlign.center,
),
),
Positioned(
bottom: 36,
right: 36,
child: FloatingActionButton(
tooltip: 'Randomize',
onPressed: () {
setState(() {});
},
child: Icon(Icons.casino)),
tooltip: 'Randomize',
onPressed: () {
setState(() {});
},
child: const Icon(Icons.casino),
),
),
],
),
Expand Down
Loading