Skip to content

Instantly share code, notes, and snippets.

@Holofox
Created December 24, 2023 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Holofox/f90d90f781d537ceed6342cbac9e52e5 to your computer and use it in GitHub Desktop.
Save Holofox/f90d90f781d537ceed6342cbac9e52e5 to your computer and use it in GitHub Desktop.
sample-1
import 'package:flutter/material.dart';
void main() => runApp(const MaterialApp(home: AuthScreen()));
class AuthScreen extends StatelessWidget {
const AuthScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Sign In')),
body: const AuthView(),
);
}
}
class AuthView extends StatelessWidget {
const AuthView({super.key});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(16.0),
child: CustomScrollView(
physics: const ClampingScrollPhysics(),
slivers: [
SliverList.list(
children: [
TextField(
autofocus: true,
decoration: const InputDecoration(hintText: 'Your username'),
onChanged: (value) => debugPrint('Username changed: $value'),
),
const SizedBox(height: 16.0),
],
),
SliverFillRemaining(
hasScrollBody: false,
child: Align(
alignment: Alignment.bottomCenter,
child: FractionallySizedBox(
widthFactor: 1.0,
child: ElevatedButton(
onPressed: () => ScaffoldMessenger.of(context)
..hideCurrentSnackBar()
..showSnackBar(
const SnackBar(content: Text('Sign in pressed')),
),
child: const Text('Sign in'),
),
),
),
),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment