relatica/lib/controls/standard_appbar.dart

31 lines
932 B
Dart

import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import '../globals.dart';
import '../services/auth_service.dart';
class StandardAppBar {
static AppBar build(BuildContext context, String title,
{bool withDrawer = false, List<Widget>? actions}) {
final service = getIt<AccountsService>();
return AppBar(
leading: withDrawer
? service.loggedIn
? Builder(builder: (context) {
return IconButton(
onPressed: () {
Scaffold.of(context).openDrawer();
},
icon: CachedNetworkImage(
imageUrl: service.currentProfile.avatar));
})
: null
: null,
title: Text(
title,
overflow: TextOverflow.ellipsis,
),
actions: actions,
);
}
}