2
answers
1
watching
101
views

Still having problems title not being shifted using TextAlign property. Using Visual Code and Flutter. Visual Code is complaining about it. Here's the code

Also please use the ``` when putting in your code so I can see it clearly since it will be formatted.

'''

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: Container(               alignment: Alignment.centerLeft, //Aligns the app bar to the left               child: AppBar(               title: const Text(                  "Task List1 Page",                ),                ),                ),               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 error from Visual Code. It's complaining about the Container. So I tried to replace the container with PreferredSizedWidget it didn't work either. Has someone tried this on the latest Visual Code.    

For unlimited access to Homework Help, a Homework+ subscription is required.

Unlock all answers

Get 1 free homework help answer.
Already have an account? Log in
Avatar image
Read by 1 person
Already have an account? Log in

Related questions

Weekly leaderboard

Start filling in the gaps now
Log in