tablet-app/lib/main.dart
2020-12-28 16:22:45 +01:00

99 lines
2.2 KiB
Dart

import 'package:flutter/material.dart';
import 'constants.dart';
void main() {
String initialRoute;
initialRoute = '/home';
final MyApp myApp = MyApp(
initialRoute: initialRoute,
//context: localContext,
);
runApp(myApp);
}
class MyApp extends StatefulWidget {
final String initialRoute;
//final Context context;
MyApp({this.initialRoute});
// This widget is the root of your application.
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Tablet App Demo',
initialRoute: widget.initialRoute,
supportedLocales: [
const Locale('en', 'US'),
const Locale('fr', 'FR'),
],
theme: ThemeData(
primarySwatch: Colors.grey,
scaffoldBackgroundColor: kBackgroundColor,
//fontFamily: "Vollkorn",
textTheme: TextTheme(bodyText1: TextStyle(color: kBodyTextColor)),
visualDensity: VisualDensity.adaptivePlatformDensity,
),
routes: {
'/home': (context) => MyHomePage(title: 'Tablet App Demo Home Page')
}
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
}