pagetitle 0.0.3 copy "pagetitle: ^0.0.3" to clipboard
pagetitle: ^0.0.3 copied to clipboard

A Flutter widget to dynamically update the application title.

example/example.dart

import 'package:flutter/material.dart';
import 'package:pagetitle/pagetitle.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      initialRoute: '/',
      routes: {
        '/': (context) => const HomePage(),
        '/test': (context) => const Page(title: 'Test Page'),
      },
      onGenerateTitle: (context) => PageTitle.current(context) ?? 'My App',
    );
  }
}

class Page extends StatelessWidget {
  const Page({super.key, required this.title});

  final String title;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: PageTitle(
        title: title,
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Text(title),
              ElevatedButton(
                onPressed: () {
                  Navigator.of(context).pop();
                },
                child: const Text('Go back!'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: PageTitle(
        title: 'Home Page',
        child: Center(
          child: ElevatedButton(
            onPressed: () {
              Navigator.of(context).pushNamed('/test');
            },
            child: const Text('Test page'),
          ),
        ),
      ),
    );
  }
}
1
likes
160
points
836
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter widget to dynamically update the application title.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on pagetitle