trial_manager 0.0.2
trial_manager: ^0.0.2 copied to clipboard
The trial_manager package for Flutter provides utilities to manage trial periods within applications.
import 'package:flutter/material.dart';
import 'package:trial_manager/trial_manager.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await TrialManager.initialize();
final trialExpired = await TrialManager.isTrialExpired(trialPeriodDays: 0);
runApp(MyApp(trialExpired: trialExpired));
}
class MyApp extends StatelessWidget {
final bool trialExpired;
const MyApp({super.key, required this.trialExpired});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
if(trialExpired){
return MaterialApp(
home: TrialManager.getExpirationScreen(type: ExpirationScreenType.type1),
);
}
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
//
// TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint"
// action in the IDE, or press "p" in the console), to see the
// wireframe for each widget.
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}