Skip to content

Commit

Permalink
feat: platform text field add
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Oct 16, 2022
1 parent 495b5db commit 30d5c4f
Show file tree
Hide file tree
Showing 3 changed files with 491 additions and 5 deletions.
54 changes: 49 additions & 5 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,33 @@ void main() {
runApp(const MyApp());
}

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

@override
State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
platform = TargetPlatform.macOS;
return const PlatformApp(
return PlatformApp(
title: 'Flutter Demo',
home: MyHomePage(title: 'Flutter Demo Home Page'),
home: MyHomePage(
title: 'Flutter Demo Home Page',
onChange: (value) {
setState(() {
platform = value;
});
},
),
);
}
}

class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final void Function(TargetPlatform?) onChange;
const MyHomePage({super.key, required this.title, required this.onChange});

final String title;

Expand Down Expand Up @@ -47,6 +59,31 @@ class _MyHomePageState extends State<MyHomePage> {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
PlatformFilledButton(
child: Text('Android'),
onPressed: () => widget.onChange(TargetPlatform.android),
),
PlatformFilledButton(
child: Text('iOS'),
onPressed: () => widget.onChange(TargetPlatform.iOS),
),
PlatformFilledButton(
child: Text('Linux'),
onPressed: () => widget.onChange(TargetPlatform.linux),
),
PlatformFilledButton(
child: Text('MacOS'),
onPressed: () => widget.onChange(TargetPlatform.macOS),
),
PlatformFilledButton(
child: Text('Windows'),
onPressed: () => widget.onChange(TargetPlatform.windows),
),
],
),
const Text(
'You have pushed the button this many times:',
),
Expand Down Expand Up @@ -86,6 +123,13 @@ class _MyHomePageState extends State<MyHomePage> {
inactiveTrackColor: Colors.white,
inactiveThumbColor: Colors.green,
),
PlatformTextField(
decoration: InputDecoration(
contentPadding: const EdgeInsets.all(10),
hintText: "Enter text",
labelText: 'TextField',
),
),
],
),
),
Expand Down
1 change: 1 addition & 0 deletions lib/platform_ui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export 'src/platform_filled_button.dart';
export 'src/platform_text_button.dart';
export 'src/platform_icon_button.dart';
export 'src/platform_switch.dart';
export 'src/platform_text_field.dart';
Loading

0 comments on commit 30d5c4f

Please sign in to comment.