Created with <3 with dartpad.dev.
Created
December 24, 2023 12:35
-
-
Save Holofox/f90d90f781d537ceed6342cbac9e52e5 to your computer and use it in GitHub Desktop.
sample-1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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