1
answer
1
watching
132
views
dragon2020Lv1
20 Mar 2023
Using latest Flutter and Visual Code. Followed someone suggestion to align the text to the left side but it failed.
Anyway here is the code below
```
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart' show GoogleFonts;
// ignore: unused_import
import 'package:todolist/pages/tasklist/tasklist.dart';
import 'package:todolist/pages/tasklistdetails/tasklistdetails.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
textTheme: GoogleFonts.robotoCondensedTextTheme(),
),
initialRoute: '/tasklist',
routes: {
'/tasklist': ((context) => Scaffold(
appBar: AppBar(
title: const Text(
"Task List1 Page",
textAlign: TextAlign.left, // added this line to align text to left
),
),
body: const Text('Task list page'),
floatingActionButton: Theme(
data: Theme.of(context).copyWith(splashColor: Colors.amber),
child: FloatingActionButton(
onPressed: () => {Navigator.pop(context)},
tooltip: 'Increment',
child: const Icon(Icons.add),
),
),
)),
'/tasklistdetails': ((context) =>
const TaskListDetailsPage(title: "Task List Details Page"))
},
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: const Text('Task list page'),
floatingActionButton: Theme(
data: Theme.of(context).copyWith(splashColor: Colors.amber),
child: FloatingActionButton(
onPressed: () => {Navigator.pop(context)},
tooltip: 'Increment',
child: const Icon(Icons.add),
),
),
);
}
}
```
Screenshot of the result - Task List1 Page didn't get shifted to the left to be aligned with Task List Page.
Using latest Flutter and Visual Code. Followed someone suggestion to align the text to the left side but it failed.
Anyway here is the code below
```
import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart' show GoogleFonts; // ignore: unused_import import 'package:todolist/pages/tasklist/tasklist.dart'; import 'package:todolist/pages/tasklistdetails/tasklistdetails.dart';void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
textTheme: GoogleFonts.robotoCondensedTextTheme(),
),
initialRoute: '/tasklist',
routes: {
'/tasklist': ((context) => Scaffold(
appBar: AppBar(
title: const Text(
"Task List1 Page",
textAlign: TextAlign.left, // added this line to align text to left
),
),
body: const Text('Task list page'),
floatingActionButton: Theme(
data: Theme.of(context).copyWith(splashColor: Colors.amber),
child: FloatingActionButton(
onPressed: () => {Navigator.pop(context)},
tooltip: 'Increment',
child: const Icon(Icons.add),
),
),
)),
'/tasklistdetails': ((context) =>
const TaskListDetailsPage(title: "Task List Details Page"))
},
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: const Text('Task list page'),
floatingActionButton: Theme(
data: Theme.of(context).copyWith(splashColor: Colors.amber),
child: FloatingActionButton(
onPressed: () => {Navigator.pop(context)},
tooltip: 'Increment',
child: const Icon(Icons.add),
),
),
);
}
} ``` Screenshot of the result - Task List1 Page didn't get shifted to the left to be aligned with Task List Page.
Read by 1 person
20 Mar 2023