mellowtel 0.0.8
mellowtel: ^0.0.8 copied to clipboard
With Mellowtel, your users can share a fraction of their unused internet by using a transparent opt-in/out mechanism. Trusted partners access the internet through this network, and you get paid for it.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:mellowtel/mellowtel.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Example Screen'),
),
body: const ExampelScreen(),
),
);
}
}
class ExampelScreen extends StatefulWidget {
const ExampelScreen({super.key});
@override
ExampelScreenState createState() => ExampelScreenState();
}
class ExampelScreenState extends State<ExampelScreen> {
final Mellowtel mellowtel = Mellowtel("123",
dialogConfiguration: const ConsentDialogConfiguration(
appName: 'King Kong',
incentive: 'Earn 500 coins in Sling Kong',
appIcon: 'asset/logo.png', // Optional
acceptButtonText: 'Yes Coins!', // Optional
),
showDebugLogs: true);
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: ElevatedButton(
onPressed: () async {
await mellowtel.start(context, showConsentDialog: true,
onOptIn: () async {
// Handle enabling services when consent is provided.
}, onOptOut: () async {
// Handle disabling services if consent is denied.
});
},
child: const Text('Start'),
),
),
const SizedBox(height: 16.0),
Center(
child: ElevatedButton(
onPressed: () async {
await mellowtel.showConsentSettingsPage(context,
onOptIn: () async {
// Handle enabling services when consent is provided.
}, onOptOut: () async {
// Handle disabling services if consent is denied.
});
},
child: const Text('Settings'),
),
),
const SizedBox(height: 16.0),
],
),
);
}
@override
void dispose() {
mellowtel.stop();
super.dispose();
}
}