KonectarEvents/lib/firebaseexample.dart

63 lines
1.8 KiB
Dart
Raw Normal View History

2024-09-06 06:30:31 +00:00
import 'dart:convert';
import 'package:firebase_remote_config/firebase_remote_config.dart';
import 'package:flutter/material.dart';
import 'package:konectar_events/flutter_eval.dart';
import 'package:konectar_events/view/home.dart';
import 'package:konectar_events/widgets/custombutton.dart';
class FirebaseExample extends StatefulWidget {
String title;
FirebaseExample({super.key, required this.title});
@override
State<FirebaseExample> createState() => _FirebaseExampleState();
}
class _FirebaseExampleState extends State<FirebaseExample> {
final remoteConfig = FirebaseRemoteConfig.instance;
String value = "clientA";
@override
void initState() {
// TODO: implement initState
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
init();
});
super.initState();
}
init() async {
await remoteConfig.fetchAndActivate();
// RemoteConfigValue rawData = remoteConfig.getValue("client-A");
// print(rawData);
// const jsonString =
// '{"text": "foo", "value": 1, "status": false, "extra": null}';
// var map = jsonDecode(rawData.toString());
setState(() {
value = remoteConfig.getString(widget.title);
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Center(child: Text(value)),
CustomButton(
backgroundColor: Colors.amber,
title: "Continue",
onPressed: () {
String filejson = remoteConfig.getString("json");
Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (context) => HomeScreen()),
);
},
textColor: Colors.white,
)
],
));
}
}