This repository has been archived on 2024-12-15. You can view files and clone it, but cannot push or open issues or pull requests.
comptaplan_app/lib/main.dart
cghislai 2005fd437f
Some checks failed
gestemps/comptaplanapp/pipeline/head There was a failure building this commit
fix
2021-11-27 18:30:36 +01:00

48 lines
1.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
void main() {
const title = String.fromEnvironment("APP_TITLE");
const uri = String.fromEnvironment("APP_URI");
const color = String.fromEnvironment("APP_COLOR");
runApp(const MyApp(title, uri, color));
}
class MyApp extends StatelessWidget {
final String _title;
final String _uri;
final String _color;
const MyApp(this._title, this._uri, this._color, {Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
MaterialColor materialColor = this._getMaterialColor(this._color);
return MaterialApp(
title: this._title,
theme: ThemeData(primarySwatch: materialColor),
home: WebView(
initialUrl: this._uri,
javascriptMode: JavascriptMode.unrestricted,
));
}
MaterialColor _getMaterialColor(String colorString) {
switch (colorString) {
case "blue":
return Colors.blue;
case "red":
return Colors.red;
case "green":
return Colors.green;
case "yellow":
return Colors.yellow;
case "teal":
return Colors.teal;
default:
return Colors.blue;
}
}
}