Skip to content

Instantly share code, notes, and snippets.

View chamithchathuka's full-sized avatar
🏠
Working from home

Chamith Chathuka chamithchathuka

🏠
Working from home
View GitHub Profile
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter for Beginners',
home: Scaffold(
## Allow anonymous users to connect, default is 'off'. !!NOTE!!
## Enabling this completely disables authentication of the clients and
## should only be used for testing/development purposes or in case
## clients are authenticated by some other means.
##
## Default: off
##
## Acceptable values:
## - on or off
allow_anonymous = off
@RequestMapping("/socialshare")
void handleUpdate(HttpServletResponse response,@RequestHeader("User-Agent") String os) throws IOException {
System.out.println(os);
if (Pattern.compile(Pattern.quote("Android"), Pattern.CASE_INSENSITIVE).matcher(os).find())
response.sendRedirect("https://play.google.com/store/apps/details?id=com.rezgcorp.powerworld&hl=en");
else if (Pattern.compile(Pattern.quote("iPhone"), Pattern.CASE_INSENSITIVE).matcher(os).find()) {
response.sendRedirect("https://apps.apple.com/us/app/power-world-access-app/id1514909558");
} else {
@chamithchathuka
chamithchathuka / main.dart
Created October 30, 2020 03:20
Flutter Firebase Remote Config - Initial
import 'package:flutter/material.dart';
import 'package:get/get.dart';
void main() {
runApp(GetMaterialApp(
initialRoute: '/page1',
title: '',
theme: ThemeData.light().copyWith(primaryColor: Colors.green),
darkTheme: ThemeData.dark().copyWith(primaryColor: Colors.purple,backgroundColor: Colors.black, ),
themeMode: ThemeMode.light,
@chamithchathuka
chamithchathuka / main.dart
Last active October 30, 2020 08:30
Remote config Method
Future<RemoteConfig> setupRemoteConfig() async {
await Firebase.initializeApp();
final RemoteConfig remoteConfig = await RemoteConfig.instance;
remoteConfig.setConfigSettings(RemoteConfigSettings(debugMode: true));
remoteConfig.setDefaults(<String, dynamic>{
'primary_colour': 0xFFB74093,
'text_body_colour': 0xFFB71000,
'appbar_colour': 0xFFB71000,
'theme': 'system',
'enable_custom_theme': false,
void main() async {
WidgetsFlutterBinding.ensureInitialized(); // add this
await setupRemoteConfig(); // add call to the remote config initalize method method
runApp(GetMaterialApp(
initialRoute: '/page1',
title: '',
theme: ThemeData.light().copyWith(primaryColor: Colors.green),
darkTheme: ThemeData.dark().copyWith(
primaryColor: Colors.purple,
),
@chamithchathuka
chamithchathuka / schdeuled_notification.dart
Created December 20, 2020 17:36
Flutter Scheduled Notification with a Custom Sound
Future<void> _cancelNotification() async {
await flutterLocalNotificationsPlugin.cancel(0);
}
/// Schedules a notification that specifies a different icon, sound and vibration pattern
Future<void> _scheduleNotification() async {
var scheduledNotificationDateTime =
DateTime.now().add(Duration(seconds: 5));
var vibrationPattern = Int64List(4);
vibrationPattern[0] = 0;
let oVizFrame = that.getView().byId("idcolumn");
let oDataSet = new sap.viz.ui5.data.FlattenedDataset({
dimensions: [
{
name: "Brands",
value: "{Model>Brand}"
}
],
measures: [{
// Define a function.
void printInteger(int aNumber) {
print('The number is $aNumber.'); // Print to console.
}
// This is where the app starts executing.
void main() {
var number = 42; // Declare and initialize a variable.
printInteger(number); // Call a function.
}
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container();
}
}